diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-04-11 16:50:26 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-04-11 16:50:26 +0200 |
| commit | 9720424884d67d61fd4ab7cbcefa2bfcc21d03e1 (patch) | |
| tree | 0dab729b193a071aaec9c6e0dc2e49547b2f57ec /src/syntax/parser.rs | |
| parent | 58e4bdb1b95a7c7f048f38e231328054e753b898 (diff) | |
Fix duplicate error message for destructuring
Diffstat (limited to 'src/syntax/parser.rs')
| -rw-r--r-- | src/syntax/parser.rs | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/syntax/parser.rs b/src/syntax/parser.rs index 83d9ae46..16d519fe 100644 --- a/src/syntax/parser.rs +++ b/src/syntax/parser.rs @@ -853,16 +853,9 @@ fn pattern(p: &mut Parser) -> PatternKind { PatternKind::Destructuring } else { - let success = p.expect(SyntaxKind::Ident); - if p.at(SyntaxKind::Comma) { - // TODO: this should only be a warning instead - p.expected("keyword `in`. did you mean to use a destructuring pattern?"); - } - - if success { + if p.expect(SyntaxKind::Ident) { p.wrap(m, SyntaxKind::Pattern); } - PatternKind::Normal } } @@ -964,7 +957,13 @@ fn for_loop(p: &mut Parser) { let m = p.marker(); p.assert(SyntaxKind::For); pattern(p); - p.expect(SyntaxKind::In); + if p.at(SyntaxKind::Comma) { + p.expected("keyword `in`. did you mean to use a destructuring pattern?"); + p.eat_if(SyntaxKind::Ident); + p.eat_if(SyntaxKind::In); + } else { + p.expect(SyntaxKind::In); + } code_expr(p); block(p); p.wrap(m, SyntaxKind::ForLoop); |
