diff --git a/acorn.js b/acorn.js index eb1c7d4ab4..34dfc947a4 100644 --- a/acorn.js +++ b/acorn.js @@ -911,9 +911,8 @@ // Test whether a semicolon can be inserted at the current position. function canInsertSemicolon() { - return tokType === _eof || tokType === _braceR || - !options.strictSemicolons && - newline.test(input.slice(lastEnd, tokStart)); + return !options.strictSemicolons && + (tokType === _eof || tokType === _braceR || newline.test(input.slice(lastEnd, tokStart))); } // Consume a semicolon, or, failing that, see if we are allowed to diff --git a/index.html b/index.html index 5d63154009..216adce76a 100644 --- a/index.html +++ b/index.html @@ -626,9 +626,8 @@ type, and if yes, consumes it as a side effect.
return true; } }Test whether a semicolon can be inserted at the current position.
function canInsertSemicolon() {
- return tokType === _eof || tokType === _braceR ||
- !options.strictSemicolons &&
- newline.test(input.slice(lastEnd, tokStart));
+ return !options.strictSemicolons &&
+ (tokType === _eof || tokType === _braceR || newline.test(input.slice(lastEnd, tokStart)));
}Consume a semicolon, or, failing that, see if we are allowed to pretend that there is a semicolon at this position.
function semicolon() {
if (!eat(_semi) && !canInsertSemicolon()) unexpected();
@@ -1168,7 +1167,7 @@ for array literals). function parseIdent(liberal) {
var node = startNode();
- node.name = tokType === _name ? tokVal : (liberal && tokType.keyword) || unexpected();
+ node.name = tokType === _name ? tokVal : (liberal && !options.forbidReserved && tokType.keyword) || unexpected();
next();
return finishNode(node, "Identifier");
}