Strict mode incorrectly reset after function

This commit is contained in:
r-e-d 2014-09-30 10:58:21 +02:00 committed by Marijn Haverbeke
parent 015a0e90bc
commit f3e759cd03
2 changed files with 6 additions and 3 deletions

View File

@ -302,7 +302,7 @@
function initParserState() { function initParserState() {
lastStart = lastEnd = tokPos; lastStart = lastEnd = tokPos;
if (options.locations) lastEndLoc = new Position; if (options.locations) lastEndLoc = new Position;
inFunction = inGenerator = strict = null; inFunction = inGenerator = strict = false;
labels = []; labels = [];
readToken(); readToken();
} }
@ -1752,7 +1752,7 @@
// function bodies). // function bodies).
function parseBlock(allowStrict) { function parseBlock(allowStrict) {
var node = startNode(), first = true, strict = false, oldStrict; var node = startNode(), first = true, oldStrict;
node.body = []; node.body = [];
expect(_braceL); expect(_braceL);
while (!eat(_braceR)) { while (!eat(_braceR)) {
@ -1764,7 +1764,7 @@
} }
first = false; first = false;
} }
if (strict && !oldStrict) setStrict(false); if (oldStrict === false) setStrict(false);
return finishNode(node, "BlockStatement"); return finishNode(node, "BlockStatement");
} }

View File

@ -27285,6 +27285,9 @@ testFail("(function a(eval) { \"use strict\"; })",
testFail("(function a(package) { \"use strict\"; })", testFail("(function a(package) { \"use strict\"; })",
"Defining 'package' in strict mode (1:12)"); "Defining 'package' in strict mode (1:12)");
testFail("\"use strict\";function foo(){\"use strict\";}function bar(){var v = 015}",
"Invalid number (1:65)");
testFail("var this = 10;", "Unexpected token (1:4)"); testFail("var this = 10;", "Unexpected token (1:4)");
testFail("throw\n10;", "Illegal newline after throw (1:5)"); testFail("throw\n10;", "Illegal newline after throw (1:5)");