diff options
author | Araq <rumpf_a@web.de> | 2017-02-16 21:30:54 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2017-02-16 21:30:54 +0100 |
commit | 0440aea69158dfde7e315d547f8f2ed474a705c0 (patch) | |
tree | 6f2a69b2c57ed5bbcfab0e62ffdaeab699728473 /compiler | |
parent | 61181702d5cf68e4b7a97cac352b395d37ddb702 (diff) | |
download | Nim-0440aea69158dfde7e315d547f8f2ed474a705c0.tar.gz |
fixes #5405
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/sem.nim | 10 | ||||
-rw-r--r-- | compiler/semdata.nim | 20 | ||||
-rw-r--r-- | compiler/sigmatch.nim | 2 |
3 files changed, 22 insertions, 10 deletions
diff --git a/compiler/sem.nim b/compiler/sem.nim index 961d9fa75..fc7736b07 100644 --- a/compiler/sem.nim +++ b/compiler/sem.nim @@ -168,16 +168,6 @@ proc commonType*(x, y: PType): PType = proc newSymS(kind: TSymKind, n: PNode, c: PContext): PSym = result = newSym(kind, considerQuotedIdent(n), getCurrOwner(), n.info) -proc getGenSym(c: PContext; s: PSym): PSym = - var it = c.p - while it != nil: - result = get(it, s) - if result != nil: - #echo "got from table ", result.name.s, " ", result.info - return result - it = it.next - result = s - proc newSymG*(kind: TSymKind, n: PNode, c: PContext): PSym = proc `$`(kind: TSymKind): string = substr(system.`$`(kind), 2).toLowerAscii diff --git a/compiler/semdata.nim b/compiler/semdata.nim index 845efd25a..77a530a15 100644 --- a/compiler/semdata.nim +++ b/compiler/semdata.nim @@ -157,6 +157,26 @@ proc get*(p: PProcCon; key: PSym): PSym = if p.mapping.data == nil: return nil result = PSym(p.mapping.idTableGet(key)) +proc getGenSym*(c: PContext; s: PSym): PSym = + if sfGenSym notin s.flags: return s + var it = c.p + while it != nil: + result = get(it, s) + if result != nil: + #echo "got from table ", result.name.s, " ", result.info + return result + it = it.next + result = s + +proc considerGenSyms*(c: PContext; n: PNode) = + if n.kind == nkSym: + let s = getGenSym(c, n.sym) + if n.sym != s: + n.sym = s + else: + for i in 0..<n.safeLen: + considerGenSyms(c, n.sons[i]) + proc newOptionEntry*(): POptionEntry = new(result) result.options = gOptions diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index 90253a691..d3c142954 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -1583,12 +1583,14 @@ proc prepareOperand(c: PContext; formal: PType; a: PNode): PNode = result = c.semOperand(c, a, flags) else: result = a + considerGenSyms(c, result) proc prepareOperand(c: PContext; a: PNode): PNode = if a.typ.isNil: result = c.semOperand(c, a, {efDetermineType}) else: result = a + considerGenSyms(c, result) proc prepareNamedParam(a: PNode) = if a.sons[0].kind != nkIdent: |