From c245cfc1fd4143553bcce99669a85f093e4b88a7 Mon Sep 17 00:00:00 2001 From: andri lim Date: Mon, 17 Jul 2017 13:07:47 +0700 Subject: [PATCH] fixes #5986 js backend failed to compile try ... except new syntax (#6116) --- lib/system/jssys.nim | 2 +- tests/js/ttryexceptnewsyntax.nim | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 tests/js/ttryexceptnewsyntax.nim diff --git a/lib/system/jssys.nim b/lib/system/jssys.nim index 768f9bc170..cc69dc503a 100644 --- a/lib/system/jssys.nim +++ b/lib/system/jssys.nim @@ -53,7 +53,7 @@ proc isNimException(): bool {.asmNoStackFrame.} = else: asm "return `lastJSError`.m_type;" -proc getCurrentException*(): ref Exception = +proc getCurrentException*(): ref Exception {.compilerRtl, benign.} = if isNimException(): result = cast[ref Exception](lastJSError) proc getCurrentExceptionMsg*(): string = diff --git a/tests/js/ttryexceptnewsyntax.nim b/tests/js/ttryexceptnewsyntax.nim new file mode 100644 index 0000000000..2573c3727a --- /dev/null +++ b/tests/js/ttryexceptnewsyntax.nim @@ -0,0 +1,13 @@ +discard """ + output: '''hello''' +""" + +type + MyException = ref Exception + +#bug #5986 + +try: + raise MyException(msg: "hello") +except MyException as e: + echo e.msg