Skip to content

Commit 41ce686

Browse files
committed
pattern with type annotation
1 parent 14e7605 commit 41ce686

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

grammar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ module.exports = grammar({
864864
optional($.as_aliasing),
865865
)),
866866

867-
parenthesized_pattern: $ => seq('(', $._pattern, ')'),
867+
parenthesized_pattern: $ => seq('(', $._pattern, optional($.type_annotation), ')'),
868868

869869
range_pattern: $ => seq(
870870
$._literal_pattern,

test/corpus/functions.txt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ Type annotations
6666
===================================================
6767

6868
(x: int, ~y: float): int => 5
69+
({contents: (x: int)}, {contents: y}) => x == y
6970

7071
---
7172

@@ -76,7 +77,22 @@ Type annotations
7677
(parameter (value_identifier) (type_annotation (type_identifier)))
7778
(parameter (labeled_parameter (value_identifier) (type_annotation (type_identifier)))))
7879
return_type: (type_annotation (type_identifier))
79-
body: (number))))
80+
body: (number)))
81+
82+
(expression_statement
83+
(function parameters:
84+
(formal_parameters
85+
(parameter
86+
(record_pattern
87+
(value_identifier)
88+
(parenthesized_pattern (value_identifier) (type_annotation (type_identifier)))))
89+
(parameter
90+
(record_pattern
91+
(value_identifier)
92+
(value_identifier))))
93+
body: (binary_expression
94+
left: (value_identifier)
95+
right: (value_identifier)))))
8096

8197
===================================================
8298
Abstract type

0 commit comments

Comments
 (0)