summaryrefslogtreecommitdiff
path: root/src/syntax/ast.rs
diff options
context:
space:
mode:
authorMarmare314 <49279081+Marmare314@users.noreply.github.com>2023-04-11 18:44:17 +0200
committerGitHub <noreply@github.com>2023-04-11 18:44:17 +0200
commit72d8785abeff66f6b832725e71fe65d9ded803ce (patch)
tree5e9177d56e3fb34ac0888f76754a4061dacec04f /src/syntax/ast.rs
parent9984e73ff396b7da71bb19416f5ed15296d50d98 (diff)
fix parenthesized binding (#707)
Diffstat (limited to 'src/syntax/ast.rs')
-rw-r--r--src/syntax/ast.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/syntax/ast.rs b/src/syntax/ast.rs
index 94114958..4119802e 100644
--- a/src/syntax/ast.rs
+++ b/src/syntax/ast.rs
@@ -1620,7 +1620,14 @@ pub enum DestructuringKind {
impl Pattern {
/// The kind of the pattern.
pub fn kind(&self) -> PatternKind {
- if self.0.children().len() <= 1 {
+ if self
+ .0
+ .children()
+ .map(SyntaxNode::kind)
+ .skip_while(|&kind| kind == SyntaxKind::LeftParen)
+ .take_while(|&kind| kind != SyntaxKind::RightParen)
+ .eq([SyntaxKind::Ident])
+ {
return PatternKind::Ident(self.0.cast_first_match().unwrap_or_default());
}