aboutsummaryrefslogtreecommitdiff
path: root/src/types.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-11-26 21:04:12 -0500
committerBruce Hill <bruce@bruce-hill.com>2025-11-26 21:04:12 -0500
commita21f9ddfd05c643049c22bb52ab3a60f41933492 (patch)
tree8a4e3967f9d8b7863c238a357eb47e978d3a8c41 /src/types.c
parent14c8cf34dd75fcf49cc56025efa93dd32e1958fd (diff)
Bugfix for accidental violation of immutable value guarantees due to
inner field members
Diffstat (limited to 'src/types.c')
-rw-r--r--src/types.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/types.c b/src/types.c
index edfee27d..4d15d493 100644
--- a/src/types.c
+++ b/src/types.c
@@ -249,6 +249,27 @@ PUREFUNC bool has_heap_memory(type_t *t) {
}
}
+PUREFUNC bool has_refcounts(type_t *t) {
+ switch (t->tag) {
+ case ListType: return true;
+ case TableType: return true;
+ case OptionalType: return has_refcounts(Match(t, OptionalType)->type);
+ case StructType: {
+ for (arg_t *field = Match(t, StructType)->fields; field; field = field->next) {
+ if (has_refcounts(field->type)) return true;
+ }
+ return false;
+ }
+ case EnumType: {
+ for (tag_t *tag = Match(t, EnumType)->tags; tag; tag = tag->next) {
+ if (tag->type && has_refcounts(tag->type)) return true;
+ }
+ return false;
+ }
+ default: return false;
+ }
+}
+
PUREFUNC bool has_stack_memory(type_t *t) {
if (!t) return false;
switch (t->tag) {