commit 6a156cca7975a7f600e89249062c7bf6da72d054
parent f97053046bf969b5ac60e5802ec7106e52fa2cbb
Author: Eyal Sawady <ecs@d2evs.net>
Date: Fri, 14 Jan 2022 08:48:18 +0000
check: improve error messages for invalid casts
Signed-off-by: Eyal Sawady <ecs@d2evs.net>
Diffstat:
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/check.c b/src/check.c
@@ -1177,7 +1177,9 @@ check_expr_cast(struct context *ctx,
}
if (!type_is_castable(value->result, secondary)) {
error(ctx, aexpr->cast.type->loc, expr,
- "Invalid cast");
+ "Invalid cast from %s to %s",
+ gen_typename(value->result),
+ gen_typename(secondary));
return;
}
bool found = false;
@@ -1199,7 +1201,9 @@ check_expr_cast(struct context *ctx,
case C_CAST:
if (!type_is_castable(secondary, value->result)) {
error(ctx, aexpr->cast.type->loc, expr,
- "Invalid cast");
+ "Invalid cast from %s to %s",
+ gen_typename(value->result),
+ gen_typename(secondary));
return;
}
// Fallthrough