Skip to content

Commit

Permalink
fix #21896 asign parameter to global variable generates invalid code (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
bung87 authored May 24, 2023
1 parent 761b927 commit 266cc69
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/semstmts.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions tests/global/t21896.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
discard """
errormsg: "cannot assign local to global variable"
line: 7
"""

proc example(a:int) =
let b {.global.} = a

example(1)

0 comments on commit 266cc69

Please sign in to comment.