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>
This commit is contained in:
ringabout 2022-12-12 23:14:44 +08:00 • committed by GitHub
commit 4388636010
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 1 deletions

View file

@ -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()