From 79101ff3bdd4d6a3ca7b6d30d24998441ef873ce Mon Sep 17 00:00:00 2001 From: lisyarus Date: Sun, 29 Mar 2026 12:20:17 +0300 Subject: [PATCH] Fix computing struct layouts --- libs/ast/source/type_check.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libs/ast/source/type_check.cpp b/libs/ast/source/type_check.cpp index ed1e562..946933c 100644 --- a/libs/ast/source/type_check.cpp +++ b/libs/ast/source/type_check.cpp @@ -858,6 +858,12 @@ namespace pslang::ast void apply(statement_list & node) { populate_globals(lcontext, node); + + // TODO: compute layouts only in the current scope + // Otherwise we're needlessly iterating over all already visited structs + for (auto & struct_data : lcontext.structs) + compute_layout(lcontext, struct_data.first, struct_data.second); + for (auto & statement : node.statements) apply(*statement); } @@ -917,9 +923,6 @@ namespace pslang::ast local_context lcontext; check_visitor visitor{{}, {}, lcontext}; visitor.apply(*root); - - for (auto & struct_data : lcontext.structs) - compute_layout(lcontext, struct_data.first, struct_data.second); } }