mirror of
https://github.com/classilla/tenfourfox.git
synced 2025-08-07 12:30:47 +00:00
#521: make async functions throw for compatibility when enabled
This commit is contained in:
@@ -3598,6 +3598,20 @@ BytecodeEmitter::emitFunctionScript(ParseNode* body)
|
|||||||
switchToMain();
|
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))
|
if (!emitTree(body))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -3648,6 +3662,7 @@ BytecodeEmitter::emitFunctionScript(ParseNode* body)
|
|||||||
if (!emit1(JSOP_CHECKRETURN))
|
if (!emit1(JSOP_CHECKRETURN))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
asyncout:
|
||||||
|
|
||||||
// Always end the script with a JSOP_RETRVAL. Some other parts of the codebase
|
// Always end the script with a JSOP_RETRVAL. Some other parts of the codebase
|
||||||
// depend on this opcode, e.g. InterpreterRegs::setToEndOfScript.
|
// 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(5, async function(w) { await w+w; }, "ok"), true);
|
||||||
assertEq(okok(6, (async(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(7, ()=>{!async function(){ }}, "ok"), true);
|
||||||
|
assertEq(okok(8, async event => { }, "ok"), true);
|
||||||
|
|
||||||
function yoyo(k) { return new Promise(resolve => { resolve(k+1); }); }
|
function yoyo(k) { return new Promise(resolve => { resolve(k+1); }); }
|
||||||
async function dodo(k) { return await yoyo(k+1); }
|
async function dodo(k) { return await yoyo(k+1); }
|
||||||
// Just make sure this executes. It currently returns ({ }) in the shell.
|
// Just make sure this executes. Right now this throws.
|
||||||
dodo(5);
|
try { dodo(5); } catch(e) { }
|
||||||
|
|
||||||
if (typeof reportCompare === "function")
|
if (typeof reportCompare === "function")
|
||||||
reportCompare(true, true);
|
reportCompare(true, true);
|
||||||
|
Reference in New Issue
Block a user