Open Bug 1444103 Opened 7 years ago Updated 2 years ago

Debugger behavior when forcing return from a generator is weird

Categories

(Core :: JavaScript Engine, enhancement, P3)

enhancement

Tracking

()

People

(Reporter: jorendorff, Unassigned)

References

(Blocks 1 open bug)

Details

The behavior seems to be a consequence of the implementation rather than design: 1. onEnterFrame pauses on the first instruction of a generator, before the JSOP_GENERATOR instruction executes. This is already a little strange. 2. Likewise we can pause in prologue-like bytecode at the top of an async function. 3. The debugger can tell the VM to `{return:}` from onEnterFrame, before the initial JSOP_GENERATOR instruction, which causes the generator to return a non-generator-iterator value, or causes the async function to return a non-Promise. 4. But we can also step or break on instructions after the initial JSOP_GENERATOR, which we reach by calling generator.next(). Then a `{return: val}` resumption value has different behavior that is also strange: `val`'s referent is returned from .next(), and the generator is left in a state where it can't be resumed (you get "TypeError: already executing generator"). Of course we don't want it.next() to resume a frame that was not suspended at a yield point. (What would that even do? Would it push an unexpected extra value onto the operand stack? Bad idea.) I think we should solve 1-3 by refusing to stop on those instructions, somehow. I think we should solve 4 by making `{return: x}` behave like a return-statement when the top frame is a generator frame. It should close the generator. It would be easier to delete support for `{return:}` resumption values.
Priority: -- → P3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.