From 2055439be4f5053b9a4d631cefd8bb7c83a8e4e3 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 21 Aug 2024 00:48:08 -0400 Subject: Variables can no longer hold function pointers, only closure_t's. This makes error reporting easier and prevents issues where some functions could be assigned, but not others. Also change outputs so Void returns don't show up when displaying types, now just: `func()` --- typecheck.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'typecheck.c') diff --git a/typecheck.c b/typecheck.c index 43be2b97..410619a5 100644 --- a/typecheck.c +++ b/typecheck.c @@ -262,6 +262,8 @@ void bind_statement(env_t *env, ast_t *statement) bind_statement(env, decl->value); } type_t *type = get_type(env, decl->value); + if (type->tag == FunctionType) + type = Type(ClosureType, type); CORD prefix = namespace_prefix(env->libname, env->namespace); CORD code = CORD_cat(prefix ? prefix : "$", name); set_binding(env, name, new(binding_t, .type=type, .code=code)); -- cgit v1.2.3