diff options
| author | Eugen Wissner <belka@caraus.de> | 2026-09-05 23:44:04 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2026-09-05 23:44:04 +0200 |
| commit | 93d251251ff926718b81fd62fba88dfa66d469e9 (patch) | |
| tree | b4b06a137b1807bce4f98653ef6ec0c4a2aaa37a /boot | |
| parent | 6eaec8726f716b2ab6b48c8cd3d7fee6aaf86977 (diff) | |
| download | elna-93d251251ff926718b81fd62fba88dfa66d469e9.tar.gz | |
Generate repeat-until condition outside body scope
Diffstat (limited to 'boot')
| -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 }); } } |
