Fix ignoring previous strict mode after twice "use strict"
For example:
var foo = function () {
"use strict";
"use strict";
// there is inside of strict mode,
// so `0123` (octal number) occurs a syntax error.
};
// there is outside of strict mode,
0123; // so left is valid syntax.
// however:
// SyntaxError: Invalid number (8:0)
I fixed it and add the test case.
This commit is contained in:
@@ -464,7 +464,7 @@ pp.parseBlockBody = function (node, allowDirectives, topLevel, end) {
|
||||
let directive = this.stmtToDirective(stmt);
|
||||
node.directives.push(directive);
|
||||
|
||||
if (directive.value.value === "use strict") {
|
||||
if (oldStrict === undefined && directive.value.value === "use strict") {
|
||||
oldStrict = this.state.strict;
|
||||
this.setStrict(true);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user