definite assignment analysis for let (#21024)
* draft for let daa * patch * fixes bugs * errors for global let variable reassignments * checkpoint * out param accepts let * add more tests * add documentation * merge tests
This commit is contained in:
parent
6d8cf25bd7
commit
b2c7019006
9 changed files with 144 additions and 30 deletions
24
tests/init/tlet_uninit3.nim
Normal file
24
tests/init/tlet_uninit3.nim
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
discard """
|
||||
cmd: "nim check $file"
|
||||
action: "reject"
|
||||
nimout: '''
|
||||
tlet_uninit3.nim(13, 5) Error: 'let' symbol requires an initialization
|
||||
tlet_uninit3.nim(19, 5) Error: 'x' cannot be assigned to
|
||||
tlet_uninit3.nim(23, 11) Error: 'let' symbol requires an initialization
|
||||
'''
|
||||
"""
|
||||
|
||||
{.experimental: "strictDefs".}
|
||||
|
||||
let global {.used.}: int
|
||||
|
||||
proc foo() =
|
||||
block:
|
||||
let x: int
|
||||
x = 13
|
||||
x = 14
|
||||
|
||||
block:
|
||||
let x: int
|
||||
doAssert x == 0
|
||||
foo()
|
||||
Loading…
Add table
Add a link
Reference in a new issue