From bd190ac0a84eefa3174c04ce1fe2059aed6f2d1b Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 12 Oct 2025 13:29:55 -0400 Subject: Better error checking and reporting --- src/compile/lists.c | 1 + src/compile/tables.c | 2 ++ 2 files changed, 3 insertions(+) (limited to 'src/compile') diff --git a/src/compile/lists.c b/src/compile/lists.c index bb94eb1d..54ad6e7f 100644 --- a/src/compile/lists.c +++ b/src/compile/lists.c @@ -23,6 +23,7 @@ Text_t compile_typed_list(env_t *env, ast_t *ast, type_t *list_type) { if (!list->items) return Text("EMPTY_LIST"); type_t *item_type = Match(list_type, ListType)->item_type; + if (item_type == NULL) code_err(ast, "I couldn't figure out what item type goes into this list"); int64_t n = 0; for (ast_list_t *item = list->items; item; item = item->next) { diff --git a/src/compile/tables.c b/src/compile/tables.c index 958e5af5..54276c3b 100644 --- a/src/compile/tables.c +++ b/src/compile/tables.c @@ -25,7 +25,9 @@ Text_t compile_typed_table(env_t *env, ast_t *ast, type_t *table_type) { } type_t *key_t = Match(table_type, TableType)->key_type; + if (key_t == NULL) code_err(ast, "I couldn't figure out the key type for this table"); type_t *value_t = Match(table_type, TableType)->value_type; + if (value_t == NULL) code_err(ast, "I couldn't figure out the value type for this table"); if (value_t->tag == OptionalType) code_err(ast, "Tables whose values are optional (", type_to_text(value_t), ") are not currently supported."); -- cgit v1.2.3