You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When parsing an input that defines a class with a static class property an unexpected token error is thrown.
Here is my stack-trace:
SyntaxError: Unexpected token (1:24)
at pp$4.raise (/.../node_modules/acorn/dist/acorn.js:3560:15)
at pp$9.unexpected (/.../node_modules/acorn/dist/acorn.js:768:10)
at pp$9.expect (/.../node_modules/acorn/dist/acorn.js:762:28)
at pp$5.parseMethod (/.../node_modules/acorn/dist/acorn.js:3315:10)
at pp$8.parseClassMethod (/.../node_modules/acorn/dist/acorn.js:1529:37)
at pp$8.parseClassElement (/.../node_modules/acorn/dist/acorn.js:1487:12)
at pp$8.parseClass (/.../node_modules/acorn/dist/acorn.js:1405:26)
at pp$8.parseStatement (/.../node_modules/acorn/dist/acorn.js:914:19)
at pp$8.parseTopLevel (/.../node_modules/acorn/dist/acorn.js:825:23)
at Parser.parse (/.../node_modules/acorn/dist/acorn.js:597:17) {
pos: 24,
loc: Position { line: 1, column: 24 },
raisedAt: 25
}
Node.js v18.16.0
I assume that the class property is mistakenly identified / parsed as a class method as there is an invocation of parseClassMethod in the middle of the stack-trace. This thought matches with the unexpected token error type as the expected token would be a ( for a class method in this case.
Repro steps
run npm init -y
run npm i acorn
create an index.js file:
constacorn=require("acorn");acorn.parse("class Example {static x = {};}",{ecmaVersion: 2020});
run the file node index.js
The text was updated successfully, but these errors were encountered:
Description
When parsing an input that defines a class with a static class property an unexpected token error is thrown.
Here is my stack-trace:
I assume that the class property is mistakenly identified / parsed as a class method as there is an invocation of
parseClassMethod
in the middle of the stack-trace. This thought matches with the unexpected token error type as the expected token would be a(
for a class method in this case.Repro steps
npm init -y
npm i acorn
index.js
file:node index.js
The text was updated successfully, but these errors were encountered: