mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-03 05:08:14 +00:00
Improve error message for check_is_expressible (Cannot convert X to Y from Z)
This commit is contained in:
+6
-3
@@ -2053,15 +2053,18 @@ bool check_is_expressible(CheckerContext *ctx, Operand *o, Type *type) {
|
|||||||
o->mode = Addressing_Invalid;
|
o->mode = Addressing_Invalid;
|
||||||
);
|
);
|
||||||
|
|
||||||
|
gbString s = exact_value_to_string(o->value);
|
||||||
|
defer (gb_string_free(s));
|
||||||
|
|
||||||
if (is_type_numeric(o->type) && is_type_numeric(type)) {
|
if (is_type_numeric(o->type) && is_type_numeric(type)) {
|
||||||
if (!is_type_integer(o->type) && is_type_integer(type)) {
|
if (!is_type_integer(o->type) && is_type_integer(type)) {
|
||||||
error(o->expr, "'%s' truncated to '%s'", a, b);
|
error(o->expr, "'%s' truncated to '%s', got %s", a, b, s);
|
||||||
} else {
|
} else {
|
||||||
error(o->expr, "Cannot convert numeric value '%s' to '%s' from '%s", a, b, c);
|
error(o->expr, "Cannot convert numeric value '%s' to '%s' from '%s', got %s", a, b, c, s);
|
||||||
check_assignment_error_suggestion(ctx, o, type);
|
check_assignment_error_suggestion(ctx, o, type);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
error(o->expr, "Cannot convert '%s' to '%s' from '%s", a, b, c);
|
error(o->expr, "Cannot convert '%s' to '%s' from '%s', got %s", a, b, c, s);
|
||||||
check_assignment_error_suggestion(ctx, o, type);
|
check_assignment_error_suggestion(ctx, o, type);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user