@@ -119,17 +119,20 @@ class PrintASTNode extends TPrintASTNode {
119119 abstract PrintASTNode getChildInternal ( int childIndex ) ;
120120
121121 /**
122- * Gets the child node at index `childIndex`.
122+ * Gets the child node at index `childIndex`.
123123 * Adds edges to fully converted expressions, that are not part of the
124124 * regular parent/child relation traversal.
125125 */
126126 PrintASTNode getChild ( int childIndex ) {
127127 result = getChildInternal ( childIndex )
128128 or
129- exists ( int nonConvertedIndex , int nextIdx , Expr expr |
130- nextIdx = max ( int idx | exists ( this .getChildInternal ( idx ) ) ) + 1 and
131- exists ( getChild ( nonConvertedIndex ) ) and
132- childIndex - nextIdx = nonConvertedIndex and
129+ // We first compute the first available child index that is not used by
130+ // `getChildInternal`, then we synthesize the child for fully converted
131+ // expressions at `nextAvailableIndex` plus the childIndex of the non-converted
132+ // expression. This ensures that both disjuncts are disjoint.
133+ exists ( int nonConvertedIndex , int nextAvailableIndex , Expr expr |
134+ nextAvailableIndex = max ( int idx | exists ( this .getChildInternal ( idx ) ) ) + 1 and
135+ childIndex - nextAvailableIndex = nonConvertedIndex and
133136 expr = getChild ( nonConvertedIndex ) .( ASTNode ) .getAST ( )
134137 |
135138 expr .getFullyConverted ( ) instanceof Conversion and
@@ -189,9 +192,9 @@ class PrintASTNode extends TPrintASTNode {
189192 or
190193 not exists ( getChildInternal ( childIndex ) ) and
191194 exists ( getChild ( childIndex ) ) and
192- exists ( int nonConvertedIndex , int nextIdx |
193- nextIdx = max ( int idx | exists ( this .getChildInternal ( idx ) ) ) + 1 and
194- childIndex - nextIdx = nonConvertedIndex
195+ exists ( int nonConvertedIndex , int nextAvailableIndex |
196+ nextAvailableIndex = max ( int idx | exists ( this .getChildInternal ( idx ) ) ) + 1 and
197+ childIndex - nextAvailableIndex = nonConvertedIndex
195198 |
196199 result = getChildEdgeLabelInternal ( nonConvertedIndex ) + " converted"
197200 )
0 commit comments