aboutsummaryrefslogtreecommitdiff
path: root/boot/type_check.cc
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2026-09-05 23:44:04 +0200
committerEugen Wissner <belka@caraus.de>2026-09-05 23:44:04 +0200
commit93d251251ff926718b81fd62fba88dfa66d469e9 (patch)
treeb4b06a137b1807bce4f98653ef6ec0c4a2aaa37a /boot/type_check.cc
parent6eaec8726f716b2ab6b48c8cd3d7fee6aaf86977 (diff)
downloadelna-93d251251ff926718b81fd62fba88dfa66d469e9.tar.gz
Generate repeat-until condition outside body scope
Diffstat (limited to 'boot/type_check.cc')
-rw-r--r--boot/type_check.cc8
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 });
}
}