forked from nim-lang/Nim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix nim-lang#3505 wrong var {.global.} initialization, asign variable…
… to it (nim-lang#20812) * fix nim-lang#3505 wrong var {.global.} initialization, asign variable to it * fix nim-lang#5132 as well * follow suggestions * handle all call kinds * Update tests/global/t3505.nim * Update compiler/semstmts.nim * Update compiler/semstmts.nim * Update compiler/semstmts.nim * follow suggestion * Update compiler/semstmts.nim Co-authored-by: Andreas Rumpf <[email protected]>
- Loading branch information
Showing
2 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
discard """ | ||
cmd: "nim check $options --hints:off $file" | ||
action: "reject" | ||
nimout: ''' | ||
t3505.nim(22, 22) Error: cannot assign local to global variable | ||
t3505.nim(31, 28) Error: cannot assign local to global variable | ||
''' | ||
""" | ||
|
||
|
||
|
||
|
||
|
||
|
||
proc foo = | ||
let a = 0 | ||
var b {.global.} = a | ||
foo() | ||
|
||
# issue #5132 | ||
proc initX(it: float): int = 8 | ||
proc initX2(it: int): int = it | ||
|
||
proc main() = | ||
var f: float | ||
var x {.global.} = initX2(initX(f)) | ||
|
||
main() |