Closed brownstein closed 7 months ago
Slight correction - we need to check if type === Interpreter.Completion.RETURN
for the early return here.
Very nice bug. Thank you. It has been fixed exactly as you described.
That said, I have this gut feeling that there may be a larger issue going on here -- but I haven't been able to find any further bugs. For example, I've tried breaking to a label outside the task, but Acorn catches that. Maybe this bug is narrow after all.
Hey @cpcallen, you are good at breaking things...
When a task is added through
createTask_
, it effectively treats the rootProgram
node as the parent state. This is ordinarily not a bad thing, but there's a bug on https://github.com/NeilFraser/JS-Interpreter/blob/master/interpreter.js#L3289 thatbreak
s and falls back to the error handling code instead of returning, resulting in the value being thrown.This issue tracks the need to change the
break
on https://github.com/NeilFraser/JS-Interpreter/blob/master/interpreter.js#L3289 to areturn
to resolve this issue.To replicate, try interpreting: