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
34
tests/init/tlet.nim
Normal file
34
tests/init/tlet.nim
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
{.experimental: "strictDefs".}
|
||||
|
||||
proc bar(x: out string) =
|
||||
x = "abc"
|
||||
|
||||
proc foo() =
|
||||
block:
|
||||
let x: string
|
||||
if true:
|
||||
x = "abc"
|
||||
else:
|
||||
x = "def"
|
||||
doAssert x == "abc"
|
||||
block:
|
||||
let y: string
|
||||
bar(y)
|
||||
doAssert y == "abc"
|
||||
block:
|
||||
let x: string
|
||||
if true:
|
||||
x = "abc"
|
||||
discard "abc"
|
||||
else:
|
||||
x = "def"
|
||||
discard "def"
|
||||
doAssert x == "abc"
|
||||
block: #
|
||||
let x: int
|
||||
block: #
|
||||
let x: float
|
||||
x = 1.234
|
||||
doAssert x == 1.234
|
||||
static: foo()
|
||||
foo()
|
||||
Loading…
Add table
Add a link
Reference in a new issue