diff --git a/lib/libesp32/Berry/src/be_vm.c b/lib/libesp32/Berry/src/be_vm.c index 26c15a1a3..25fd2ff2e 100644 --- a/lib/libesp32/Berry/src/be_vm.c +++ b/lib/libesp32/Berry/src/be_vm.c @@ -1062,7 +1062,13 @@ newframe: /* a new call frame */ if (!IGET_RA(ins)) { be_except_block_setup(vm); if (be_setjmp(vm->errjmp->b)) { + bvalue *top = vm->top; + bvalue e1 = top[0]; + bvalue e2 = top[1]; be_except_block_resume(vm); + top = vm->top; + top[0] = e1; + top[1] = e2; goto newframe; } reg = vm->reg; diff --git a/lib/libesp32/Berry/tests/exceptions.be b/lib/libesp32/Berry/tests/exceptions.be new file mode 100644 index 000000000..dc2ad54e4 --- /dev/null +++ b/lib/libesp32/Berry/tests/exceptions.be @@ -0,0 +1,7 @@ + +try + for k: 0..1 assert({'a':1}.contains('b'), 'failure') end +except .. as e,m + assert(e == "assert_failed") + assert(m == "failure") +end