Open pablomarx opened 5 years ago
I've been able to resolve this by removing the call to pop handlers from NBCGenTry()
:
And adding it above this line in NBCGenTryPost()
:
I'm not sure if this a proper fix and would appreciate guidance.
Wrote new tests to compare NEWT/0 generated bytecode with NewtonOS built-in compiler. There are differences that may account for what you observed, fixing them one by one. However, the proposed change doesn't fix it.
The issue is here: https://github.com/gnue/NEWT0/blob/6234fed3cf9e17f87dbf2acf6fc54ea77334658e/src/newt_core/NewtBC.c#L2281
Try blocks should be passed ret to handle the pop at the appropriate place. Will submit a pull-request as soon as tests pass, including with a fix for #8.
It appears that the exception handler stack is not popped when a handler is invoked that returns a value. This would seem to be because the
kNBCPopHandlers
is generated after the branch to the handler, and thus is not invoked due to the return statement.This causes subsequent exceptions to not be handled properly.
The following NewtonScript code demonstrates the problem:
When ran under NEWT/0, the output is:
(Note: Attempt 2 is never logged)
Under WallyScript/NewtonScript 1.x: