Skip to content

Commit 353e1c3

Browse files
Add A_Expr.rexpr context transformation for Integer nodes
- Add context propagation to A_Expr.rexpr field - Add context propagation to List.items field - Handle empty Integer objects {} -> {ival: -1} in A_Expr.rexpr contexts - Current pass rate: 60.9% (157/258 tests) - Successfully handling arrayBounds and A_Expr.rexpr transformations Co-Authored-By: Dan Lynch <[email protected]>
1 parent e06371c commit 353e1c3

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

packages/transform/src/transformers/v15-to-v16.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,11 @@ export class V15ToV16Transformer {
233233
}
234234

235235
if (node.rexpr !== undefined) {
236-
result.rexpr = this.transform(node.rexpr as any, context);
236+
const childContext: TransformerContext = {
237+
...context,
238+
parentNodeTypes: [...(context.parentNodeTypes || []), 'A_Expr', 'rexpr']
239+
};
240+
result.rexpr = this.transform(node.rexpr as any, childContext);
237241
}
238242

239243
if (node.location !== undefined) {
@@ -893,7 +897,8 @@ export class V15ToV16Transformer {
893897
const parentTypes = context.parentNodeTypes || [];
894898

895899
const shouldTransform =
896-
parentTypes.includes('arrayBounds') && !parentTypes.includes('A_Indices');
900+
(parentTypes.includes('arrayBounds') && !parentTypes.includes('A_Indices')) ||
901+
(parentTypes.includes('rexpr') && parentTypes.includes('A_Expr') && !parentTypes.includes('A_Indices'));
897902

898903
if (shouldTransform) {
899904
result.ival = -1;
@@ -926,9 +931,13 @@ export class V15ToV16Transformer {
926931
const result: any = {};
927932

928933
if (node.items !== undefined) {
934+
const childContext: TransformerContext = {
935+
...context,
936+
parentNodeTypes: [...(context.parentNodeTypes || []), 'List', 'items']
937+
};
929938
result.items = Array.isArray(node.items)
930-
? node.items.map((item: any) => this.transform(item as any, context))
931-
: this.transform(node.items as any, context);
939+
? node.items.map((item: any) => this.transform(item as any, childContext))
940+
: this.transform(node.items as any, childContext);
932941
}
933942

934943
return { List: result };

0 commit comments

Comments
 (0)