summary refs log tree commit diff stats
path: root/compiler/seminst.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2014-11-16 20:32:05 +0100
committerAraq <rumpf_a@web.de>2014-11-16 20:32:05 +0100
commit8349cee613e971525b7c21aeee16eac41decd139 (patch)
tree134ddc3485c7a5fb42a035a38935511035b9cf75 /compiler/seminst.nim
parentf7dca91344392a200392bdbd5d2d7c5167298e93 (diff)
downloadNim-8349cee613e971525b7c21aeee16eac41decd139.tar.gz
fixes #1055
Diffstat (limited to 'compiler/seminst.nim')
-rw-r--r--compiler/seminst.nim9
1 files changed, 6 insertions, 3 deletions
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)