diff options
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/ast.nim | 2 | ||||
-rw-r--r-- | compiler/seminst.nim | 9 |
2 files changed, 7 insertions, 4 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim index 4f0b47b85..ec309ba1a 100644 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -1055,7 +1055,7 @@ proc discardSons(father: PNode) = father.sons = nil when defined(useNodeIds): - const nodeIdToDebug* = 310841 # 612794 + const nodeIdToDebug* = -1 # 884953 # 612794 #612840 # 612905 # 614635 # 614637 # 614641 # 423408 #429107 # 430443 # 441048 # 441090 # 441153 diff --git a/compiler/seminst.nim b/compiler/seminst.nim index 8ac3849b4..2decb5d0b 100644 --- a/compiler/seminst.nim +++ b/compiler/seminst.nim @@ -157,8 +157,7 @@ proc instantiateProcType(c: PContext, pt: TIdTable, # # The solution would be to move this logic into semtypinst, but # at this point semtypinst have to become part of sem, because it - # will need to use openScope, addDecl, etc - # + # will need to use openScope, addDecl, etc. addDecl(c, prc) pushInfoContext(info) @@ -223,7 +222,11 @@ proc generateInstance(c: PContext, fn: PSym, pt: TIdTable, n.sons[genericParamsPos] = ast.emptyNode var oldPrc = genericCacheGet(fn, entry[]) if oldPrc == nil: - fn.procInstCache.safeAdd(entry) + # we MUST not add potentially wrong instantiations to the caching mechanism. + # This means recursive instantiations behave differently when in + # a ``compiles`` context but this is the lesser evil. See + # bug #1055 (tevilcompiles). + if c.inCompilesContext == 0: fn.procInstCache.safeAdd(entry) c.generics.add(makeInstPair(fn, entry)) if n.sons[pragmasPos].kind != nkEmpty: pragma(c, result, n.sons[pragmasPos], allRoutinePragmas) |