Closed
Bug 1543225
Opened 6 years ago
Closed 5 years ago
[jsdbg2] Debugger doesn't distinguish implicit await when an async function returns (just calls onPop twice)
Categories
(Core :: JavaScript Engine, defect, P3)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
People
(Reporter: jimb, Unassigned)
References
Details
A Debugger.Frame's onPop handler gets called twice for the return of an async generator. The following program:
var g = newGlobal({ newCompartment: true });
g.eval(`async function* ag() { return 42; }`);
var dbg = new Debugger(g);
dbg.onEnterFrame = f => {
print(`onEnterFrame: ${f.callee.name}`);
f.onPop = function (k) {
print(`onPop: ${uneval(k)}`);
};
}
(async function () {
const a = [];
for await (let item of g.ag()) {
a.push(item);
}
return a;
})().then(v => {
print(`resolved to ${uneval(v)}`);
});
produces the following output:
onEnterFrame: ag
onPop: ({return:{}})
onEnterFrame: ag
onPop: ({return:42})
onEnterFrame: ag
onPop: ({return:42})
resolved to []
I would have expected to see 42
only once.
Reporter | ||
Updated•6 years ago
|
Type: task → defect
Comment 1•6 years ago
|
||
return
in async generators performs an implicit await
per spec, basically as if return await 42
had been written: https://tc39.github.io/ecma262/#sec-return-statement-runtime-semantics-evaluation
So I guess the additional onEnterFrame
/onPop
pair is actually the implicit await
.
Reporter | ||
Comment 2•6 years ago
|
||
Ah, okay, great. I was hoping it was something like that. I'm adding more detailed information to completion values in bug 1470558, so that should let consumers distinguish the implicit await from the final return.
Updated•6 years ago
|
Summary: [jsdbg2] Debugger reports returns twice for async generators → [jsdbg2] Debugger doesn't distinguish implicit await when an async function returns (just calls onPop twice)
Reporter | ||
Comment 4•5 years ago
|
||
Yes, I think we can close this.
Status: NEW → RESOLVED
Closed: 5 years ago
Flags: needinfo?(jimb)
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•