harec

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

commit db9663f9b9e7868ab31614bbe27fb7d0a7de8198
parent 883978d16df460a72871edfa287f784c5d58b01c
Author: Drew DeVault <sir@cmpwn.com>
Date:   Tue,  2 Feb 2021 13:55:07 -0500

check: verify that match cases are assignable

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

diff --git a/src/check.c b/src/check.c @@ -1071,10 +1071,15 @@ check_expr_match(struct context *ctx, } struct match_case *_case = expr->match.cases; + struct ast_match_case *acase = aexpr->match.cases; while (_case) { + expect(&acase->value->loc, + type_is_assignable(expr->result, _case->value->result), + "Match case is not assignable to result type"); _case->value = lower_implicit_cast( expr->result, _case->value); _case = _case->next; + acase = acase->next; } struct type_tagged_union *tu = result_type.next;