mirror of
https://github.com/swc-project/swc.git
synced 2024-10-05 12:49:21 +03:00
fix(es/parser): Report an error if LeftHandSideExpression
is invalid (#4001)
This commit is contained in:
parent
9d6a57c6e5
commit
f8d6127dd1
@ -1901,6 +1901,10 @@ impl<'a, I: Tokens> Parser<I> {
|
||||
}
|
||||
|
||||
pub(super) fn check_assign_target(&mut self, expr: &Expr, deny_call: bool) {
|
||||
if !expr.is_valid_simple_assignment_target(self.ctx().strict) {
|
||||
self.emit_err(expr.span(), SyntaxError::TS2406);
|
||||
}
|
||||
|
||||
// We follow behavior of tsc
|
||||
if self.input.syntax().typescript() && self.syntax().early_errors() {
|
||||
let is_eval_or_arguments = match *expr {
|
||||
@ -1932,8 +1936,6 @@ impl<'a, I: Tokens> Parser<I> {
|
||||
{
|
||||
self.emit_err(expr.span(), SyntaxError::TS2406);
|
||||
}
|
||||
} else if !expr.is_valid_simple_assignment_target(self.ctx().strict) {
|
||||
self.emit_err(expr.span(), SyntaxError::TS2406);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
1++;
|
@ -0,0 +1,6 @@
|
||||
|
||||
x The left-hand side of an assignment expression must be a variable or a property access.
|
||||
,-[$DIR/tests/typescript-errors/issue-3885/input.ts:2:1]
|
||||
2 | 1++;
|
||||
: ^
|
||||
`----
|
Loading…
Reference in New Issue
Block a user