diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2019-08-23 18:58:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-23 18:58:55 +0200 |
commit | fbb2763204ada801f3935e9cbab80abab9a7e945 (patch) | |
tree | 7ad629fe7e4d39797e25100aea2877fb842f852d /compiler/plugins/locals.nim | |
parent | b07694cd90ab7c6eb4660971ddb818b461d4eed8 (diff) | |
download | Nim-fbb2763204ada801f3935e9cbab80abab9a7e945.tar.gz |
fixes #11958 (#12013)
Diffstat (limited to 'compiler/plugins/locals.nim')
-rw-r--r-- | compiler/plugins/locals.nim | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/compiler/plugins/locals.nim b/compiler/plugins/locals.nim index 08d836f7d..73f6eaa19 100644 --- a/compiler/plugins/locals.nim +++ b/compiler/plugins/locals.nim @@ -17,25 +17,24 @@ proc semLocals*(c: PContext, n: PNode): PNode = var tupleType = newTypeS(tyTuple, c) result = newNodeIT(nkPar, n.info, tupleType) tupleType.n = newNodeI(nkRecList, n.info) + let owner = getCurrOwner(c) # for now we skip openarrays ... for scope in walkScopes(c.currentScope): if scope == c.topLevelScope: break for it in items(scope.symbols): - # XXX parameters' owners are wrong for generics; this caused some pain - # for closures too; we should finally fix it. - #if it.owner != c.p.owner: return result if it.kind in skLocalVars and it.typ.skipTypes({tyGenericInst, tyVar}).kind notin {tyVarargs, tyOpenArray, tyTypeDesc, tyStatic, tyUntyped, tyTyped, tyEmpty}: - var field = newSym(skField, it.name, getCurrOwner(c), n.info) - field.typ = it.typ.skipTypes({tyVar}) - field.position = counter - inc(counter) + if it.owner == owner: + var field = newSym(skField, it.name, owner, n.info) + field.typ = it.typ.skipTypes({tyVar}) + field.position = counter + inc(counter) - addSon(tupleType.n, newSymNode(field)) - addSonSkipIntLit(tupleType, field.typ) + addSon(tupleType.n, newSymNode(field)) + addSonSkipIntLit(tupleType, field.typ) - var a = newSymNode(it, result.info) - if it.typ.skipTypes({tyGenericInst}).kind == tyVar: a = newDeref(a) - result.add(a) + var a = newSymNode(it, result.info) + if it.typ.skipTypes({tyGenericInst}).kind == tyVar: a = newDeref(a) + result.add(a) |