aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2025-04-29 17:39:28 +0100
committergingerBill <bill@gingerbill.org>2025-04-29 17:39:28 +0100
commit0de802d388051c752cfce8fdc07dddfa19b45bfe (patch)
treef5b2631fc6e4771def791b1c1c9d3d8249dc4f6a /src
parent7c294a6e557321afa51b5ec96bcba7f11828afda (diff)
All N-valued (N>=2) expressions in `or_else` expressions
Diffstat (limited to 'src')
-rw-r--r--src/check_expr.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index 91d9e669f..5185876e6 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -9011,7 +9011,19 @@ gb_internal ExprKind check_or_else_expr(CheckerContext *c, Operand *o, Ast *node
if (left_type != nullptr) {
if (!y_is_diverging) {
- check_assignment(c, &y, left_type, name);
+ if (is_type_tuple(left_type)) {
+ if (!is_type_tuple(y.type)) {
+ error(y.expr, "Found a single value where a %td-valued expression was expected", left_type->Tuple.variables.count);
+ } else if (!are_types_identical(left_type, y.type)) {
+ gbString xt = type_to_string(left_type);
+ gbString yt = type_to_string(y.type);
+ error(y.expr, "Mismatched types, expected (%s), got (%s)", xt, yt);
+ gb_string_free(yt);
+ gb_string_free(xt);
+ }
+ } else {
+ check_assignment(c, &y, left_type, name);
+ }
}
} else {
check_or_else_expr_no_value_error(c, name, x, type_hint);