* Fix compiler crash * make sure type is not lost
This commit is contained in:
parent
fcd4cd82c3
commit
12b11fd848
2 changed files with 10 additions and 2 deletions
|
|
@ -716,7 +716,7 @@ proc transformExceptBranch(c: PTransf, n: PNode): PTransNode =
|
||||||
result = transformSons(c, n)
|
result = transformSons(c, n)
|
||||||
if n[0].isInfixAs():
|
if n[0].isInfixAs():
|
||||||
let excTypeNode = n[0][1]
|
let excTypeNode = n[0][1]
|
||||||
let actions = newTransNode(nkStmtList, n[1].info, 2)
|
let actions = newTransNode(nkStmtListExpr, n[1], 2)
|
||||||
# Generating `let exc = (excType)(getCurrentException())`
|
# Generating `let exc = (excType)(getCurrentException())`
|
||||||
# -> getCurrentException()
|
# -> getCurrentException()
|
||||||
let excCall = PTransNode(callCodegenProc("getCurrentException", ast.emptyNode))
|
let excCall = PTransNode(callCodegenProc("getCurrentException", ast.emptyNode))
|
||||||
|
|
|
||||||
|
|
@ -21,5 +21,13 @@ proc test2() =
|
||||||
testTemplate(Exception)
|
testTemplate(Exception)
|
||||||
doAssert(not declared(foobar))
|
doAssert(not declared(foobar))
|
||||||
|
|
||||||
|
|
||||||
|
proc testTryAsExpr(i: int) =
|
||||||
|
let x = try: i
|
||||||
|
except ValueError as ex:
|
||||||
|
echo(ex.msg)
|
||||||
|
-1
|
||||||
|
|
||||||
test[Exception]()
|
test[Exception]()
|
||||||
test2()
|
test2()
|
||||||
|
testTryAsExpr(5)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue