aboutsummaryrefslogtreecommitdiff
path: root/boot
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2026-08-31 17:18:39 +0200
committerEugen Wissner <belka@caraus.de>2026-08-31 17:18:39 +0200
commit0f5e9f00b07606871a6289060fa904555d41ae7d (patch)
tree2699d0c10e5e1756bec8f6093796c7379ff95822 /boot
parentd905e48d6af0445c7941cd2e638461db2f4d9ee8 (diff)
downloadelna-0f5e9f00b07606871a6289060fa904555d41ae7d.tar.gz
Reject comparison of uncompatible types
Diffstat (limited to 'boot')
-rw-r--r--boot/type_check.cc18
1 files changed, 8 insertions, 10 deletions
diff --git a/boot/type_check.cc b/boot/type_check.cc
index 5b0547b..068d958 100644
--- a/boot/type_check.cc
+++ b/boot/type_check.cc
@@ -127,6 +127,11 @@ namespace elna::boot
if constexpr (std::is_same_v<T, expected_type>)
{
+ if (this->actual.empty())
+ {
+ return "Expected type '" + payload.value.to_string()
+ + "', but the expression has no value";
+ }
return "Expected type '" + payload.value.to_string()
+ "', but got '" + this->actual.to_string() + "'";
}
@@ -381,14 +386,7 @@ namespace elna::boot
bool type_analysis_visitor::is_equality_compatible(const type& left, const type& right)
{
- auto resolved_left = resolve_underlying_type(left);
- auto resolved_right = resolve_underlying_type(right);
-
- return resolved_left == resolved_right
- || (is_primitive_type(resolved_left, "Pointer") && is_any_pointer_type(resolved_right))
- || (is_any_pointer_type(resolved_left) && is_primitive_type(resolved_right, "Pointer"))
- || (resolved_left.get<slice_type>() && resolved_right.get<slice_type>())
- || (resolved_left.get<record_type>() && resolved_right.get<record_type>());
+ return is_assignable_from(left, right) || is_assignable_from(right, left);
}
void type_analysis_visitor::visit_and_validate_condition(expression& condition)
@@ -465,7 +463,7 @@ namespace elna::boot
if (assignee_ptr == nullptr || assignment_ptr == nullptr)
{
- return verdict::reject;
+ return verdict::pass;
}
auto assignee_pointee_const = resolve_aliases(assignee_ptr->base).get<constant_type>();
auto assignment_pointee_const = resolve_aliases(assignment_ptr->base).get<constant_type>();
@@ -678,7 +676,7 @@ namespace elna::boot
found.value(), type_requirement_error::kind::zero_sized);
}
}
- if (declaration->initializer == nullptr || has_errors())
+ if (declaration->initializer == nullptr)
{
return;
}