💻
How are you using Babel?
@babel/cli
Input code
Found this while reading https://github.com/evanw/esbuild/releases/tag/v0.12.25 (esbuild continues to have wonderful changelogs):
class Foo {
#a;
#b;
constructor(c) {
#a in #b in c
}
}
Because of the way the in operator works, this is parsing the same as (#a in #b) in c, which isn't a valid program.
Configuration file name
No response
Configuration
Only default settings are needed.
Current and expected behavior
This should throw a parse error.
Environment
Babel 7.15.3
Possible solution
This issue is in
|
const { value, start } = this.state; |
|
node = this.parsePrivateName(); |
|
if (this.match(tt._in)) { |
|
this.classScope.usePrivateName(value, start); |
|
} else { |
|
this.raise(start, Errors.PrivateInExpectedIn, value); |
|
} |
|
return node; |
. We're not checking whether we're already in the RHS of an
in expression.
Additional context
No response
💻
How are you using Babel?
@babel/cli
Input code
Found this while reading https://github.com/evanw/esbuild/releases/tag/v0.12.25 (esbuild continues to have wonderful changelogs):
Because of the way the
inoperator works, this is parsing the same as(#a in #b) in c, which isn't a valid program.Configuration file name
No response
Configuration
Only default settings are needed.
Current and expected behavior
This should throw a parse error.
Environment
Babel 7.15.3
Possible solution
This issue is in
babel/packages/babel-parser/src/parser/expression.js
Lines 1219 to 1226 in b335dcc
inexpression.Additional context
No response