summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/semstmts.nim3
-rw-r--r--tests/exception/texcas.nim1
2 files changed, 2 insertions, 2 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index 9752ccac1..25d4b3c74 100644
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -274,7 +274,7 @@ proc semTry(c: PContext, n: PNode): PNode =
     var a = n.sons[i]
     checkMinSonsLen(a, 1)
     var length = sonsLen(a)
-
+    openScope(c)
     if a.kind == nkExceptBranch:
       # so that ``except [a, b, c]`` is supported:
       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])
     if a.kind != nkFinally: typ = commonType(typ, a.sons[length-1].typ)
     else: dec last
+    closeScope(c)
 
   dec c.p.inTryStmt
   if isEmptyType(typ) or typ.kind == tyNil:
diff --git a/tests/exception/texcas.nim b/tests/exception/texcas.nim
index a00b09a8f..dfbed8f46 100644
--- a/tests/exception/texcas.nim
+++ b/tests/exception/texcas.nim
@@ -8,7 +8,6 @@ proc test[T]() =
     raise newException(T, "Hello")
   except T as foobar:
     echo(foobar.msg)
-  echo(declared(foobar))
   doAssert(not declared(foobar))
 
 template testTemplate() =