aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2022-08-11 13:43:35 +0100
committergingerBill <bill@gingerbill.org>2022-08-11 13:43:35 +0100
commit70dc0c15fd244bdc4a769b0d91b50ecc210bca65 (patch)
treee91f4be7b4704d70c3bae91a7bc92fa9ffdf9d20 /src/check_expr.cpp
parent9eeed9d5bde1348d16d3c3790ba3178f3e0bb09d (diff)
Improve type hint for #load to allow for string types
Diffstat (limited to 'src/check_expr.cpp')
-rw-r--r--src/check_expr.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index ae459574c..076eaba73 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -7435,10 +7435,6 @@ ExprKind check_or_else_expr(CheckerContext *c, Operand *o, Ast *node, Type *type
// NOTE(bill, 2022-08-11): edge case to handle #load(path) or_else default
if (is_load_directive_call(arg)) {
LoadDirectiveResult res = check_load_directive(c, &x, arg, type_hint, false);
- if (res == LoadDirective_Success) {
- *o = x;
- return Expr_Expr;
- }
bool y_is_diverging = false;
check_expr_base(c, &y, default_value, x.type);
@@ -7468,10 +7464,16 @@ ExprKind check_or_else_expr(CheckerContext *c, Operand *o, Ast *node, Type *type
if (!y_is_diverging) {
check_assignment(c, &y, x.type, name);
+ if (y.mode != Addressing_Constant) {
+ error(y.expr, "expected a constant expression on the right-hand side of 'or_else' in conjuction with '#load'");
+ }
}
- o->mode = y.mode;
- o->type = y.type;
+ if (res == LoadDirective_Success) {
+ *o = x;
+ } else {
+ *o = y;
+ }
o->expr = node;
return Expr_Expr;