diff --git a/src/typechecker.cpp b/src/typechecker.cpp index 48163c9..61e349d 100644 --- a/src/typechecker.cpp +++ b/src/typechecker.cpp @@ -25,8 +25,11 @@ namespace { if (types::types_equal(checked, target)) { return TypecheckRes{ TypecheckResKind::Ok, target }; } - else if (potential_cast.has_value() && potential_cast->allow_implicit) { - return TypecheckRes{ TypecheckResKind::Castable, target }; + else if (potential_cast.has_value()) { + if (potential_cast->allow_implicit) + return TypecheckRes{ TypecheckResKind::Castable, target }; + + return std::string{ "Type " + checked->formatted() + " not implicitly castable to " + target->formatted() }; } return std::string{ "Types " + checked->formatted() + " and " + target->formatted() + " incompatible" };