diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2020-02-09 00:22:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-09 00:22:34 +0100 |
commit | 240174dd81781e279d84090f1937ebf4b971e29c (patch) | |
tree | ff168e604fbdc0b855d6013dc64bbb04c2c69929 /compiler | |
parent | 038f47e7b93308bef0118e1ef73edf36e39f9b91 (diff) | |
download | Nim-240174dd81781e279d84090f1937ebf4b971e29c.tar.gz |
fixes #13314 (#13372)
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/dfa.nim | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/compiler/dfa.nim b/compiler/dfa.nim index 2f3a54b60..b46db9aed 100644 --- a/compiler/dfa.nim +++ b/compiler/dfa.nim @@ -609,15 +609,16 @@ proc aliases*(obj, field: PNode): bool = proc useInstrTargets*(ins: Instr; loc: PNode): bool = assert ins.kind == use - 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. + 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. # use x.f; question: does it affect the full 'x'? No. # use x; question does it affect 'x.f'? Yes. proc defInstrTargets*(ins: Instr; loc: PNode): bool = assert ins.kind == def - sameTrees(ins.n, loc) or - ins.n.aliases(loc) # We can come here if loc is 'x.f' and ins.n is 'x' or the other way round. + result = sameTrees(ins.n, loc) or ins.n.aliases(loc) + # 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; 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) elif isAnalysableFieldAccess(n, c.owner): 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) = gen(c, n[0]) |