mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 22:10:33 +00:00
* fix #3505 wrong var {.global.} initialization, asign variable to it
* fix #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 <rumpf_a@web.de>
(cherry picked from commit 1410243d3b)
This commit is contained in:
33
tests/global/t3505.nim
Normal file
33
tests/global/t3505.nim
Normal file
@@ -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()
|
||||
Reference in New Issue
Block a user