Open Bug 1607662 Opened 5 years ago Updated 1 year ago

[jsdbg2] Passing completion values through onPop handlers doesn't work in generators

Categories

(Core :: JavaScript Engine, defect, P3)

defect

Tracking

()

People

(Reporter: jimb, Unassigned)

References

(Blocks 1 open bug)

Details

A user of the Debugger API should be able to assume that if their onPop handler simply returns the completion value it was passed as its resumption value, that will have no effect on execution. This works on ordinary functions, but not generators:

var g = newGlobal({ newCompartment: true });
var dbg1 = new Debugger(g);
var dbg2 = new Debugger(g);

g.eval(`
  function* f() {
    debugger;
  }
`);

dbg1.onDebuggerStatement = dbg2.onDebuggerStatement = (frame) => {
  frame.onPop = (completion) => {
    return completion;
  };
};

print(uneval(g.f().next()));

This prints:

({value:{value:{value:(void 0), done:true}, done:true}, done:true})

Each Debugger's onPop handler re-wraps the iterator result object received from the prior handler, so we get a triply-nested result object.

Perhaps the onPop handler for a generator shouldn't get the iterator result object; rather, it should get the value of the result object.

I ran into this too and apparently forgot to file it, woops. I 100% agree that completion should only be the value and not the iterator result object.

Priority: -- → P3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.