diff --git a/acorn/src/tokenize.js b/acorn/src/tokenize.js index a8d8f7a75..fdd69b472 100644 --- a/acorn/src/tokenize.js +++ b/acorn/src/tokenize.js @@ -316,7 +316,7 @@ pp.readToken_question = function() { // '?' pp.readToken_numberSign = function() { // '#' const ecmaVersion = this.options.ecmaVersion - let code = "#" + let code = 35 // '#' if (ecmaVersion >= 13) { ++this.pos code = this.fullCharCodeAtPos() diff --git a/test/tests-class-features-2022.js b/test/tests-class-features-2022.js index a74e0d75b..41e41e8dc 100644 --- a/test/tests-class-features-2022.js +++ b/test/tests-class-features-2022.js @@ -1755,6 +1755,9 @@ test("class C { #𩸽 }", { "sourceType": "script" }, {ecmaVersion: 13}) +// old ecma version +testFail("class C { #aaa }", "Unexpected character '#' (1:10)", {ecmaVersion: 12}) + // Unexpected character testFail("class C { # aaa }", "Unexpected character ' ' (1:11)", {ecmaVersion: 13}) testFail("class C { #+aaa }", "Unexpected character '+' (1:11)", {ecmaVersion: 13})