-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Erroneous errors for multiline statements that include BigInt literal suffix #25835
Comments
The problem is that |
@nodejs/repl should we close this as a known limitation (Node.js, through V8, can support newer syntax that acorn doesn't know about)? |
This problem looks really annoying, so +1 for fixing it (here or somewhere else). Have anybody reported it to |
I agree with @targos that this is a known limitation and we should not try to fix this on our side. I am going to close this issue for now. If someone disagrees, please leave a note or just reopen the issue. |
I am actually about to fix this. |
This adds bigint, class-fields, numeric-separators, static-class features, private class methods and fields as dependency. That way it's possible to use these in combination with acorn to parse these language features. This also removes a couple of files that were not necessary for Node.js to reduce the code base. PR-URL: nodejs#27400 Refs: nodejs#27391 Refs: nodejs#25835 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
This adds new language features to acorn. Otherwise BigInt and other input would not be parsed correct and would not result in nice error messages when using simple assert. PR-URL: nodejs#27400 Refs: nodejs#27391 Refs: nodejs#25835 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
This adds stage-3 language features to acorn so that it's possible to parse these features when using top level await in the REPL. PR-URL: nodejs#27400 Refs: nodejs#27391 Refs: nodejs#25835 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
This adds bigint, class-fields, numeric-separators, static-class features, private class methods and fields as dependency. That way it's possible to use these in combination with acorn to parse these language features. This also removes a couple of files that were not necessary for Node.js to reduce the code base. PR-URL: #27400 Refs: #27391 Refs: #25835 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
This adds new language features to acorn. Otherwise BigInt and other input would not be parsed correct and would not result in nice error messages when using simple assert. PR-URL: #27400 Refs: #27391 Refs: #25835 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
This adds stage-3 language features to acorn so that it's possible to parse these features when using top level await in the REPL. PR-URL: #27400 Refs: #27391 Refs: #25835 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
This adds stage-3 language features to acorn so that the REPL is able to parse these features properly. Otherwise these would cause SyntaxErrors. PR-URL: #27400 Fixes: #27391 Fixes: #25835 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
Possibly related to the issues discussed in #24231
When attempting to create a multiline statement that includes the BigInt literal suffix syntax (i.e. Number followed by
n
to denote a BigInt) causes an erroneousSyntaxError: Invalid or unexpected token
to be thrown. This behavior appears to occur only when the end of the statement is not on the same line as the BigInt. For example, the following seems to be erroneous behavior:Whereas if the statement ends on the same line, it seems to behave as expected:
The same behavior seems to extend to any multiline statements regardless of whether or not the BigNum is the last thing on the line:
With BigNum:
Without BigNum:
BigNum on same line as closing bracket:
Edit (Not sure if helpful):
BigInt suffix seems to be picked up as an identifier. Given the following input into REPL:
pp$4.raise()
at line 2753 ininternal/deps/acorn/dist/acorn.js
is receivingpos = 6, message = "Identifier directly after number (2:4)
That in turn seems to be coming from
pp$8.readRadixNumber()
at line 4981 ininternal/deps/acorn/dist/acorn.js
The issue seems to originate at
isIdentifierStart()
(internal/deps/acorn/dist/acorn.js:71), which does in fact pick upn
as the start of an identifier.isIdentifierStart()
is also called bypp$8.readNumber()
when using a normal, non-radix-prefixed number, producing the same result.isIdentifierStart()
is bypassed when the statement is terminated on the same line as the BigInt, which explains why this scenario does not trigger the error:The text was updated successfully, but these errors were encountered: