fix #21896 asign parameter to global variable generates invalid code (#21900)

This commit is contained in:
Bung
2023-05-24 21:30:14 +08:00
committed by GitHub
parent 761b927e47
commit 266cc69f19
2 changed files with 10 additions and 1 deletions

View File

@@ -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

9
tests/global/t21896.nim Normal file
View File

@@ -0,0 +1,9 @@
discard """
errormsg: "cannot assign local to global variable"
line: 7
"""
proc example(a:int) =
let b {.global.} = a
example(1)