Skip to content

Commit

Permalink
fix(es/parser): Do not parse empty stmt after using decl (#9798)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret authored Dec 15, 2024
1 parent 46cbc8a commit c2696db
Show file tree
Hide file tree
Showing 54 changed files with 121 additions and 904 deletions.
6 changes: 6 additions & 0 deletions .changeset/lucky-hotels-grow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
swc_core: patch
swc_ecma_parser: patch
---

fix(es/parser): Do not parse empty stmt after using decl
2 changes: 2 additions & 0 deletions crates/swc_ecma_parser/src/parser/stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,8 @@ impl<'a, I: Tokens> Parser<I> {
}
}

eat!(self, ';');

Ok(Some(Box::new(UsingDecl {
span: span!(self, start),
is_await,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"type": "UsingDeclaration",
"span": {
"start": 5,
"end": 30
"end": 31
},
"isAwait": false,
"decls": [
Expand Down Expand Up @@ -61,13 +61,6 @@
"definite": false
}
]
},
{
"type": "EmptyStatement",
"span": {
"start": 30,
"end": 31
}
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"type": "UsingDeclaration",
"span": {
"start": 3,
"end": 20
"end": 21
},
"isAwait": false,
"decls": [
Expand Down Expand Up @@ -51,13 +51,6 @@
"definite": false
}
]
},
{
"type": "EmptyStatement",
"span": {
"start": 20,
"end": 21
}
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"type": "UsingDeclaration",
"span": {
"start": 3,
"end": 21
"end": 22
},
"isAwait": false,
"decls": [
Expand Down Expand Up @@ -61,13 +61,6 @@
"definite": false
}
]
},
{
"type": "EmptyStatement",
"span": {
"start": 21,
"end": 22
}
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"type": "UsingDeclaration",
"span": {
"start": 5,
"end": 21
"end": 22
},
"isAwait": false,
"decls": [
Expand Down Expand Up @@ -52,13 +52,6 @@
}
]
},
{
"type": "EmptyStatement",
"span": {
"start": 21,
"end": 22
}
},
{
"type": "ForOfStatement",
"span": {
Expand Down
Loading

0 comments on commit c2696db

Please sign in to comment.