diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-02-26 23:02:09 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-02-26 23:02:09 -0500 |
| commit | 115c75692bab91f62ff07ab3567a29436ab04515 (patch) | |
| tree | c00e40db70cf7b76af68aa7a6a661008d33feeca /environment.c | |
| parent | 8f5a40b9445fa319f4855cba69e7a795de845307 (diff) | |
Better error checking
Diffstat (limited to 'environment.c')
| -rw-r--r-- | environment.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/environment.c b/environment.c index 9ce52bcd..6957f26d 100644 --- a/environment.c +++ b/environment.c @@ -12,14 +12,14 @@ typedef struct { binding_t binding; } ns_entry_t; -static type_t *namespace_type(table_t *ns) +static type_t *namespace_type(const char *name, table_t *ns) { arg_t *fields = NULL; for (int64_t i = Table_length(ns); i >= 1; i--) { struct {const char *name; binding_t binding; } *entry = Table_entry(ns, i); fields = new(arg_t, .next=fields, .name=entry->name, .type=entry->binding.type); } - return Type(StructType, .fields=fields); + return Type(StructType, .name=name, .fields=fields); } env_t *new_compilation_unit(void) @@ -63,7 +63,7 @@ env_t *new_compilation_unit(void) }; for (size_t i = 0; i < sizeof(global_types)/sizeof(global_types[0]); i++) { - Table_str_set(env->globals, global_types[i].name, namespace_type(&global_types[i].namespace)); + Table_str_set(env->globals, global_types[i].name, namespace_type(global_types[i].name, &global_types[i].namespace)); Table_str_set(env->types, global_types[i].name, global_types[i].type); } |
