diff options
Diffstat (limited to 'boot')
| -rw-r--r-- | boot/type_check.cc | 18 |
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; } |
