Exception causes assignment on previous line to be ignored
danluu opened this issue · 2 comments
danluu commented
Here are two functions I'd expect to behave identically:
function wheee0()
i = 0
while true
try
if i == 0
print(".")
end
i += 1
peakflops(1954784290346684782)
catch
end
end
end
function wheee1()
i = 0
while true
try
i += 1
if i == 1
print(".")
end
peakflops(1954784290346684782)
catch
end
end
end
When I run wheee0()
, i
never increments and my screen gets filled with .
. When I run wheee1()
, I get a single .
, as expected.
Additionally, accessing i
inside the while loop, (either inside the catch block of after the entire try/catch expression) causes wheee0
to behave as expected. Accessing i
after the while loop has no effect.
I ran into this while trying to create a small, reproducible, test case for some strange behavior on a bad peakflops
call, but replacing peakflops
with something else that throws an exception (or just throwing an exception with throw) doesn't seem to change the behavior here.
JeffBezanson commented
ivarne commented
Backported in 0cdc92e