mirror of
https://github.com/classilla/tenfourfox.git
synced 2025-04-19 03:37:08 +00:00
#521: make async functions throw for compatibility when enabled
This commit is contained in:
parent
2d25f717b9
commit
46b01b5d42
@ -3598,6 +3598,20 @@ BytecodeEmitter::emitFunctionScript(ParseNode* body)
|
||||
switchToMain();
|
||||
}
|
||||
|
||||
if (funbox->isAsync()) {
|
||||
// Currently short-circuit async functions with a throw.
|
||||
// TenFourFox issue 521.
|
||||
if (!emit1(JSOP_NULL))
|
||||
return false;
|
||||
if (!emit1(JSOP_THROW))
|
||||
return false;
|
||||
if (!emit1(JSOP_NULL))
|
||||
return false;
|
||||
if (!emit1(JSOP_RETURN))
|
||||
return false;
|
||||
goto asyncout;
|
||||
}
|
||||
|
||||
if (!emitTree(body))
|
||||
return false;
|
||||
|
||||
@ -3648,6 +3662,7 @@ BytecodeEmitter::emitFunctionScript(ParseNode* body)
|
||||
if (!emit1(JSOP_CHECKRETURN))
|
||||
return false;
|
||||
}
|
||||
asyncout:
|
||||
|
||||
// Always end the script with a JSOP_RETRVAL. Some other parts of the codebase
|
||||
// depend on this opcode, e.g. InterpreterRegs::setToEndOfScript.
|
||||
|
@ -27,11 +27,12 @@ function okok(x, y, z) { return (typeof y === "function"); }
|
||||
assertEq(okok(5, async function(w) { await w+w; }, "ok"), true);
|
||||
assertEq(okok(6, (async(w)=>{await w+w}), "ok"), true);
|
||||
assertEq(okok(7, ()=>{!async function(){ }}, "ok"), true);
|
||||
assertEq(okok(8, async event => { }, "ok"), true);
|
||||
|
||||
function yoyo(k) { return new Promise(resolve => { resolve(k+1); }); }
|
||||
async function dodo(k) { return await yoyo(k+1); }
|
||||
// Just make sure this executes. It currently returns ({ }) in the shell.
|
||||
dodo(5);
|
||||
// Just make sure this executes. Right now this throws.
|
||||
try { dodo(5); } catch(e) { }
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user