mirror of
https://github.com/nim-lang/Nim.git
synced 2026-09-17 18:44:53 +00:00
fixes #26123 `cast[T](x)` is a transparent path expression for compiler analysis. Previously, move/alias analysis could fail to see a later use through a cast and incorrectly mark the source as moved, causing the issue’s segmentation fault. for views, https://nim-lang.org/docs/manual_experimental.html#view-types-path-expressions: A cast expression cast[T](e) is a path expression. It also affects skipConvDfa, isAnalysableFieldAccess, and aliases. And I might narrow it down for the two cases above mentioned if it causes problems
29 lines
327 B
Nim
29 lines
327 B
Nim
discard """
|
|
matrix: "--mm:orc"
|
|
output: "destroy b"
|
|
"""
|
|
|
|
# bug #26123
|
|
|
|
type
|
|
A = ptr AObj
|
|
|
|
AObj = object
|
|
b: B
|
|
|
|
B = distinct ptr BObj
|
|
|
|
BObj = object
|
|
a: A
|
|
|
|
proc `=destroy`(r: var B) =
|
|
echo "destroy b"
|
|
|
|
proc main() =
|
|
var a = create(AObj)
|
|
var b = B(create(BObj))
|
|
a.b = b
|
|
cast[ptr BObj](b).a = a
|
|
|
|
main()
|