From 56a1244380133ab400f98d2da15353e080ffb360 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Thu, 15 Oct 2026 14:46:38 +0200 Subject: Restrict index types to Int and Word --- boot/type_check.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'boot/type_check.cc') diff --git a/boot/type_check.cc b/boot/type_check.cc index 797282c..5a8170a 100644 --- a/boot/type_check.cc +++ b/boot/type_check.cc @@ -250,7 +250,7 @@ namespace elna::boot return "Condition must be a boolean expression, but got '" + this->actual.to_string() + "'"; case array_index: - return "Array index must be an integral type, but got '" + return "Array index must be of type 'Word' or 'Int', but got '" + this->actual.to_string() + "'"; case non_indexable: return "Indexing is not allowed on type '" @@ -1528,12 +1528,12 @@ namespace elna::boot { walking_visitor::visit(expression); - if (!is_integral_type(resolve_underlying_type(expression->start().type_decoration))) + if (!is_index_type(expression->start().type_decoration, this->target)) { add_error(expression->start().position(), expression->start().type_decoration, type_requirement_error::kind::array_index); } - if (!is_integral_type(resolve_underlying_type(expression->end().type_decoration))) + if (!is_index_type(expression->end().type_decoration, this->target)) { add_error(expression->end().position(), expression->end().type_decoration, type_requirement_error::kind::array_index); @@ -1551,7 +1551,7 @@ namespace elna::boot add_error(expression->position(), expression->base().type_decoration, type_requirement_error::kind::non_indexable); } - if (!is_integral_type(resolve_underlying_type(expression->index().type_decoration))) + if (!is_index_type(expression->index().type_decoration, this->target)) { add_error(expression->index().position(), expression->index().type_decoration, type_requirement_error::kind::array_index); -- cgit v1.2.3