harec

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit af04c6acf5f2a825e584f120b9cd4d77132f3827
parent 6864ad7e04188d2c272a21f2367df09fe8210ab0
Author: Eyal Sawady <ecs@d2evs.net>
Date:   Sun, 24 Apr 2022 12:34:59 +0000

check: improve error msg for invalid return values

Signed-off-by: Eyal Sawady <ecs@d2evs.net>

Diffstat:
Msrc/check.c | 6++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/check.c b/src/check.c @@ -2148,7 +2148,8 @@ check_expr_return(struct context *ctx, if (!type_is_assignable(ctx->fntype->func.result, rval->result)) { error(ctx, aexpr->loc, expr, - "Return value is not assignable to function result type"); + "Return value %s is not assignable to function result type %s", + gen_typename(rval->result), gen_typename(ctx->fntype->func.result)); return; } if (ctx->fntype->func.result != rval->result) { @@ -2950,7 +2951,8 @@ check_function(struct context *ctx, expect(&afndecl->body->loc, body->terminates || type_is_assignable(fntype->func.result, body->result), - "Result value is not assignable to function result type"); + "Result value %s is not assignable to function result type %s", + gen_typename(body->result), gen_typename(fntype->func.result)); if (!body->terminates && fntype->func.result != body->result) { body = lower_implicit_cast(fntype->func.result, body); }