mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 23:28:48 +00:00
Fix #2018 type assertion on untyped nil within a ternary if expression
This commit is contained in:
+8
-7
@@ -7359,13 +7359,13 @@ ExprKind check_ternary_if_expr(CheckerContext *c, Operand *o, Ast *node, Type *t
|
|||||||
return kind;
|
return kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x.mode == Addressing_Type || y.mode == Addressing_Type) {
|
if (x.mode == Addressing_Type || y.mode == Addressing_Type) {
|
||||||
Ast *type_expr = (x.mode == Addressing_Type) ? x.expr : y.expr;
|
Ast *type_expr = (x.mode == Addressing_Type) ? x.expr : y.expr;
|
||||||
gbString type_string = expr_to_string(type_expr);
|
gbString type_string = expr_to_string(type_expr);
|
||||||
error(node, "Type %s is invalid operand for ternary if expression", type_string);
|
error(node, "Type %s is invalid operand for ternary if expression", type_string);
|
||||||
gb_string_free(type_string);
|
gb_string_free(type_string);
|
||||||
return kind;
|
return kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x.type == nullptr || x.type == t_invalid ||
|
if (x.type == nullptr || x.type == t_invalid ||
|
||||||
y.type == nullptr || y.type == t_invalid) {
|
y.type == nullptr || y.type == t_invalid) {
|
||||||
@@ -7403,6 +7403,7 @@ ExprKind check_ternary_if_expr(CheckerContext *c, Operand *o, Ast *node, Type *t
|
|||||||
check_cast_internal(c, &y, type_hint)) {
|
check_cast_internal(c, &y, type_hint)) {
|
||||||
convert_to_typed(c, o, type_hint);
|
convert_to_typed(c, o, type_hint);
|
||||||
update_untyped_expr_type(c, node, type_hint, !is_type_untyped(type_hint));
|
update_untyped_expr_type(c, node, type_hint, !is_type_untyped(type_hint));
|
||||||
|
o->type = type_hint;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return kind;
|
return kind;
|
||||||
|
|||||||
Reference in New Issue
Block a user