From 3ea319f7bfeed670b72024e1cbc1fba51184f7d0 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Tue, 31 Mar 2026 15:59:23 +0300 Subject: [PATCH] Fix evaluating array address in IR compiler --- libs/ir/source/compiler.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libs/ir/source/compiler.cpp b/libs/ir/source/compiler.cpp index c33eb20..e016e7e 100644 --- a/libs/ir/source/compiler.cpp +++ b/libs/ir/source/compiler.cpp @@ -536,9 +536,7 @@ namespace pslang::ir node_ref base_ptr; if (array_type) { - auto array = apply(*array_access->array); - mcontext.nodes->emplace_back(cast_operation{array, target_pointer_type}, target_pointer_type); - base_ptr = last(); + base_ptr = apply_get_address(array_access->array).value(); } else // if (pointer_type) { @@ -611,7 +609,7 @@ namespace pslang::ir // Evaluating variable initializer didn't produce any nodes // It must have been just a reference to another variable or smth like that // Introduce a copy node to prevent accidental variable coalescing - mcontext.nodes->emplace_back(copy{result}); + mcontext.nodes->emplace_back(copy{result}, node.inferred_type); result = last(); } lcontext.variables[&node] = result;