diff --git a/README.md b/README.md index 1a8afd8e86..b685917d11 100644 --- a/README.md +++ b/README.md @@ -63,8 +63,8 @@ object referring to that same position. - **onTrailingComma**: Like `onInsertedSemicolon`, but for trailing commas. -- **forbidReserved**: If `true`, using a reserved word will generate - an error. Defaults to `false`. When given the value `"everywhere"`, +- **allowReserved**: If `false`, using a reserved word will generate + an error. Defaults to `true`. When given the value `"never"`, reserved words and keywords can also not be used as property names (as in Internet Explorer's old parser). diff --git a/acorn.js b/acorn.js index 8eb6feb988..24740de6b5 100644 --- a/acorn.js +++ b/acorn.js @@ -60,11 +60,11 @@ // `onTrailingComma` is similar to `onInsertedSemicolon`, but for // trailing commas. onTrailingComma: null, - // By default, reserved words are not enforced. Enable - // `forbidReserved` to enforce them. When this option has the - // value "everywhere", reserved words and keywords can also not be + // By default, reserved words are not enforced. Disable + // `allowReserved` to enforce them. When this option has the + // value "never", reserved words and keywords can also not be // used as property names. - forbidReserved: false, + allowReserved: true, // When enabled, a return at the top level is not considered an // error. allowReturnOutsideFunction: false, @@ -2700,10 +2700,10 @@ pp.parseIdent = function(liberal) { var node = this.startNode(); - if (liberal && this.options.forbidReserved == "everywhere") liberal = false; + if (liberal && this.options.allowReserved == "never") liberal = false; if (this.type === tt.name) { if (!liberal && - (this.options.forbidReserved && + (!this.options.allowReserved && (this.options.ecmaVersion === 3 ? isReservedWord3 : isReservedWord5)(this.value) || this.strict && isStrictReservedWord(this.value)) && this.input.slice(this.start, this.end).indexOf("\\") == -1) diff --git a/test/tests-harmony.js b/test/tests-harmony.js index 552b98dc3c..288b74a8ef 100644 --- a/test/tests-harmony.js +++ b/test/tests-harmony.js @@ -13871,7 +13871,7 @@ testFail("function hello() {'use strict'; ({ i: 10, s(eval) { } }); }", "Definin testFail("function a() { \"use strict\"; ({ b(t, t) { } }); }", "Argument name clash in strict mode (1:37)", {ecmaVersion: 6}); -testFail("var super", "The keyword 'super' is reserved (1:4)", {ecmaVersion: 6, forbidReserved: true}); +testFail("var super", "The keyword 'super' is reserved (1:4)", {ecmaVersion: 6, allowReserved: false}); testFail("var default", "Unexpected token (1:4)", {ecmaVersion: 6});