Better error checking
This commit is contained in:
parent
8f5a40b944
commit
115c75692b
@ -846,6 +846,9 @@ CORD compile(env_t *env, ast_t *ast)
|
||||
auto test = Match(ast, DocTest);
|
||||
CORD src = heap_strn(test->expr->start, (size_t)(test->expr->end - test->expr->start));
|
||||
type_t *expr_t = get_type(env, test->expr);
|
||||
if (!expr_t)
|
||||
code_err(test->expr, "I couldn't figure out the type of this expression");
|
||||
|
||||
if (test->expr->tag == Declare) {
|
||||
auto decl = Match(test->expr, Declare);
|
||||
return CORD_asprintf(
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user