diff options
Diffstat (limited to 'boot/type_check.cc')
| -rw-r--r-- | boot/type_check.cc | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/boot/type_check.cc b/boot/type_check.cc index 4ceab18..fd47998 100644 --- a/boot/type_check.cc +++ b/boot/type_check.cc @@ -18,6 +18,7 @@ along with GCC; see the file COPYING3. If not see #include "elna/boot/type_check.h" #include "elna/boot/evaluator.h" +#include <ranges> #include <utility> namespace elna::boot @@ -1027,12 +1028,13 @@ namespace elna::boot type_mismatch_error::expected_type{ type(std::make_shared<array_type>(type(), 0)) }); return; } - for (auto *element : expression->elements) + // The first element of the array literal determines the array type and + // does not have to be checked. + for (auto *element : expression->elements | std::views::drop(1)) { if (!is_assignable_from(array->base, element->type_decoration)) { - add_error<type_mismatch_error>( - element->position(), element->type_decoration, + add_error<type_mismatch_error>(element->position(), element->type_decoration, type_mismatch_error::expected_type{ array->base }); } } |
