cursor inference: hotfix (#14999)
This commit is contained in:
parent
ba5604b96d
commit
6b607413e9
1 changed files with 13 additions and 8 deletions
|
|
@ -35,6 +35,7 @@ type
|
||||||
mutations: IntSet
|
mutations: IntSet
|
||||||
reassigns: IntSet
|
reassigns: IntSet
|
||||||
config: ConfigRef
|
config: ConfigRef
|
||||||
|
inAsgnSource: int
|
||||||
|
|
||||||
proc locationRoot(e: PNode; followDotExpr = true): PSym =
|
proc locationRoot(e: PNode; followDotExpr = true): PSym =
|
||||||
var n = e
|
var n = e
|
||||||
|
|
@ -221,7 +222,9 @@ proc analyse(c: var Con; n: PNode) =
|
||||||
|
|
||||||
of nkAsgn, nkFastAsgn:
|
of nkAsgn, nkFastAsgn:
|
||||||
analyse(c, n[0])
|
analyse(c, n[0])
|
||||||
|
inc c.inAsgnSource
|
||||||
analyse(c, n[1])
|
analyse(c, n[1])
|
||||||
|
dec c.inAsgnSource
|
||||||
|
|
||||||
if n[0].kind == nkSym:
|
if n[0].kind == nkSym:
|
||||||
if hasDestructor(n[0].typ):
|
if hasDestructor(n[0].typ):
|
||||||
|
|
@ -252,14 +255,16 @@ proc analyse(c: var Con; n: PNode) =
|
||||||
c.mutations.incl r.id
|
c.mutations.incl r.id
|
||||||
|
|
||||||
of nkTupleConstr, nkBracket, nkObjConstr:
|
of nkTupleConstr, nkBracket, nkObjConstr:
|
||||||
for i in ord(n.kind == nkObjConstr)..<n.len:
|
for child in n: analyse(c, child)
|
||||||
if n[i].kind == nkSym:
|
if c.inAsgnSource > 0:
|
||||||
# we assume constructions with cursors are better without
|
for i in ord(n.kind == nkObjConstr)..<n.len:
|
||||||
# the cursors because it's likely we can move then, see
|
if n[i].kind == nkSym:
|
||||||
# test arc/topt_no_cursor.nim
|
# we assume constructions with cursors are better without
|
||||||
let r = n[i].sym
|
# the cursors because it's likely we can move then, see
|
||||||
c.mayOwnData.incl r.id
|
# test arc/topt_no_cursor.nim
|
||||||
c.mutations.incl r.id
|
let r = n[i].sym
|
||||||
|
c.mayOwnData.incl r.id
|
||||||
|
c.mutations.incl r.id
|
||||||
|
|
||||||
of nkVarSection, nkLetSection:
|
of nkVarSection, nkLetSection:
|
||||||
for it in n:
|
for it in n:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue