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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: async({ foo33 = 1 })
is parsed without errors
#13392
Comments
Hey @nicolo-ribaudo As the issue #13399 was just taken. Maybe I could give a try on this one ? |
Another related issue: // should throw duplicate proto keys
async({ __proto__: x, __proto__: y }) Spoiler, expand when you need help!Babel tracks the pattern babel/packages/babel-parser/src/parser/expression.js Lines 1953 to 1955 in 0b29b5c
However, this error is not thrown as it should have, because when we don't see an arrow after babel/packages/babel-parser/src/parser/expression.js Lines 804 to 806 in 0b29b5c
we lost the access to
We can create the babel/packages/babel-parser/src/parser/expression.js Lines 785 to 791 in 0b29b5c
and pass down the
|
Hi 馃憢 guys I'm hacking around the parser and try to understand the flow for our bug case. Thanks a lot @JLHwung for your pointers, it helps a lot. I'll keep you informed. |
@tony-go hit us up on slack if you have any questions! |
Hey @JLHwung I tried It seems to work there, but in the parser test I add a case and I got: Expected non-recoverable error message: Redefinition of __proto__ property. (1:22). But instead parsing recovered from errors: [
{
"loc": {
"line": 1,
"column": 22
},
"pos": 22,
"code": "BABEL_PARSER_SYNTAX_ERROR",
"reasonCode": "DuplicateProto"
}
] Do you have an idea about why ? (I'll dig it anyway) |
It's because we already have the tracking logic for non-async arrow functions, and you are making the parser use the same existing logic also for async arrows. |
It should throw, which means you have fixed this issue. The error comes from the fact we are enabling You can try removing |
Thanks a lot guys 馃憦 I just pushed the new test case ^^ I probably understand that our update allows to catch this error, my misunderstanding was more on the fact in one case we use:
Maybe do you guys have an idea ? |
Usually use use |
Hi @nicolo-ribaudo 馃憢 Hope you're doing right ^^ I fully understand why we use a ref ( But at the end of the day if (shorthandAssign >= 0) {
this.unexpected(shorthandAssign); // will throw something
}
if (doubleProto >= 0) {
this.raise(doubleProto, Errors.DuplicateProto); // will return something
} I think that the REPL handle both of them similarly. But it seems ambiguous for me. But I probably miss something, let me know in case. Note: So sorry if my questions are a bit boring 馃檹 - I'm just tryin to better understand the code base. Thanks a lot for your time ^^ |
Your question is a really good one, actually 馃槈
For example, we could parse
In general, "2" is more similar to linting errors (valid syntax but which is disallowed by the spec via Early Errors), while "1" are actual syntax errors (tokens that aren't allowed in that position). |
Thanks a lot for this level of detail @nicolo-ribaudo ^^ |
Thank you for the PR! |
馃捇
How are you using Babel?
Programmatic API (
babel.transform
,babel.parse
)Input code
Configuration file name
No response
Configuration
Default parser config
Current and expected behavior
foo33 = 1
is parsed as anObjectProperty
whose value is anAssignmentPattern
. It should throw, since objects cannot have property initializers with=
.Environment
Babel 7.14.4
Possible solution
No response
Additional context
Reported at https://twitter.com/buzyescayadev/status/1398526884955058181
The text was updated successfully, but these errors were encountered: