summary refs log tree commit diff stats
path: root/tests/init/tlet.nim
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2022-12-12 23:14:44 +0800
committerGitHub <noreply@github.com>2022-12-12 23:14:44 +0800
commit438863601047cc974d831c6c0dd5533e4e3f0dc5 (patch)
tree22af24f2291c24fd954809e3dc887e140ed3e0c2 /tests/init/tlet.nim
parent584cfa6af81303caeaffe4084472167ad47216fe (diff)
downloadNim-438863601047cc974d831c6c0dd5533e4e3f0dc5.tar.gz
fixes #21043; fixes a named exception in the infixAs expression which generate an implicit uninitialized let statement (#21081)
* fixes #21043; fixes a named exception in the infixAs expression which generate an implicit uninitialized let statement

* Update compiler/sempass2.nim

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Diffstat (limited to 'tests/init/tlet.nim')
-rw-r--r--tests/init/tlet.nim23
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/init/tlet.nim b/tests/init/tlet.nim
index de0da23a6..e32bedb18 100644
--- a/tests/init/tlet.nim
+++ b/tests/init/tlet.nim
@@ -3,6 +3,18 @@
 proc bar(x: out string) =
   x = "abc"
 
+template moe = # bug #21043
+  try:
+    discard
+  except ValueError as e:
+    echo(e.msg)
+
+template moe0 {.dirty.} = # bug #21043
+  try:
+    discard
+  except ValueError as e:
+    echo(e.msg)
+
 proc foo() =
   block:
     let x: string
@@ -25,10 +37,19 @@ proc foo() =
       discard "def"
     doAssert x == "abc"
   block: #
-    let x: int
+    let x {.used.} : int
   block: #
     let x: float
     x = 1.234
     doAssert x == 1.234
+
+  block:
+    try:
+      discard
+    except ValueError as e:
+      echo(e.msg)
+  moe()
+  moe0()
+
 static: foo()
 foo()