Carpet

Carpet

2M Downloads

[Scarpet] Exception handling doesn't work without enough stack deepness

altrisi opened this issue ยท 4 comments

commented

I was testing exceptions again, and just found that running try(throw()) gets out of the stack.

Making the call indirect through a function call, like try(throw_it());throw_it()->(throw()) also doesn't work.

Due to recent findings I think with enough deepness it would work, cause it did in my previous testing.

If I recall correctly, that should get handled, shouldn't it? (since it's the definition of user defined)

commented

Actually, I think this is something I found when making the catchable exceptions (cause nothing is being caught):

I think throw needs to be a lazy-ish function (like a new ContextFunction). Not sure why, but if it wasn't then the try wouldn't always catch it. RN tested directly in the try and indirectly through a function call.

This was reverted in 74bd0bb

If I had to guess the reason, it's because the ThrowStatement isn't promoted into a ProcessedThrowStatement until it finds the stack limit (basically something where handleCodeException is called) and with a single Function (impure in this case) the stack isn't pushed, therefore not getting promoted in time for the catch block.

Edit: Tested, changing throw to a ContextFunction makes it work again.

commented

Capture
Nice catch - probably this try and catch are in a completely ridiculous place and they should capture the exception when its thrown.

commented

surrounding eval

commented

I will give it more thought since its a clutch place to make changes so need to be 100% sure about it.