diff options
-rw-r--r-- | compiler/semstmts.nim | 2 | ||||
-rw-r--r-- | tests/global/t21896.nim | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 579af973e..6e2fb9252 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -563,7 +563,7 @@ proc semVarMacroPragma(c: PContext, a: PNode, n: PNode): PNode = return result template isLocalSym(sym: PSym): bool = - sym.kind in {skVar, skLet} and not + sym.kind in {skVar, skLet, skParam} and not ({sfGlobal, sfPure} * sym.flags != {} or sfCompileTime in sym.flags) or sym.kind in {skProc, skFunc, skIterator} and diff --git a/tests/global/t21896.nim b/tests/global/t21896.nim new file mode 100644 index 000000000..c7765c4dd --- /dev/null +++ b/tests/global/t21896.nim @@ -0,0 +1,9 @@ +discard """ + errormsg: "cannot assign local to global variable" + line: 7 +""" + +proc example(a:int) = + let b {.global.} = a + +example(1) |