diff options
-rw-r--r-- | src/interp/interp.cc | 3 | ||||
-rw-r--r-- | test/regress/interp-throw-before-try.txt | 19 |
2 files changed, 21 insertions, 1 deletions
diff --git a/src/interp/interp.cc b/src/interp/interp.cc index cb5623d8..fe333b42 100644 --- a/src/interp/interp.cc +++ b/src/interp/interp.cc @@ -2615,7 +2615,8 @@ RunResult Thread::DoThrow(Exception::Ptr exn) { auto iter = handlers.rbegin(); while (iter != handlers.rend()) { const HandlerDesc& handler = *iter; - if (pc >= handler.try_start_offset && pc < handler.try_end_offset) { + // pc points to the *next* instruction by the time we're in DoThrow. + if (pc > handler.try_start_offset && pc <= handler.try_end_offset) { // For a try-delegate, skip part of the traversal by directly going // up to an outer handler specified by the delegate depth. if (handler.kind == HandlerKind::Delegate) { diff --git a/test/regress/interp-throw-before-try.txt b/test/regress/interp-throw-before-try.txt new file mode 100644 index 00000000..69ea3001 --- /dev/null +++ b/test/regress/interp-throw-before-try.txt @@ -0,0 +1,19 @@ +;;; TOOL: run-interp-spec +;;; ARGS*: --enable-exceptions +(module + (tag $e0) + (func (export "throws") + (throw $e0) + (try $try + (do + ) + (catch $e0) + ) + ) +) + +(assert_exception (invoke "throws")) +(;; STDOUT ;;; +out/test/regress/interp-throw-before-try.txt:15: assert_exception passed +2/2 tests passed. +;;; STDOUT ;;) |