mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 05:50:30 +00:00
since the example code return value from global variable, instead
of first argument, the `n.len` is 1 which causes compiler crashes.
(cherry picked from commit f755e452d2)
This commit is contained in:
@@ -479,7 +479,7 @@ proc destMightOwn(c: var Partitions; dest: var VarIndex; n: PNode) =
|
||||
# calls do construct, what we construct must be destroyed,
|
||||
# so dest cannot be a cursor:
|
||||
dest.flags.incl ownsData
|
||||
elif n.typ.kind in {tyLent, tyVar}:
|
||||
elif n.typ.kind in {tyLent, tyVar} and n.len > 1:
|
||||
# we know the result is derived from the first argument:
|
||||
var roots: seq[(PSym, int)]
|
||||
allRoots(n[1], roots, RootEscapes)
|
||||
|
||||
10
tests/arc/t18971.nim
Normal file
10
tests/arc/t18971.nim
Normal file
@@ -0,0 +1,10 @@
|
||||
discard """
|
||||
cmd: "nim c --gc:arc $file"
|
||||
"""
|
||||
|
||||
type MyObj = ref object
|
||||
|
||||
var o = MyObj()
|
||||
proc x: var MyObj = o
|
||||
|
||||
var o2 = x()
|
||||
Reference in New Issue
Block a user