cursor inference bugfix

This commit is contained in:
Andreas Rumpf
2020-07-20 18:37:14 +02:00
parent 80d3ef9952
commit 3a4e4cec4d
2 changed files with 65 additions and 4 deletions

View File

@@ -237,10 +237,11 @@ proc analyse(c: var Con; n: PNode) =
# assignments like 'x.field = value' mean that 'x' itself cannot
# be a cursor:
let r = locationRoot(n[0])
if r != nil and r.typ.skipTypes(abstractInst).kind notin {tyPtr, tyRef}:
if r != nil:
# however, an assignment like 'it.field = x' does not influence r's
# cursorness property:
c.mayOwnData.incl r.id
if r.typ.skipTypes(abstractInst).kind notin {tyPtr, tyRef}:
c.mayOwnData.incl r.id
c.mutations.incl r.id
if hasDestructor(n[1].typ):