summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/jsgen.nim3
-rw-r--r--tests/exception/tunhandledexc.nim5
-rw-r--r--tests/testament/categories.nim1
3 files changed, 5 insertions, 4 deletions
diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim
index 80bcd2b0e..335ee2b92 100644
--- a/compiler/jsgen.nim
+++ b/compiler/jsgen.nim
@@ -560,6 +560,7 @@ proc genTry(p: PProc, n: PNode, r: var TCompRes) =
   #  ++excHandler;
   #  try {
   #    stmts;
+  #    --excHandler;
   #  } catch (EXC) {
   #    var prevJSError = lastJSError; lastJSError = EXC;
   #    --excHandler;
@@ -595,7 +596,7 @@ proc genTry(p: PProc, n: PNode, r: var TCompRes) =
   var generalCatchBranchExists = false
   let dollar = rope(if p.target == targetJS: "" else: "$")
   if p.target == targetJS and catchBranchesExist:
-    addf(p.body, "} catch (EXC) {$n var prevJSError = lastJSError;$n" &
+    addf(p.body, "--excHandler;$n} catch (EXC) {$n var prevJSError = lastJSError;$n" &
         " lastJSError = EXC;$n --excHandler;$n", [])
   elif p.target == targetPHP:
     addf(p.body, "} catch (Exception $$EXC) {$n $$prevJSError = $$lastJSError;$n $$lastJSError = $$EXC;$n", [])
diff --git a/tests/exception/tunhandledexc.nim b/tests/exception/tunhandledexc.nim
index 63a402414..c318aec81 100644
--- a/tests/exception/tunhandledexc.nim
+++ b/tests/exception/tunhandledexc.nim
@@ -14,10 +14,9 @@ proc genErrors(s: string) =
     raise newException(EsomeotherErr, "bla")
 
 when true:
+  try: discard except: discard
+
   try:
     genErrors("errssor!")
   except ESomething:
     echo("Error happened")
-
-
-
diff --git a/tests/testament/categories.nim b/tests/testament/categories.nim
index e534cc161..8d8d0bcec 100644
--- a/tests/testament/categories.nim
+++ b/tests/testament/categories.nim
@@ -220,6 +220,7 @@ proc jsTests(r: var TResults, cat: Category, options: string) =
   for testfile in ["exception/texceptions", "exception/texcpt1",
                    "exception/texcsub", "exception/tfinally",
                    "exception/tfinally2", "exception/tfinally3",
+                   "exception/tunhandledexc",
                    "actiontable/tactiontable", "method/tmultim1",
                    "method/tmultim3", "method/tmultim4",
                    "varres/tvarres0", "varres/tvarres3", "varres/tvarres4",