Im not sure what exactly causes this, but it seems that some local variables that are optimized away does not end up in the exception frame.
Unless those locals are used ABOVE the try, like getting its address, they will have an invalid state (the one prior to entering Try) when re-entering the scope after a Throw.
minified sample:
Framework BRL.StandardIO
SuperStrict
Function Bail()
Throw "BAIL"
EndFunction
Function TryFail()
Local x:Int = 10
Try
x :* 2
Bail()
Catch e:Object
Print e.ToString() + " x == " + x + " should be 20"
EndTry
EndFunction
Function TryOk()
Local x:Int = 10
Local p:Byte Ptr = Varptr x ' taking the address solidifies the variable
Try
x :* 2
Bail()
Catch e:Object
Print e.ToString() + " x == " + x + " should be 20"
EndTry
EndFunction
TryFail()
TryOk()
output (win32):
BAIL x == 10 should be 20
BAIL x == 20 should be 20
expected output:
BAIL x == 20 should be 20
BAIL x == 20 should be 20
Im not sure what exactly causes this, but it seems that some local variables that are optimized away does not end up in the exception frame.
Unless those locals are used ABOVE the try, like getting its address, they will have an invalid state (the one prior to entering Try) when re-entering the scope after a Throw.
minified sample:
output (win32):
expected output: