* 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>
This commit is contained in:
parent
165d523edf
commit
1410243d3b
2 changed files with 54 additions and 1 deletions
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()
|
||||
Loading…
Add table
Add a link
Reference in a new issue