Skip to content

Commit 15958a5

Browse files
committed
ssr/matching: Ignore trailing semicolon in let stmt
1 parent ccc18ad commit 15958a5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

crates/ssr/src/matching.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,12 @@ impl<'db, 'sema> Matcher<'db, 'sema> {
283283
if p.kind() == SyntaxKind::COMMA && is_closing_token(code.kind()) {
284284
pattern.next();
285285
}
286+
} else if code.kind() == SyntaxKind::SEMICOLON {
287+
// If the pattern ends but the code still has a trailing semicolon, accept the match.
288+
// Allows to match `let x = y; ...` with `let $a = $b`.
289+
return Ok(());
286290
}
291+
287292
// Consume an element from the pattern and make sure it matches.
288293
match pattern.next() {
289294
Some(SyntaxElement::Token(p)) => {

0 commit comments

Comments
 (0)