Skip to content

Commit b386f4d

Browse files
committed
fix: Closure parameters can have trailing commas
1 parent 261b202 commit b386f4d

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

grammar.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,6 +1311,7 @@ module.exports = grammar({
13111311
$._pattern,
13121312
$.parameter,
13131313
)),
1314+
optional(','),
13141315
'|',
13151316
),
13161317

test/corpus/expressions.txt

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,7 @@ h(|| -> i { j });
12581258
(identifier)))))))
12591259

12601260
================================================================================
1261-
Closures with typed parameteres
1261+
Closures with typed parameters
12621262
================================================================================
12631263

12641264
a.map(|b: usize| b.push(c));
@@ -1284,6 +1284,35 @@ a.map(|b: usize| b.push(c));
12841284
(arguments
12851285
(identifier))))))))
12861286

1287+
1288+
================================================================================
1289+
Closure parameters can have a trailing comma
1290+
================================================================================
1291+
1292+
a.map(|b: usize,| b.push(c));
1293+
1294+
--------------------------------------------------------------------------------
1295+
1296+
(source_file
1297+
(expression_statement
1298+
(call_expression
1299+
(field_expression
1300+
(identifier)
1301+
(field_identifier))
1302+
(arguments
1303+
(closure_expression
1304+
(closure_parameters
1305+
(parameter
1306+
(identifier)
1307+
(primitive_type)))
1308+
(call_expression
1309+
(field_expression
1310+
(identifier)
1311+
(field_identifier))
1312+
(arguments
1313+
(identifier))))))))
1314+
1315+
12871316
================================================================================
12881317
Generators
12891318
================================================================================

0 commit comments

Comments
 (0)