diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2022-12-06 17:19:12 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-06 10:19:12 +0100 |
commit | b2c70190061233f2aaaaacdfb36f8f5181c1f514 (patch) | |
tree | b77672304b9dc444b98954bff404a0cd9b9ccc08 /tests/init/tlet.nim | |
parent | 6d8cf25bd7d9d0836c7c894cffae2cdb4f6a2503 (diff) | |
download | Nim-b2c70190061233f2aaaaacdfb36f8f5181c1f514.tar.gz |
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
Diffstat (limited to 'tests/init/tlet.nim')
-rw-r--r-- | tests/init/tlet.nim | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/init/tlet.nim b/tests/init/tlet.nim new file mode 100644 index 000000000..de0da23a6 --- /dev/null +++ b/tests/init/tlet.nim @@ -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() |