diff --git a/compiler/lookups.nim b/compiler/lookups.nim index 93a7b7c722..fcb5b67314 100644 --- a/compiler/lookups.nim +++ b/compiler/lookups.nim @@ -92,7 +92,7 @@ proc errorSym*(c: PContext, n: PNode): PSym = result.typ = errorType(c) incl(result.flags, sfDiscardable) # pretend it's imported from some unknown module to prevent cascading errors: - if gCmd != cmdInteractive: + if gCmd != cmdInteractive and c.inCompilesContext == 0: c.importTable.addSym(result) type diff --git a/tests/compiles/tcompiles.nim b/tests/compiles/tcompiles.nim index d0fccdaff8..b3d9c17ce7 100644 --- a/tests/compiles/tcompiles.nim +++ b/tests/compiles/tcompiles.nim @@ -24,3 +24,5 @@ ok supports(`+`, 34) no compiles(4+5.0 * "hallo") +no compiles(undeclaredIdentifier) +no compiles(undeclaredIdentifier)