aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.cpp
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2022-09-05 15:47:10 +0100
committerGitHub <noreply@github.com>2022-09-05 15:47:10 +0100
commitd699d872d974509c2cdbe5a1d0913f51e9335d69 (patch)
tree9873b3cd609af22d4e80505357a4222fa62842f5 /src/check_expr.cpp
parent8421cb6d21e6b0a397dd9a31e76b97aba5c1852b (diff)
parent17894add9569f08c279f5ec20ba40bf9365a9c9c (diff)
Merge pull request #2019 from jaspergeer/fix-ternary-if-type-operands
fix panic when typeid used as operand for ternary if expression
Diffstat (limited to 'src/check_expr.cpp')
-rw-r--r--src/check_expr.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index 54dc081cf..0b6e108a3 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -7359,6 +7359,14 @@ ExprKind check_ternary_if_expr(CheckerContext *c, Operand *o, Ast *node, Type *t
return kind;
}
+ 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;
+ }
+
if (x.type == nullptr || x.type == t_invalid ||
y.type == nullptr || y.type == t_invalid) {
return kind;