Bug 878501: Forbid variable declarations without var keyword in asm.js; r=luke

This commit is contained in:
Benjamin Bouvier 2013-06-13 11:54:25 -07:00
parent e09fdfc7e4
commit a3d61db254
2 changed files with 7 additions and 2 deletions

View File

@ -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);

View File

@ -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);