Skip to content

Commit f1754c8

Browse files
committed
fix: allow VariantPatternWithEmptyParams()
1 parent 49c468a commit f1754c8

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

grammar.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ module.exports = grammar({
8282
[$.let_binding, $.ternary_expression],
8383
[$.variant_identifier, $.module_identifier],
8484
[$.variant, $.variant_pattern],
85+
[$.variant],
8586
[$.variant_declaration, $.function_type_parameter],
87+
[$.variant_arguments, $._variant_pattern_parameters],
8688
[$.polyvar, $.polyvar_pattern],
8789
[$._pattern],
8890
[$._record_element, $.jsx_expression],
@@ -868,7 +870,7 @@ module.exports = grammar({
868870

869871
_variant_pattern_parameters: $ => seq(
870872
'(',
871-
commaSep1t($._variant_pattern_parameter),
873+
commaSept($._variant_pattern_parameter),
872874
')',
873875
),
874876

@@ -1209,10 +1211,10 @@ module.exports = grammar({
12091211
')',
12101212
),
12111213

1212-
variant: $ => prec.right(seq(
1214+
variant: $ => seq(
12131215
choice($.variant_identifier, $.nested_variant_identifier),
12141216
optional(alias($.variant_arguments, $.arguments)),
1215-
)),
1217+
),
12161218

12171219
nested_variant_identifier: $ => seq(
12181220
$.module_primary_expression,

test/corpus/expressions.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ Switch of variants
423423
switch foo {
424424
| Some(x as qux: int, {y, z}) => x
425425
| Option.None => 42
426+
| Surprise() => 0
426427
}
427428

428429
---
@@ -447,6 +448,9 @@ switch foo {
447448
(nested_variant_identifier
448449
(module_identifier)
449450
(variant_identifier)))
451+
(expression_statement (number)))
452+
(switch_match
453+
(variant_pattern (variant_identifier) (formal_parameters))
450454
(expression_statement (number))))))
451455

452456
===========================================

0 commit comments

Comments
 (0)