@@ -46,6 +46,7 @@ module.exports = grammar({
4646 conflicts : $ => [
4747 [ $ . _simple_name , $ . generic_name ] ,
4848 [ $ . _simple_name , $ . type_parameter ] ,
49+ [ $ . _simple_name , $ . subpattern ] ,
4950
5051 [ $ . tuple_element , $ . type_pattern ] ,
5152 [ $ . tuple_element , $ . using_variable_declarator ] ,
@@ -1174,14 +1175,15 @@ module.exports = grammar({
11741175
11751176 type_pattern : $ => prec . right ( field ( 'type' , $ . type ) ) ,
11761177
1177- list_pattern : $ => seq (
1178+ list_pattern : $ => prec . right ( seq (
11781179 '[' ,
11791180 optional ( seq (
11801181 commaSep1 ( choice ( $ . pattern , '..' ) ) ,
11811182 optional ( ',' ) ,
11821183 ) ) ,
11831184 ']' ,
1184- ) ,
1185+ optional ( $ . _variable_designation ) ,
1186+ ) ) ,
11851187
11861188 recursive_pattern : $ => prec . left ( seq (
11871189 optional ( field ( 'type' , $ . type ) ) ,
@@ -1197,7 +1199,7 @@ module.exports = grammar({
11971199
11981200 positional_pattern_clause : $ => prec ( 1 , seq (
11991201 '(' ,
1200- optional ( commaSep2 ( $ . subpattern ) ) ,
1202+ optional ( commaSep ( $ . subpattern ) ) ,
12011203 ')' ,
12021204 ) ) ,
12031205
@@ -1208,10 +1210,15 @@ module.exports = grammar({
12081210 '}' ,
12091211 ) ) ,
12101212
1211- subpattern : $ => seq (
1212- optional ( seq ( $ . expression , ':' ) ) ,
1213+ subpattern : $ => prec . right ( seq (
1214+ optional (
1215+ choice (
1216+ seq ( $ . expression , ':' ) ,
1217+ seq ( $ . identifier , ':' ) ,
1218+ ) ,
1219+ ) ,
12131220 $ . pattern ,
1214- ) ,
1221+ ) ) ,
12151222
12161223 relational_pattern : $ => choice (
12171224 seq ( '<' , $ . expression ) ,
@@ -1720,6 +1727,7 @@ module.exports = grammar({
17201727 _with_body : $ => seq (
17211728 '{' ,
17221729 commaSep ( $ . with_initializer ) ,
1730+ optional ( ',' ) ,
17231731 '}' ,
17241732 ) ,
17251733
0 commit comments