harec

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

commit 55a08bbcb2a7170ae3fba45bddadb371ff96b81f
parent aec1d1840df604d3d3dd83ad4c8404a4c0097c5e
Author: Drew DeVault <sir@cmpwn.com>
Date:   Wed,  1 Sep 2021 11:59:54 +0200

check: add useful test for missing yields

It may be a good idea to generalize this into an error in the future and
force users to yield void if they really want to.

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

diff --git a/src/check.c b/src/check.c @@ -1302,6 +1302,10 @@ check_expr_compound(struct context *ctx, "A terminating expression may not be followed by additional expressions"); } } + if (lexpr->result != &builtin_type_void && hint && hint != &builtin_type_void) { + fprintf(stderr, "Warning: non-void result ignored at %s:%d\n", + lexpr->loc.path, lexpr->loc.lineno); + } expr->terminates = lexpr->terminates && lexpr->type != EXPR_YIELD; expr->result = type_store_reduce_result(ctx->store, scope->results);