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