From 062aefd6aa7cda6a30ae557f4813a2a967b49596 Mon Sep 17 00:00:00 2001 From: CircleShift Date: Fri, 5 Dec 2025 01:58:03 -0500 Subject: [tnslc] Fix struct resolution --- tnslc/compile/module.tnsl | 2 +- tnslc/compile/struct.tnsl | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/tnslc/compile/module.tnsl b/tnslc/compile/module.tnsl index d2f1525..99d42f1 100644 --- a/tnslc/compile/module.tnsl +++ b/tnslc/compile/module.tnsl @@ -188,7 +188,7 @@ struct Module { _printf(str`) _printf("' in module '\0") _printf(self.name) - _printf("'\n\0") + _print_num("' at level %d\n\0", lvl) /; loop (int i = 0; i < self.subs.count) [i++] diff --git a/tnslc/compile/struct.tnsl b/tnslc/compile/struct.tnsl index 45f85d3..780e8ad 100644 --- a/tnslc/compile/struct.tnsl +++ b/tnslc/compile/struct.tnsl @@ -149,13 +149,13 @@ struct Struct { return ;/ - /; if (ft`.size == 0) - # Recurse - ft`._compute_size(parent) - ;/ - /; if (ft`.size < 0) # Cyclical dependency + _printf("ERROR: Cyclic struct definition: '\0") + _printf(ft`.name) + _printf("' imported from '\0") + _printf(self.name) + _printf("'\n\0") return ;/ @@ -198,10 +198,13 @@ struct Struct { # Find struct and compute its size ~Struct out = parent`.find(SEARCH_STRUCT, ~sv) - sv.pop() - ~Module outp = parent - /; if (sv.count !== 0) - outp = parent`.find(SEARCH_SUB, ~sv) + /; if (out !== NULL && out`.size == 0) + sv.pop() + ~Module outp = parent + /; if (sv.count !== 0) + outp = parent`.find(SEARCH_SUB, ~sv) + ;/ + out`._compute_size(outp) ;/ sv.end() return out -- cgit v1.2.3