Skip to content

Commit c2696db

Browse files
authored
fix(es/parser): Do not parse empty stmt after using decl (#9798)
1 parent 46cbc8a commit c2696db

File tree

54 files changed

+121
-904
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+121
-904
lines changed

.changeset/lucky-hotels-grow.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
swc_core: patch
3+
swc_ecma_parser: patch
4+
---
5+
6+
fix(es/parser): Do not parse empty stmt after using decl

crates/swc_ecma_parser/src/parser/stmt.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,8 @@ impl<'a, I: Tokens> Parser<I> {
839839
}
840840
}
841841

842+
eat!(self, ';');
843+
842844
Ok(Some(Box::new(UsingDecl {
843845
span: span!(self, start),
844846
is_await,

crates/swc_ecma_parser/tests/js/explicit-resource-management/valid-using-binding-basic/input.js.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"type": "UsingDeclaration",
1818
"span": {
1919
"start": 5,
20-
"end": 30
20+
"end": 31
2121
},
2222
"isAwait": false,
2323
"decls": [
@@ -61,13 +61,6 @@
6161
"definite": false
6262
}
6363
]
64-
},
65-
{
66-
"type": "EmptyStatement",
67-
"span": {
68-
"start": 30,
69-
"end": 31
70-
}
7164
}
7265
]
7366
}

crates/swc_ecma_parser/tests/js/explicit-resource-management/valid-using-binding-escaped/input.js.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"type": "UsingDeclaration",
1818
"span": {
1919
"start": 3,
20-
"end": 20
20+
"end": 21
2121
},
2222
"isAwait": false,
2323
"decls": [
@@ -51,13 +51,6 @@
5151
"definite": false
5252
}
5353
]
54-
},
55-
{
56-
"type": "EmptyStatement",
57-
"span": {
58-
"start": 20,
59-
"end": 21
60-
}
6154
}
6255
]
6356
}

crates/swc_ecma_parser/tests/js/explicit-resource-management/valid-using-binding-non-bmp/input.js.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"type": "UsingDeclaration",
1818
"span": {
1919
"start": 3,
20-
"end": 21
20+
"end": 22
2121
},
2222
"isAwait": false,
2323
"decls": [
@@ -61,13 +61,6 @@
6161
"definite": false
6262
}
6363
]
64-
},
65-
{
66-
"type": "EmptyStatement",
67-
"span": {
68-
"start": 21,
69-
"end": 22
70-
}
7164
}
7265
]
7366
}

crates/swc_ecma_parser/tests/js/explicit-resource-management/valid-using-binding-using/input.js.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"type": "UsingDeclaration",
1818
"span": {
1919
"start": 5,
20-
"end": 21
20+
"end": 22
2121
},
2222
"isAwait": false,
2323
"decls": [
@@ -52,13 +52,6 @@
5252
}
5353
]
5454
},
55-
{
56-
"type": "EmptyStatement",
57-
"span": {
58-
"start": 21,
59-
"end": 22
60-
}
61-
},
6255
{
6356
"type": "ForOfStatement",
6457
"span": {

0 commit comments

Comments
 (0)