parent
038f47e7b9
commit
240174dd81
2 changed files with 34 additions and 5 deletions
|
|
@ -609,15 +609,16 @@ proc aliases*(obj, field: PNode): bool =
|
||||||
|
|
||||||
proc useInstrTargets*(ins: Instr; loc: PNode): bool =
|
proc useInstrTargets*(ins: Instr; loc: PNode): bool =
|
||||||
assert ins.kind == use
|
assert ins.kind == use
|
||||||
sameTrees(ins.n, loc) or
|
result = sameTrees(ins.n, loc) or
|
||||||
ins.n.aliases(loc) or loc.aliases(ins.n) # We can come here if loc is 'x.f' and ins.n is 'x' or the other way round.
|
ins.n.aliases(loc) or loc.aliases(ins.n)
|
||||||
|
# We can come here if loc is 'x.f' and ins.n is 'x' or the other way round.
|
||||||
# use x.f; question: does it affect the full 'x'? No.
|
# use x.f; question: does it affect the full 'x'? No.
|
||||||
# use x; question does it affect 'x.f'? Yes.
|
# use x; question does it affect 'x.f'? Yes.
|
||||||
|
|
||||||
proc defInstrTargets*(ins: Instr; loc: PNode): bool =
|
proc defInstrTargets*(ins: Instr; loc: PNode): bool =
|
||||||
assert ins.kind == def
|
assert ins.kind == def
|
||||||
sameTrees(ins.n, loc) or
|
result = sameTrees(ins.n, loc) or ins.n.aliases(loc)
|
||||||
ins.n.aliases(loc) # We can come here if loc is 'x.f' and ins.n is 'x' or the other way round.
|
# We can come here if loc is 'x.f' and ins.n is 'x' or the other way round.
|
||||||
# def x.f; question: does it affect the full 'x'? No.
|
# def x.f; question: does it affect the full 'x'? No.
|
||||||
# def x; question: does it affect the 'x.f'? Yes.
|
# def x; question: does it affect the 'x.f'? Yes.
|
||||||
|
|
||||||
|
|
@ -678,6 +679,10 @@ proc genDef(c: var Con; n: PNode) =
|
||||||
c.code.add Instr(n: n, kind: def)
|
c.code.add Instr(n: n, kind: def)
|
||||||
elif isAnalysableFieldAccess(n, c.owner):
|
elif isAnalysableFieldAccess(n, c.owner):
|
||||||
c.code.add Instr(n: n, kind: def)
|
c.code.add Instr(n: n, kind: def)
|
||||||
|
else:
|
||||||
|
# bug #13314: An assignment to t5.w = -5 is a usage of 't5'
|
||||||
|
# we still need to gather the use information:
|
||||||
|
gen(c, n)
|
||||||
|
|
||||||
proc genCall(c: var Con; n: PNode) =
|
proc genCall(c: var Con; n: PNode) =
|
||||||
gen(c, n[0])
|
gen(c, n[0])
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
discard """
|
discard """
|
||||||
cmd: "nim c --gc:arc $file"
|
cmd: "nim c --gc:arc $file"
|
||||||
output: '''5'''
|
output: '''5
|
||||||
|
(w: 5)
|
||||||
|
(w: -5)
|
||||||
|
'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# move bug
|
# move bug
|
||||||
|
|
@ -62,3 +65,24 @@ proc main =
|
||||||
|
|
||||||
main()
|
main()
|
||||||
echo destroyCounter
|
echo destroyCounter
|
||||||
|
|
||||||
|
# bug #13314
|
||||||
|
|
||||||
|
type
|
||||||
|
O = object
|
||||||
|
v: int
|
||||||
|
R = ref object
|
||||||
|
w: int
|
||||||
|
|
||||||
|
proc `$`(r: R): string = $r[]
|
||||||
|
|
||||||
|
proc tbug13314 =
|
||||||
|
var t5 = R(w: 5)
|
||||||
|
var execute = proc () =
|
||||||
|
echo t5
|
||||||
|
|
||||||
|
execute()
|
||||||
|
t5.w = -5
|
||||||
|
execute()
|
||||||
|
|
||||||
|
tbug13314()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue