Bug 1055337 - Disable syntax parsing inside asm.js so that we get better asm.js warning messages (r=jorendorff)

--HG--
extra : rebase_source : 8885a8d6d6914dc4f6f6e960b6ce4746074c819f
This commit is contained in:
Luke Wagner 2014-08-29 15:57:25 -05:00
parent 182e711a53
commit 492e803939
2 changed files with 12 additions and 0 deletions

View File

@ -2421,6 +2421,9 @@ template <>
bool
Parser<FullParseHandler>::asmJS(Node list)
{
// Disable syntax parsing in anything nested inside the asm.js module.
handler.disableSyntaxParser();
// We should be encountering the "use asm" directive for the first time; if
// the directive is already, we must have failed asm.js validation and we're
// reparsing. In that case, don't try to validate again. A non-null

View File

@ -117,6 +117,15 @@ assertTypeFailInEval('function f(g = 2) { "use asm"; function g() {} return g }'
assertTypeFailInEval('function *f() { "use asm"; function g() {} return g }');
assertTypeFailInEval('f => { "use asm"; function g() {} return g }');
assertAsmTypeFail(USE_ASM + 'function f(i) {i=i|0; (i for (x in [1,2,3])) } return f');
assertAsmTypeFail(USE_ASM + 'function f(i) {i=i|0; [i for (x in [1,2,3])] } return f');
assertAsmTypeFail(USE_ASM + 'function f() { (x for (x in [1,2,3])) } return f');
assertAsmTypeFail(USE_ASM + 'function f() { [x for (x in [1,2,3])] } return f');
assertTypeFailInEval('function f() { "use asm"; function g(i) {i=i|0; (i for (x in [1,2,3])) } return g }');
assertTypeFailInEval('function f() { "use asm"; function g(i) {i=i|0; [i for (x in [1,2,3])] } return g }');
assertTypeFailInEval('function f() { "use asm"; function g() { (x for (x in [1,2,3])) } return g }');
assertTypeFailInEval('function f() { "use asm"; function g() { [x for (x in [1,2,3])] } return g }');
assertThrowsInstanceOf(function() { new Function(USE_ASM + 'var)') }, SyntaxError);
assertThrowsInstanceOf(function() { new Function(USE_ASM + 'return)') }, SyntaxError);
assertThrowsInstanceOf(function() { new Function(USE_ASM + 'var z=-2w') }, SyntaxError);