diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-03-10 13:40:58 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-03-10 13:40:58 -0400 |
| commit | 839abfc29425873f5610467b8facac44ad784e19 (patch) | |
| tree | 98641ce9b9f1395b1330ee3cdbb493e0ffefc734 /typecheck.c | |
| parent | 7f75a34bcea9688f4bb0d5947f01063ff02c837b (diff) | |
Be more conservative about disallowing constructors as top-level
initializers
Diffstat (limited to 'typecheck.c')
| -rw-r--r-- | typecheck.c | 21 |
1 files changed, 1 insertions, 20 deletions
diff --git a/typecheck.c b/typecheck.c index 9d3fab76..16863f08 100644 --- a/typecheck.c +++ b/typecheck.c @@ -1549,26 +1549,7 @@ PUREFUNC bool is_constant(env_t *env, ast_t *ast) } } case Use: return true; - case FunctionCall: { - // Constructors are allowed: - auto call = Match(ast, FunctionCall); - if (call->fn->tag != Var) return false; - binding_t *b = get_binding(env, Match(call->fn, Var)->name); - if (b == NULL || b->type->tag != TypeInfoType) return false; - - type_t *t = Match(b->type, TypeInfoType)->type; - if (t->tag == IntType) { - return call->args->value->tag == Int; - } else if (t->tag == NumType) { - return call->args->value->tag == Num; - } - - for (arg_ast_t *arg = call->args; arg; arg = arg->next) { - if (!is_constant(env, arg->value)) - return false; - } - return true; - } + case FunctionCall: return false; case InlineCCode: return true; default: return false; } |
