aboutsummaryrefslogtreecommitdiff
path: root/boot/type_check.cc
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2026-08-21 00:05:03 +0200
committerEugen Wissner <belka@caraus.de>2026-08-21 00:05:03 +0200
commit39269cc68a32f6e1a7524b00da36a1fe4cc7fb8b (patch)
tree9558cd6107d60e22127faeddbdeac5031ee2fdbe /boot/type_check.cc
parent4f77ad5d019618893c59a0f8d5bfa6b98e50a3be (diff)
downloadelna-39269cc68a32f6e1a7524b00da36a1fe4cc7fb8b.tar.gz
Implement Single and Double floats
Diffstat (limited to 'boot/type_check.cc')
-rw-r--r--boot/type_check.cc19
1 files changed, 5 insertions, 14 deletions
diff --git a/boot/type_check.cc b/boot/type_check.cc
index d830763..2d82579 100644
--- a/boot/type_check.cc
+++ b/boot/type_check.cc
@@ -833,7 +833,7 @@ namespace elna::boot
auto operation = expression->operation();
type const resolved = resolve_underlying_type(expression->operand().type_decoration);
- if (operation == unary_operator::plus)
+ if (operation == unary_operator::plus || operation == unary_operator::minus)
{
if (!is_numeric_type(resolved))
{
@@ -842,17 +842,6 @@ namespace elna::boot
type_mismatch_error::unary{ .operation = operation });
}
}
- else if (operation == unary_operator::minus)
- {
- auto signed_primitive = resolved.get<primitive_type>();
- if ((signed_primitive == nullptr || !signed_primitive->identifier.starts_with("Int"))
- && !is_primitive_type(resolved, "Float"))
- {
- add_error<type_mismatch_error>(expression->position(),
- expression->operand().type_decoration,
- type_mismatch_error::unary{ .operation = operation });
- }
- }
else if (operation == unary_operator::negation)
{
if (is_primitive_type(resolved, "Bool"))
@@ -933,10 +922,12 @@ namespace elna::boot
|| (is_numeric_type(lhs_resolved) && lhs_resolved == rhs_resolved);
break;
case division:
- case remainder:
case multiplication:
valid = is_numeric_type(lhs_resolved) && lhs_resolved == rhs_resolved;
break;
+ case remainder:
+ valid = is_integral_type(lhs_resolved) && lhs_resolved == rhs_resolved;
+ break;
case less:
case greater:
case less_equal:
@@ -1032,7 +1023,7 @@ namespace elna::boot
const type resolved = resolve_underlying_type(trait->type_decoration);
if (resolved.get<enumeration_type>() == nullptr
- && !is_primitive_type(resolved, "Float")
+ && !is_float_type(resolved)
&& !is_discrete_type(resolved))
{
add_error<trait_error>(trait->name.position(), trait->name.name(),