mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 20:11:17 +00:00
Update error message on casting between distinct types.
This commit is contained in:
@@ -685,6 +685,16 @@ static bool report_cast_error(CastContext *cc, bool may_cast_explicit)
|
||||
}
|
||||
if (may_cast_explicit)
|
||||
{
|
||||
if (expr->type->canonical->type_kind == TYPE_DISTINCT
|
||||
&& type_no_optional(to)->canonical->type_kind == TYPE_DISTINCT)
|
||||
{
|
||||
RETURN_CAST_ERROR(expr,
|
||||
"Implicitly casting %s to %s is not permitted. It's possible to do an explicit cast by placing '(%s)' before the expression. However, usually explicit casts between distinct types are not intended and are not safe.",
|
||||
type_quoted_error_string(type_no_optional(expr->type)),
|
||||
type_quoted_error_string(to),
|
||||
type_to_error_string(type_no_optional(to)));
|
||||
|
||||
}
|
||||
RETURN_CAST_ERROR(expr,
|
||||
"Implicitly casting %s to %s is not permitted, but you may do an explicit cast by placing '(%s)' before the expression.",
|
||||
type_quoted_error_string(type_no_optional(expr->type)),
|
||||
|
||||
Reference in New Issue
Block a user