diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-04-06 19:20:07 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-04-06 19:20:07 -0400 |
| commit | 1d2e55f53dfab5153dbfd0c03f28cd9daedb3b77 (patch) | |
| tree | aa1c21191800467abe0b3d16cb6c2a0c2e4587f9 /src/typecheck.c | |
| parent | bc93dea8186168aa015b05a615bc1873173393b5 (diff) | |
Allow uninitialized variables when there's a sensible empty value
(defaults to empty/zero value)
Diffstat (limited to 'src/typecheck.c')
| -rw-r--r-- | src/typecheck.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/typecheck.c b/src/typecheck.c index fed02ec6..a869f73e 100644 --- a/src/typecheck.c +++ b/src/typecheck.c @@ -303,10 +303,11 @@ void bind_statement(env_t *env, ast_t *statement) return; if (get_binding(env, name)) code_err(decl->var, "A ", type_to_str(get_binding(env, name)->type), " called ", quoted(name), " has already been defined"); - bind_statement(env, decl->value); + if (decl->value) + bind_statement(env, decl->value); type_t *type = decl->type ? parse_type_ast(env, decl->type) : get_type(env, decl->value); if (!type) - code_err(decl->value, "I couldn't figure out the type of this value"); + code_err(statement, "I couldn't figure out the type of this value"); if (type->tag == FunctionType) type = Type(ClosureType, type); CORD prefix = namespace_prefix(env, env->namespace); |
