fix(es/parser): Handle more TS2406 errors (#5640)

This commit is contained in:
magic-akari 2022-08-26 22:13:38 +08:00 committed by GitHub
parent 7a8a172479
commit 838438dc9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 199 additions and 21 deletions

View File

@ -1 +1,12 @@
1 >>= 2;
//!
//! x The left-hand side of an assignment expression must be a variable or a property access.
//! ,----
//! 1 | 1 >>= 2;
//! : ^
//! `----
//!
//!
//!Caused by:
//! 0: failed to process input file
//! 1: error was recoverable, but proceeding would result in wrong codegen
//! 2: Syntax Error

View File

@ -1 +1,12 @@
1 >>= 2;
//!
//! x The left-hand side of an assignment expression must be a variable or a property access.
//! ,----
//! 1 | 1 >>= 2;
//! : ^
//! `----
//!
//!
//!Caused by:
//! 0: failed to process input file
//! 1: error was recoverable, but proceeding would result in wrong codegen
//! 2: Syntax Error

View File

@ -1 +1,12 @@
1 >>= 2;
//!
//! x The left-hand side of an assignment expression must be a variable or a property access.
//! ,----
//! 1 | 1 >>= 2;
//! : ^
//! `----
//!
//!
//!Caused by:
//! 0: failed to process input file
//! 1: error was recoverable, but proceeding would result in wrong codegen
//! 2: Syntax Error

View File

@ -1 +1,12 @@
1 >>= 2;
//!
//! x The left-hand side of an assignment expression must be a variable or a property access.
//! ,----
//! 1 | 1 >>= 2;
//! : ^
//! `----
//!
//!
//!Caused by:
//! 0: failed to process input file
//! 1: error was recoverable, but proceeding would result in wrong codegen
//! 2: Syntax Error

View File

@ -1 +1,12 @@
1 >>= 2;
//!
//! x The left-hand side of an assignment expression must be a variable or a property access.
//! ,----
//! 1 | 1
//! : ^
//! `----
//!
//!
//!Caused by:
//! 0: failed to process input file
//! 1: error was recoverable, but proceeding would result in wrong codegen
//! 2: Syntax Error

View File

@ -1 +1,12 @@
1 >>= 2;
//!
//! x The left-hand side of an assignment expression must be a variable or a property access.
//! ,----
//! 1 | 1
//! : ^
//! `----
//!
//!
//!Caused by:
//! 0: failed to process input file
//! 1: error was recoverable, but proceeding would result in wrong codegen
//! 2: Syntax Error

View File

@ -1 +1,12 @@
1 >>= 2;
//!
//! x The left-hand side of an assignment expression must be a variable or a property access.
//! ,----
//! 1 | 1
//! : ^
//! `----
//!
//!
//!Caused by:
//! 0: failed to process input file
//! 1: error was recoverable, but proceeding would result in wrong codegen
//! 2: Syntax Error

View File

@ -1 +1,12 @@
1 >>= 2;
//!
//! x The left-hand side of an assignment expression must be a variable or a property access.
//! ,----
//! 1 | 1
//! : ^
//! `----
//!
//!
//!Caused by:
//! 0: failed to process input file
//! 1: error was recoverable, but proceeding would result in wrong codegen
//! 2: Syntax Error

View File

@ -1 +1,12 @@
1 >>>= 2;
//!
//! x The left-hand side of an assignment expression must be a variable or a property access.
//! ,----
//! 1 | 1 >>>= 2;
//! : ^
//! `----
//!
//!
//!Caused by:
//! 0: failed to process input file
//! 1: error was recoverable, but proceeding would result in wrong codegen
//! 2: Syntax Error

View File

@ -1 +1,12 @@
1 >>>= 2;
//!
//! x The left-hand side of an assignment expression must be a variable or a property access.
//! ,----
//! 1 | 1 >>>= 2;
//! : ^
//! `----
//!
//!
//!Caused by:
//! 0: failed to process input file
//! 1: error was recoverable, but proceeding would result in wrong codegen
//! 2: Syntax Error

View File

@ -1 +1,12 @@
1 >>>= 2;
//!
//! x The left-hand side of an assignment expression must be a variable or a property access.
//! ,----
//! 1 | 1 >>>= 2;
//! : ^
//! `----
//!
//!
//!Caused by:
//! 0: failed to process input file
//! 1: error was recoverable, but proceeding would result in wrong codegen
//! 2: Syntax Error

View File

@ -1 +1,12 @@
1 >>>= 2;
//!
//! x The left-hand side of an assignment expression must be a variable or a property access.
//! ,----
//! 1 | 1 >>>= 2;
//! : ^
//! `----
//!
//!
//!Caused by:
//! 0: failed to process input file
//! 1: error was recoverable, but proceeding would result in wrong codegen
//! 2: Syntax Error

View File

@ -1 +1,12 @@
1 >>>= 2;
//!
//! x The left-hand side of an assignment expression must be a variable or a property access.
//! ,----
//! 1 | 1
//! : ^
//! `----
//!
//!
//!Caused by:
//! 0: failed to process input file
//! 1: error was recoverable, but proceeding would result in wrong codegen
//! 2: Syntax Error

View File

@ -1 +1,12 @@
1 >>>= 2;
//!
//! x The left-hand side of an assignment expression must be a variable or a property access.
//! ,----
//! 1 | 1
//! : ^
//! `----
//!
//!
//!Caused by:
//! 0: failed to process input file
//! 1: error was recoverable, but proceeding would result in wrong codegen
//! 2: Syntax Error

View File

@ -1 +1,12 @@
1 >>>= 2;
//!
//! x The left-hand side of an assignment expression must be a variable or a property access.
//! ,----
//! 1 | 1
//! : ^
//! `----
//!
//!
//!Caused by:
//! 0: failed to process input file
//! 1: error was recoverable, but proceeding would result in wrong codegen
//! 2: Syntax Error

View File

@ -1 +1,12 @@
1 >>>= 2;
//!
//! x The left-hand side of an assignment expression must be a variable or a property access.
//! ,----
//! 1 | 1
//! : ^
//! `----
//!
//!
//!Caused by:
//! 0: failed to process input file
//! 1: error was recoverable, but proceeding would result in wrong codegen
//! 2: Syntax Error

View File

@ -158,12 +158,14 @@ impl<I: Tokens> Parser<I> {
.map(Box::new)
.map(PatOrExpr::Pat)?
} else {
//It is an early Reference Error if IsValidSimpleAssignmentTarget of
// It is an early Reference Error if IsValidSimpleAssignmentTarget of
// LeftHandSideExpression is false.
if !self.input.syntax().typescript()
&& !cond.is_valid_simple_assignment_target(self.ctx().strict)
{
self.emit_err(cond.span(), SyntaxError::NotSimpleAssign)
if !cond.is_valid_simple_assignment_target(self.ctx().strict) {
if self.input.syntax().typescript() {
self.emit_err(cond.span(), SyntaxError::TS2406);
} else {
self.emit_err(cond.span(), SyntaxError::NotSimpleAssign)
}
}
if self.input.syntax().typescript()
&& cond