@@ -1516,7 +1516,7 @@ fn applyIniDeinliningRulesRecursivelyNode(allocator: Allocator, node: *Node, pro
15161516 if (strEql (nodeProperty , property )) {
15171517 if (node .children .items .len > 0 ) {
15181518 const className : []const u8 = nodeValue ;
1519- var moduleName : []const u8 = "Base.rte" ;
1519+ var moduleNameOptional : ? []const u8 = null ;
15201520 var presetNameOptional : ? []const u8 = null ;
15211521
15221522 var isOriginalPreset : bool = false ;
@@ -1542,7 +1542,7 @@ fn applyIniDeinliningRulesRecursivelyNode(allocator: Allocator, node: *Node, pro
15421542 // This lets it respect when well written mods intentionally reference non-Base data entities.
15431543 if (presetNameOptional ) | presetName | {
15441544 if (indexOf (u8 , presetName , "/" )) | modulePrefixEnd | {
1545- moduleName = presetName [0.. modulePrefixEnd ];
1545+ moduleNameOptional = presetName [0.. modulePrefixEnd ];
15461546 presetNameOptional = presetName [modulePrefixEnd + 1 .. ];
15471547 }
15481548 }
@@ -1554,7 +1554,7 @@ fn applyIniDeinliningRulesRecursivelyNode(allocator: Allocator, node: *Node, pro
15541554 // If we're set to deinline, then we're making a new preset definition in this module.
15551555 // This means the constant reference should certainly point to this module.
15561556 if (deinliningFlag ) {
1557- moduleName = moduleSpace .moduleName ;
1557+ moduleNameOptional = moduleSpace .moduleName ;
15581558
15591559 const duplicateNode = Node {
15601560 .property = "AddEffect" ,
@@ -1571,13 +1571,16 @@ fn applyIniDeinliningRulesRecursivelyNode(allocator: Allocator, node: *Node, pro
15711571 if (presetNameOptional ) | presetName | {
15721572 // If this was copied from something, and it isn't an original preset,
15731573 // then check if it is pointing to something within this module.
1574- if (isCopyOf and ! isOriginalPreset ) {
1575- if (moduleSpace .entityDefinitions .get (className )) | presetNameSpace | {
1576- if (presetNameSpace .get (presetName ) != null ) {
1577- moduleName = moduleSpace .moduleName ;
1574+ const moduleName : []const u8 = moduleNameOptional orelse moduleNameDeterminingBlock : {
1575+ if (isCopyOf and ! isOriginalPreset ) {
1576+ if (moduleSpace .entityDefinitions .get (className )) | presetNameSpace | {
1577+ if (presetNameSpace .get (presetName ) != null ) {
1578+ break :moduleNameDeterminingBlock moduleSpace .moduleName ;
1579+ }
15781580 }
15791581 }
1580- }
1582+ break :moduleNameDeterminingBlock "Base.rte" ;
1583+ };
15811584
15821585 node .value = try allocPrint (allocator , "{s}/{s}/{s}" , .{ className , moduleName , presetName });
15831586 } else {
@@ -2622,6 +2625,10 @@ test "updated" {
26222625 try testDirectory ("updated" , false );
26232626}
26242627
2628+ test "constant_reference" {
2629+ try testDirectory ("constant_reference" , false );
2630+ }
2631+
26252632fn testDirectory (comptime directory_name : []const u8 , is_invalid_test : bool ) ! void {
26262633 var iterable_tests = try std .fs .cwd ().openDir ("tests/" ++ directory_name , .{ .iterate = true });
26272634 defer iterable_tests .close ();
0 commit comments