aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2022-09-22 00:34:36 +0100
committergingerBill <bill@gingerbill.org>2022-09-22 00:34:36 +0100
commitdade5b5ef2ee5a35cbe2c5a3d524cbc3e84402f0 (patch)
tree5f8c882d1a6bbee3fd4a635f5e9da61fbd8f5a45 /src
parent3aea9a7c206f225af3bc327738f2df30d7fe0a58 (diff)
Improve error message for `check_is_expressible` (Cannot convert X to Y from Z)
Diffstat (limited to 'src')
-rw-r--r--src/check_expr.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index 1168a9ba3..0a42c6618 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -2053,15 +2053,18 @@ bool check_is_expressible(CheckerContext *ctx, Operand *o, Type *type) {
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_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 {
- 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);
}
} 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);
}
return false;