* fixes #11515

* better fix for #11515; make tests green
This commit is contained in:
Andreas Rumpf 2019-07-01 18:08:50 +02:00 • committed by GitHub
commit 766960dc15
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 6 deletions

View file

@ -2023,6 +2023,9 @@ proc tryExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
let oldErrorCount = c.config.errorCounter let oldErrorCount = c.config.errorCounter
let oldErrorMax = c.config.errorMax let oldErrorMax = c.config.errorMax
let oldCompilesId = c.compilesContextId let oldCompilesId = c.compilesContextId
# if this is a nested 'when compiles', do not increase the ID so that
# generic instantations can still be cached for this level.
if c.compilesContextId == 0:
inc c.compilesContextIdGenerator inc c.compilesContextIdGenerator
c.compilesContextId = c.compilesContextIdGenerator c.compilesContextId = c.compilesContextIdGenerator
# do not halt after first error: # do not halt after first error:

View file

@ -98,7 +98,7 @@ proc sameInstantiation(a, b: TInstantiation): bool =
proc genericCacheGet(genericSym: PSym, entry: TInstantiation; proc genericCacheGet(genericSym: PSym, entry: TInstantiation;
id: CompilesId): PSym = id: CompilesId): PSym =
for inst in genericSym.procInstCache: for inst in genericSym.procInstCache:
if inst.compilesId == id and sameInstantiation(entry, inst[]): if (inst.compilesId == 0 or inst.compilesId == id) and sameInstantiation(entry, inst[]):
return inst.sym return inst.sym
when false: when false:

View file

@ -1,6 +1,5 @@
discard """ discard """
errormsg: "generic instantiation too nested" action: compile
file: "system.nim"
""" """
# bug #4766 # bug #4766

View file

@ -1,5 +1,5 @@
discard """ discard """
errormsg: "generic instantiation too nested" action: compile
""" """
#[ #[