aboutsummaryrefslogtreecommitdiff
path: root/typecheck.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-05-12 15:18:46 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-05-12 15:18:46 -0400
commit4dbe046866a6280cf304c7e0ec6471d872bc8e27 (patch)
tree293b94a73769a8fd10cdc5135a3af8da82c4d334 /typecheck.c
parent8ada56c4248e9e09b8f151e9d516739dd86ad520 (diff)
Add interface fields
Diffstat (limited to 'typecheck.c')
-rw-r--r--typecheck.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/typecheck.c b/typecheck.c
index 5e3d005f..fa8e3003 100644
--- a/typecheck.c
+++ b/typecheck.c
@@ -284,6 +284,8 @@ void bind_statement(env_t *env, ast_t *statement)
if ((field_t->tag == InterfaceType && Match(field_t, InterfaceType)->opaque)
|| (field_t->tag == EnumType && Match(field_t, EnumType)->opaque))
code_err(field_ast->type, "This type is recursive and would create an infinitely sized interface. Try using a pointer.");
+ if (field_t->tag != FunctionType)
+ field_t = Type(PointerType, .pointed=field_t);
fields = new(arg_t, .name=field_ast->name, .type=field_t, .default_val=field_ast->value, .next=fields);
}
REVERSE_LIST(fields);