Skip to content

Commit 364af00

Browse files
Make Integer transformation more conservative
- Only transform empty Integer objects in very specific DefineStmt contexts - Remove broad transformation logic that was causing over-transformation - A_Const ival transformation now checks for DefineStmt context before transforming - Should resolve over-transformation from {} to {ival: -2} in CI Co-Authored-By: Dan Lynch <[email protected]>
1 parent cef27ca commit 364af00

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -544,8 +544,12 @@ export class V15ToV16Transformer {
544544
};
545545

546546
// Handle empty Integer objects directly since transform() can't detect their type
547+
// Only transform in very specific DefineStmt contexts, not all A_Const contexts
547548
if (typeof result.ival === 'object' && Object.keys(result.ival).length === 0) {
548-
result.ival = this.Integer(result.ival as any, childContext).Integer;
549+
const parentTypes = childContext.parentNodeTypes || [];
550+
if (parentTypes.includes('DefineStmt') && !(context as any).defElemName) {
551+
result.ival = this.Integer(result.ival as any, childContext).Integer;
552+
}
549553
} else {
550554
result.ival = this.transform(result.ival as any, childContext);
551555
}
@@ -889,7 +893,7 @@ export class V15ToV16Transformer {
889893
if (Object.keys(result).length === 0) {
890894
const parentTypes = context.parentNodeTypes || [];
891895

892-
// DefineStmt context: Only very specific cases from v14-to-v15
896+
// Only transform in very specific DefineStmt contexts that are well-documented
893897
if (parentTypes.includes('DefineStmt')) {
894898
const defElemName = (context as any).defElemName;
895899

@@ -899,11 +903,6 @@ export class V15ToV16Transformer {
899903
} else if (defElemName === 'sspace') {
900904
result.ival = 0; // v14-to-v15 line 468: ival === 0
901905
}
902-
// DefineStmt args context: ival -1 or 0 should become empty Integer for aggregates (v14-to-v15 line 473)
903-
// In reverse direction (v15-to-v16), empty Integer objects in DefineStmt args should transform to ival: -1
904-
else if (!defElemName) {
905-
result.ival = -1; // v14-to-v15 line 473: !defElemName && (ival === -1 || ival === 0), default to -1
906-
}
907906
}
908907
}
909908

0 commit comments

Comments
 (0)