@@ -531,6 +531,11 @@ fn translation_rules() -> Vec<Rule<SwiftContext>> {
531531 =>
532532 ( identifier #{ name} )
533533 ) ,
534+ rule!(
535+ ( patternExpr pattern: @p)
536+ =>
537+ expr { p }
538+ ) ,
534539 // A `let`/`var` value-binding pattern (`let x`) inside a case or `if case`
535540 // preserves the binding specifier around its inner pattern.
536541 rule!(
@@ -694,44 +699,11 @@ fn translation_rules() -> Vec<Rule<SwiftContext>> {
694699 tree!( ( call_expr callee: { callee} argument: { args} ) )
695700 }
696701 ) ,
697- // A call or enum-case pattern argument. Both use the shared `argument`
698- // shape, preserving the optional label as `name` and the child as `value`.
699- // The pattern-only shapes (`patternExpr`, `discardAssignmentExpr`) are
700- // matched first; they never occur as ordinary call arguments.
701- rule!(
702- ( labeledExpr
703- label: _? @@lbl
704- expression: ( functionCallExpr
705- calledExpression: @constructor
706- arguments: _* @elements) @@call)
707- =>
708- argument {
709- let value = tree_at!(
710- ctx,
711- call,
712- ( call_expr callee: { constructor} argument: { elements} )
713- ) ;
714- tree!( ( argument
715- name_node: ( identifier #{ lbl} ) ?
716- value: { value} ) )
717- }
718- ) ,
719- rule!(
720- ( labeledExpr label: _? @@lbl expression: ( patternExpr pattern: @p) )
721- =>
722- ( argument name_node: ( identifier #{ lbl} ) ? value: { p} )
723- ) ,
724- rule!(
725- ( labeledExpr label: _? @@lbl expression: ( discardAssignmentExpr) @@wildcard)
726- =>
727- ( argument name_node: ( identifier #{ lbl} ) ? value: ( identifier #{ wildcard} ) )
728- ) ,
702+ // A call or enum-case pattern argument.
729703 rule!(
730704 ( labeledExpr label: _? @@lbl expression: @val)
731705 =>
732- argument {
733- tree!( ( argument name_node: ( identifier #{ lbl} ) ? value: { val} ) )
734- }
706+ ( argument name_node: ( identifier #{ lbl} ) ? value: { val} )
735707 ) ,
736708 // Member access (`list.append`). The `declName` is itself a
737709 // `declReferenceExpr`; pull its `baseName` out as the member identifier.
0 commit comments