aboutsummaryrefslogtreecommitdiff
path: root/typecheck.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-12-22 16:37:09 -0500
committerBruce Hill <bruce@bruce-hill.com>2024-12-22 16:37:09 -0500
commitdf1b36cc278663f8376871b5f3d110c320315a36 (patch)
treec8c8dfd927174e3413d0ee6f2257c9618ea6110a /typecheck.c
parentdcab9eb748bc092347c0f46565c9ff2c8933b06d (diff)
Fix issue with cross promotion for tables with default values
Diffstat (limited to 'typecheck.c')
-rw-r--r--typecheck.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/typecheck.c b/typecheck.c
index 7f655606..2b5dd701 100644
--- a/typecheck.c
+++ b/typecheck.c
@@ -98,7 +98,8 @@ type_t *parse_type_ast(env_t *env, type_ast_t *ast)
code_err(ast, "Tables with optional-typed values are not currently supported");
return Type(TableType, .key_type=key_type, .value_type=val_type);
} else if (table_type->default_value) {
- type_t *t = Type(TableType, .key_type=key_type, .default_value=table_type->default_value);
+ type_t *t = Type(TableType, .key_type=key_type,
+ .value_type=get_type(env, table_type->default_value), .default_value=table_type->default_value);
if (has_stack_memory(t))
code_err(ast, "Tables can't have stack references because the array may outlive the stack frame.");
return t;