summaryrefslogtreecommitdiff
path: root/src/parser/parser_expr.c
diff options
context:
space:
mode:
authorZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-29 22:45:43 +0000
committerZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-29 22:45:43 +0000
commitee090168fd7f678e40150b3699e335625b90d947 (patch)
treee2410fa1f65b95183dad6faebf4124ea04475d54 /src/parser/parser_expr.c
parent12932210150c6cbf1125b0c834b1425327b24911 (diff)
Fix for #150
Diffstat (limited to 'src/parser/parser_expr.c')
-rw-r--r--src/parser/parser_expr.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/parser/parser_expr.c b/src/parser/parser_expr.c
index 8f3579a..51d2baa 100644
--- a/src/parser/parser_expr.c
+++ b/src/parser/parser_expr.c
@@ -156,6 +156,14 @@ int is_type_copy(ParserContext *ctx, Type *t)
{
return 1;
}
+
+ // If the struct is NOT defined (opaque/C type) and does NOT implement Drop,
+ // treat it as Copy (C behavior).
+ if (!find_struct_def(ctx, t->name) && !check_impl(ctx, "Drop", t->name))
+ {
+ return 1;
+ }
+
return 0;
case TYPE_ARRAY:
@@ -164,6 +172,13 @@ int is_type_copy(ParserContext *ctx, Type *t)
// but if it's a value assignment, C doesn't support it anyway unless wrapped in struct.
return 0;
+ case TYPE_ALIAS:
+ if (t->alias.is_opaque_alias)
+ {
+ return 1;
+ }
+ return is_type_copy(ctx, t->inner);
+
default:
return 1;
}