aboutsummaryrefslogtreecommitdiff
path: root/typecheck.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-02-24 15:24:44 -0500
committerBruce Hill <bruce@bruce-hill.com>2024-02-24 15:24:44 -0500
commit106704b9564b50e95dfce50b7a7471e73b64a78e (patch)
tree509e94ff49f76c9c2edc75c20fe1da9bfd600912 /typecheck.c
parentc7470346457550467bafd9199185c5d0e8481f02 (diff)
Improve enums with metamethods
Diffstat (limited to 'typecheck.c')
-rw-r--r--typecheck.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/typecheck.c b/typecheck.c
index eb1f2427..ce3c9d08 100644
--- a/typecheck.c
+++ b/typecheck.c
@@ -146,8 +146,10 @@ void bind_statement(env_t *env, ast_t *statement)
for (tag_t *tag = tags; tag; tag = tag->next) {
const char *name = heap_strf("%s__%s", def->name, tag->name);
type_t *constructor_t = Type(FunctionType, .args=Match(tag->type, StructType)->fields, .ret=type);
- set_binding(env, name, new(binding_t, .type=constructor_t));
+ Table_str_set(env->globals, name, new(binding_t, .type=constructor_t));
+ Table_str_set(env->types, heap_strf("%s$%s", def->name, tag->name), tag->type);
}
+ Table_str_set(env->types, def->name, type);
break;
}
default: break;