mirror of
https://github.com/swc-project/swc.git
synced 2024-12-01 09:52:57 +03:00
fix(es/parser): Report errors for array patterns without comma (#2365)
This commit is contained in:
parent
521e6717ad
commit
d65ce85030
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -2683,7 +2683,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "swc_ecma_parser"
|
||||
version = "0.73.2"
|
||||
version = "0.73.3"
|
||||
dependencies = [
|
||||
"either",
|
||||
"enum_kind",
|
||||
|
@ -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.2"
|
||||
version = "0.73.3"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
|
@ -96,9 +96,7 @@ impl<'a, I: Tokens> Parser<I> {
|
||||
continue;
|
||||
}
|
||||
if comma > 0 {
|
||||
// One comma is used for separating elements
|
||||
let cnt = if elems.is_empty() { comma } else { comma - 1 };
|
||||
elems.extend(iter::repeat(None).take(cnt));
|
||||
elems.extend(iter::repeat(None).take(comma));
|
||||
comma = 0;
|
||||
}
|
||||
let start = cur_pos!(self);
|
||||
@ -119,6 +117,10 @@ impl<'a, I: Tokens> Parser<I> {
|
||||
} else {
|
||||
elems.push(self.parse_binding_element().map(Some)?);
|
||||
}
|
||||
|
||||
if !is!(self, ']') {
|
||||
expect!(self, ',');
|
||||
}
|
||||
}
|
||||
|
||||
expect!(self, ']');
|
||||
|
@ -1,4 +1,4 @@
|
||||
error: Unexpected token `.`. Expected yield, an identifier, [ or {
|
||||
error: Expected ',', got '.'
|
||||
--> $DIR/tests/test262-parser/fail/235adc0d4af204c6.js:1:7
|
||||
|
|
||||
1 | var [a.b] = 0
|
||||
|
@ -1,4 +1,4 @@
|
||||
error: Unexpected token `.`. Expected yield, an identifier, [ or {
|
||||
error: Expected ',', got '.'
|
||||
--> $DIR/tests/test262-parser/fail/3f9ce9123e9ea7cb.js:1:14
|
||||
|
|
||||
1 | function a([a.b]) {}
|
||||
|
@ -1,4 +1,4 @@
|
||||
error: Unexpected token `.`. Expected yield, an identifier, [ or {
|
||||
error: Expected ',', got '.'
|
||||
--> $DIR/tests/test262-parser/fail/6bc739c23342216d.js:1:11
|
||||
|
|
||||
1 | ({set a([a.b]){}})
|
||||
|
@ -1,4 +1,4 @@
|
||||
error: Unexpected token `.`. Expected yield, an identifier, [ or {
|
||||
error: Expected ',', got '.'
|
||||
--> $DIR/tests/test262-parser/fail/7de586a1b43f8f7a.js:1:15
|
||||
|
|
||||
1 | function* a([a.b]) {}
|
||||
|
@ -1,4 +1,4 @@
|
||||
error: Unexpected token `.`. Expected yield, an identifier, [ or {
|
||||
error: Expected ',', got '.'
|
||||
--> $DIR/tests/test262-parser/fail/b508d676bbb2b2af.js:1:14
|
||||
|
|
||||
1 | (function ([a.b]) {})
|
||||
|
@ -1,4 +1,4 @@
|
||||
error: Unexpected token `.`. Expected yield, an identifier, [ or {
|
||||
error: Expected ',', got '.'
|
||||
--> $DIR/tests/test262-parser/fail/ca424e812e0896bd.js:1:15
|
||||
|
|
||||
1 | (function* ([a.b]) {})
|
||||
|
@ -1,4 +1,4 @@
|
||||
error: Unexpected token `.`. Expected yield, an identifier, [ or {
|
||||
error: Expected ',', got '.'
|
||||
--> $DIR/tests/test262-parser/fail/d5512eff7d8174e4.js:1:8
|
||||
|
|
||||
1 | ({*a([a.b]){}})
|
||||
|
@ -1,4 +1,4 @@
|
||||
error: Unexpected token `.`. Expected yield, an identifier, [ or {
|
||||
error: Expected ',', got '.'
|
||||
--> $DIR/tests/test262-parser/fail/dee9ac08aa5be125.js:1:7
|
||||
|
|
||||
1 | ({a([a.b]){}})
|
||||
|
@ -0,0 +1 @@
|
||||
const [a b] = arr
|
@ -0,0 +1,6 @@
|
||||
error: Expected ',', got 'b'
|
||||
--> $DIR/tests/typescript-errors/array-pattern/input.ts:1:10
|
||||
|
|
||||
1 | const [a b] = arr
|
||||
| ^
|
||||
|
Loading…
Reference in New Issue
Block a user