Fixes incorrect scoping in semstmts.semTry.
This commit is contained in:
parent
1c233ba27a
commit
4661ae22dd
2 changed files with 2 additions and 2 deletions
|
|
@ -274,7 +274,7 @@ proc semTry(c: PContext, n: PNode): PNode =
|
||||||
var a = n.sons[i]
|
var a = n.sons[i]
|
||||||
checkMinSonsLen(a, 1)
|
checkMinSonsLen(a, 1)
|
||||||
var length = sonsLen(a)
|
var length = sonsLen(a)
|
||||||
|
openScope(c)
|
||||||
if a.kind == nkExceptBranch:
|
if a.kind == nkExceptBranch:
|
||||||
# so that ``except [a, b, c]`` is supported:
|
# so that ``except [a, b, c]`` is supported:
|
||||||
if length == 2 and a.sons[0].kind == nkBracket:
|
if length == 2 and a.sons[0].kind == nkBracket:
|
||||||
|
|
@ -319,6 +319,7 @@ proc semTry(c: PContext, n: PNode): PNode =
|
||||||
a.sons[length-1] = semExprBranchScope(c, a.sons[length-1])
|
a.sons[length-1] = semExprBranchScope(c, a.sons[length-1])
|
||||||
if a.kind != nkFinally: typ = commonType(typ, a.sons[length-1].typ)
|
if a.kind != nkFinally: typ = commonType(typ, a.sons[length-1].typ)
|
||||||
else: dec last
|
else: dec last
|
||||||
|
closeScope(c)
|
||||||
|
|
||||||
dec c.p.inTryStmt
|
dec c.p.inTryStmt
|
||||||
if isEmptyType(typ) or typ.kind == tyNil:
|
if isEmptyType(typ) or typ.kind == tyNil:
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ proc test[T]() =
|
||||||
raise newException(T, "Hello")
|
raise newException(T, "Hello")
|
||||||
except T as foobar:
|
except T as foobar:
|
||||||
echo(foobar.msg)
|
echo(foobar.msg)
|
||||||
echo(declared(foobar))
|
|
||||||
doAssert(not declared(foobar))
|
doAssert(not declared(foobar))
|
||||||
|
|
||||||
template testTemplate() =
|
template testTemplate() =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue