From d0a666507a6f11b65170c257fd483613f462f3f2 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Wed, 15 Jul 2026 23:19:58 +0200 Subject: Use build3(COND_EXPR) for conditionals --- boot/semantic.cc | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'boot') diff --git a/boot/semantic.cc b/boot/semantic.cc index 031adfc..9137053 100644 --- a/boot/semantic.cc +++ b/boot/semantic.cc @@ -206,6 +206,18 @@ namespace elna::boot } } + unsupported_trait_type_error::unsupported_trait_type_error(const identifier& trait, + type actual) + : error(trait.position()), trait_name(trait.name()), actual(actual) + { + } + + std::string unsupported_trait_type_error::what() const + { + return "Type '" + actual.to_string() + + "' does not support trait '#" + trait_name + "'"; + } + type_analysis_visitor::type_analysis_visitor(symbol_bag bag) : error_container(), bag(bag) { @@ -917,6 +929,25 @@ namespace elna::boot else if (trait->name == "min" || trait->name == "max") { trait->type_decoration = trait->types.empty() ? type() : trait->types.front(); + + if (!trait->type_decoration.empty()) + { + type resolved = inner_aliased_type(trait->type_decoration); + bool is_enum = resolved.get() != nullptr; + bool is_integral = false; + + if (auto prim = resolved.get()) + { + is_integral = prim->identifier == "Int" || prim->identifier == "Word" + || prim->identifier == "Bool" || prim->identifier == "Char"; + } + if (!is_enum && !is_integral) + { + add_error(trait->name, + trait->type_decoration); + trait->type_decoration = type(); + } + } } else { -- cgit v1.2.3