aboutsummaryrefslogtreecommitdiff
path: root/src/typecheck.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-09-13 12:01:52 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-09-13 12:01:52 -0400
commit981da7f0c6c47f66120482e7a7885cb5719d6959 (patch)
treec0d5bf912e7e477a0486120b8ac4aea8c49833f9 /src/typecheck.c
parent3a8841af6d15763e4c322c2c7671582ed6c3b006 (diff)
parentb4f2d03db2cd20688d6bb537904998e997bc48aa (diff)
Merge branch 'optional-list-indexing' into dev
Diffstat (limited to 'src/typecheck.c')
-rw-r--r--src/typecheck.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/typecheck.c b/src/typecheck.c
index 89a21fc3..e9968f09 100644
--- a/src/typecheck.c
+++ b/src/typecheck.c
@@ -933,14 +933,14 @@ type_t *get_type(env_t *env, ast_t *ast) {
if (!indexing->index) return indexed_t;
type_t *index_t = get_type(env, indexing->index);
if (index_t->tag == IntType || index_t->tag == BigIntType || index_t->tag == ByteType)
- return Match(value_t, ListType)->item_type;
+ return Type(OptionalType, Match(value_t, ListType)->item_type);
code_err(indexing->index, "I only know how to index lists using integers, not ", type_to_str(index_t));
} else if (value_t->tag == TableType) {
DeclareMatch(table_type, value_t, TableType);
if (table_type->default_value) return table_type->value_type;
return Type(OptionalType, table_type->value_type);
} else if (value_t->tag == TextType) {
- return value_t;
+ return Type(OptionalType, value_t);
} else {
code_err(ast, "I don't know how to index ", type_to_str(indexed_t), " values");
}