Skip to content

Commit

Permalink
Merge pull request rescript-lang#226 from aspeddro/fix-lazy-pattern
Browse files Browse the repository at this point in the history
Fix lazy pattern
  • Loading branch information
nkrkv authored Jun 9, 2023
2 parents df909f3 + b7f5ac1 commit 66fc95d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 8 deletions.
11 changes: 3 additions & 8 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ module.exports = grammar({
],
[$._jsx_attribute_value, $.pipe_expression],
[$.function_type_parameters, $.function_type],
[$._reserved_identifier, $.module_unpack]
[$._reserved_identifier, $.module_unpack],
[$.lazy_pattern, $.or_pattern]
],

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

lazy_pattern: $ => seq(
'lazy',
choice(
$.value_identifier,
$._literal_pattern,
$._destructuring_pattern,
$.polyvar_type_pattern,
$.parenthesized_pattern,
)
$._pattern
),

_jsx_element: $ => choice($.jsx_element, $.jsx_self_closing_element),
Expand Down
34 changes: 34 additions & 0 deletions test/corpus/expressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,40 @@ switch c {
(expression_statement
(number)))))))

================================================================================
Switch of lazy patterns
================================================================================

switch c {
| lazy(r) => r
| (lazy (), lazy 3) => false
}

--------------------------------------------------------------------------------

(source_file
(expression_statement
(switch_expression
(value_identifier)
(switch_match
(lazy_pattern
(parenthesized_pattern
(value_identifier)))
(sequence_expression
(expression_statement
(value_identifier))))
(switch_match
(tuple_pattern
(tuple_item_pattern
(lazy_pattern
(unit)))
(tuple_item_pattern
(lazy_pattern
(number))))
(sequence_expression
(expression_statement
(false)))))))

================================================================================
Math operators
================================================================================
Expand Down

0 comments on commit 66fc95d

Please sign in to comment.