diff --git a/corpus/expressions.txt b/corpus/expressions.txt index 4a8dce41a..8b46f27af 100644 --- a/corpus/expressions.txt +++ b/corpus/expressions.txt @@ -1067,6 +1067,7 @@ object O { if (c) d.e } { a => implicit b => b } { (a: Int) ?=> (b: Int) => b } + { (_, a) => a } } -------------------------------------------------------------------------------- @@ -1157,7 +1158,15 @@ object O { (binding (identifier) (type_identifier))) - (identifier))))))) + (identifier)))) + (block + (lambda_expression + (bindings + (binding + (wildcard)) + (binding + (identifier))) + (identifier)))))) ================================================================================ Unit expressions diff --git a/grammar.js b/grammar.js index 260074d00..2efd5428e 100644 --- a/grammar.js +++ b/grammar.js @@ -92,6 +92,8 @@ module.exports = grammar({ // 'for' operator_identifier ':' _annotated_type • ':' … [$._type, $.compound_type], [$.lambda_expression, $.modifiers], + // _postfix_expression_choice ':' '(' wildcard • ':' … + [$.binding, $._simple_type], ], word: $ => $._alpha_identifier, @@ -1159,11 +1161,14 @@ module.exports = grammar({ finally_clause: $ => prec.right(seq("finally", $._indentable_expression)), + /* + * Binding ::= (id | ‘_’) [‘:’ Type] + */ binding: $ => prec.dynamic( PREC.binding, seq( - field("name", $._identifier), + choice(field("name", $._identifier), $.wildcard), optional(seq(":", field("type", $._param_type))), ), ),