mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 22:32:46 +00:00
Bug 878501: Forbid variable declarations without var keyword in asm.js; r=luke
This commit is contained in:
parent
e09fdfc7e4
commit
a3d61db254
@ -3085,8 +3085,12 @@ CheckModuleExports(ModuleCompiler &m, ParseNode *fn, ParseNode **stmtIter)
|
||||
{
|
||||
ParseNode *returnNode = SkipEmptyStatements(*stmtIter);
|
||||
|
||||
if (!returnNode || !returnNode->isKind(PNK_RETURN))
|
||||
return m.fail(fn, "asm.js module must end with a return export statement");
|
||||
if (!returnNode || !returnNode->isKind(PNK_RETURN)) {
|
||||
if (returnNode && NextNode(returnNode) != NULL)
|
||||
return m.fail(returnNode, "invalid asm.js statement");
|
||||
else
|
||||
return m.fail(fn, "asm.js module must end with a return export statement");
|
||||
}
|
||||
|
||||
ParseNode *returnExpr = UnaryKid(returnNode);
|
||||
|
||||
|
@ -23,6 +23,7 @@ assertEq(asmLink(asmCompile(USE_ASM + 'function f(x,y){x=x|0;y=y|0; return (x+y)
|
||||
assertAsmTypeFail('a', USE_ASM + 'function a(){} return a');
|
||||
assertAsmTypeFail('a','b','c', USE_ASM + 'var c');
|
||||
assertAsmTypeFail('a','b','c', USE_ASM + 'var c=0');
|
||||
assertAsmTypeFail(USE_ASM + 'c=0;return {}');
|
||||
assertAsmTypeFail('x','x', USE_ASM + 'function a(){} return a');
|
||||
assertAsmTypeFail('x','y','x', USE_ASM + 'function a(){} return a');
|
||||
assertEq(asmLink(asmCompile('x', USE_ASM + 'function a(){} return a'))(), undefined);
|
||||
|
Loading…
Reference in New Issue
Block a user