aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.cpp
diff options
context:
space:
mode:
authorJasperGeer <jasper.geer@gmail.com>2022-09-04 16:37:40 -0400
committerJasperGeer <jasper.geer@gmail.com>2022-09-04 16:37:40 -0400
commit17894add9569f08c279f5ec20ba40bf9365a9c9c (patch)
tree9873b3cd609af22d4e80505357a4222fa62842f5 /src/check_expr.cpp
parent23d93f68463bd0f486f468075a767525c5be1a59 (diff)
Remove redundant code
Diffstat (limited to 'src/check_expr.cpp')
-rw-r--r--src/check_expr.cpp12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index a9a0b2235..0b6e108a3 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -7347,13 +7347,6 @@ ExprKind check_ternary_if_expr(CheckerContext *c, Operand *o, Ast *node, Type *t
check_expr_or_type(c, &x, te->x, type_hint);
node->viral_state_flags |= te->x->viral_state_flags;
- if (x.mode == Addressing_Type) {
- gbString type_string = expr_to_string(x.expr);
- error(node, "Type %s is invalid operand for ternary if expression", type_string);
- gb_string_free(type_string);
- return kind;
- }
-
if (te->y != nullptr) {
Type *th = type_hint;
if (type_hint == nullptr && is_type_typed(x.type)) {
@@ -7366,8 +7359,9 @@ ExprKind check_ternary_if_expr(CheckerContext *c, Operand *o, Ast *node, Type *t
return kind;
}
- if (y.mode == Addressing_Type) {
- gbString type_string = expr_to_string(y.expr);
+ if (x.mode == Addressing_Type || y.mode == Addressing_Type) {
+ Ast *type_expr = (x.mode == Addressing_Type) ? x.expr : y.expr;
+ gbString type_string = expr_to_string(type_expr);
error(node, "Type %s is invalid operand for ternary if expression", type_string);
gb_string_free(type_string);
return kind;