@@ -100,6 +100,14 @@ function traditionalTernaries(
100100 ] ) ;
101101}
102102
103+ function getOperandSingleExpression ( {
104+ variant
105+ } : Expression ) : Expression | undefined {
106+ return variant . kind === NonterminalKind . TupleExpression
107+ ? variant . items . getSingleExpression ( )
108+ : undefined ;
109+ }
110+
103111export class ConditionalExpression implements SlangNode {
104112 readonly kind = NonterminalKind . ConditionalExpression ;
105113
@@ -133,20 +141,12 @@ export class ConditionalExpression implements SlangNode {
133141 // We can remove parentheses only because we are sure that the
134142 // `condition` must be a single `bool` value.
135143 const operandLoc = this . operand . loc ;
136-
137- const getOperandSingleExpression = ( ) : Expression | undefined => {
138- const operandVariant = this . operand . variant ;
139- return operandVariant . kind === NonterminalKind . TupleExpression
140- ? operandVariant . items . getSingleExpression ( )
141- : undefined ;
142- } ;
143-
144144 for (
145- let operandSingleExpression = getOperandSingleExpression ( ) ;
145+ let operandSingleExpression = getOperandSingleExpression ( this . operand ) ;
146146 operandSingleExpression &&
147147 operandSingleExpression . variant . kind !==
148148 NonterminalKind . ConditionalExpression ;
149- operandSingleExpression = getOperandSingleExpression ( )
149+ operandSingleExpression = getOperandSingleExpression ( this . operand )
150150 ) {
151151 this . operand = operandSingleExpression ;
152152 }
0 commit comments