fix(es/parser): Report errors for multiple array elements without comma (#2366)

This commit is contained in:
Pig Fang 2021-10-07 15:08:53 +08:00 committed by GitHub
parent e2a0edd49d
commit 521e6717ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 3 deletions

2
Cargo.lock generated
View File

@ -2683,7 +2683,7 @@ dependencies = [
[[package]]
name = "swc_ecma_parser"
version = "0.73.1"
version = "0.73.2"
dependencies = [
"either",
"enum_kind",

View File

@ -7,7 +7,7 @@ include = ["Cargo.toml", "src/**/*.rs", "examples/**/*.rs"]
license = "Apache-2.0/MIT"
name = "swc_ecma_parser"
repository = "https://github.com/swc-project/swc.git"
version = "0.73.1"
version = "0.73.2"
[package.metadata.docs.rs]
all-features = true

View File

@ -451,7 +451,7 @@ impl<'a, I: Tokens> Parser<I> {
.parse_expr_or_spread()
.map(Some)?,
);
if is!(self, ',') {
if !is!(self, ']') {
expect!(self, ',');
}
}

View File

@ -0,0 +1 @@
const arr = [a b]

View File

@ -0,0 +1,6 @@
error: Expected ',', got 'b'
--> $DIR/tests/typescript-errors/array-expression/input.ts:1:16
|
1 | const arr = [a b]
| ^