Skip to content

Commit 66fc95d

Browse files
authored
Merge pull request #226 from aspeddro/fix-lazy-pattern
Fix lazy pattern
2 parents df909f3 + b7f5ac1 commit 66fc95d

File tree

2 files changed

+37
-8
lines changed

2 files changed

+37
-8
lines changed

grammar.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ module.exports = grammar({
6969
],
7070
[$._jsx_attribute_value, $.pipe_expression],
7171
[$.function_type_parameters, $.function_type],
72-
[$._reserved_identifier, $.module_unpack]
72+
[$._reserved_identifier, $.module_unpack],
73+
[$.lazy_pattern, $.or_pattern]
7374
],
7475

7576
conflicts: $ => [
@@ -925,13 +926,7 @@ module.exports = grammar({
925926

926927
lazy_pattern: $ => seq(
927928
'lazy',
928-
choice(
929-
$.value_identifier,
930-
$._literal_pattern,
931-
$._destructuring_pattern,
932-
$.polyvar_type_pattern,
933-
$.parenthesized_pattern,
934-
)
929+
$._pattern
935930
),
936931

937932
_jsx_element: $ => choice($.jsx_element, $.jsx_self_closing_element),

test/corpus/expressions.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,6 +1108,40 @@ switch c {
11081108
(expression_statement
11091109
(number)))))))
11101110

1111+
================================================================================
1112+
Switch of lazy patterns
1113+
================================================================================
1114+
1115+
switch c {
1116+
| lazy(r) => r
1117+
| (lazy (), lazy 3) => false
1118+
}
1119+
1120+
--------------------------------------------------------------------------------
1121+
1122+
(source_file
1123+
(expression_statement
1124+
(switch_expression
1125+
(value_identifier)
1126+
(switch_match
1127+
(lazy_pattern
1128+
(parenthesized_pattern
1129+
(value_identifier)))
1130+
(sequence_expression
1131+
(expression_statement
1132+
(value_identifier))))
1133+
(switch_match
1134+
(tuple_pattern
1135+
(tuple_item_pattern
1136+
(lazy_pattern
1137+
(unit)))
1138+
(tuple_item_pattern
1139+
(lazy_pattern
1140+
(number))))
1141+
(sequence_expression
1142+
(expression_statement
1143+
(false)))))))
1144+
11111145
================================================================================
11121146
Math operators
11131147
================================================================================

0 commit comments

Comments
 (0)