diff options
| author | jason <jkercher@rlcsystems.com> | 2022-05-16 13:49:57 -0400 |
|---|---|---|
| committer | jason <jkercher@rlcsystems.com> | 2022-05-16 13:49:57 -0400 |
| commit | fff23e2bbbd1574debce9e0dee894f3cc84a04c4 (patch) | |
| tree | 4055ea217375d34693861b39fc284e411f7c0366 /src/check_expr.cpp | |
| parent | 97d1a6787189d7630650612f44c393f7a635019a (diff) | |
| parent | 33895b6d927c70167f3bfa64c6cc1c15c4e428c5 (diff) | |
merge from upstream and convert to ^File types
Diffstat (limited to 'src/check_expr.cpp')
| -rw-r--r-- | src/check_expr.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp index dcf17af39..f578f8c73 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -7241,7 +7241,11 @@ ExprKind check_ternary_if_expr(CheckerContext *c, Operand *o, Ast *node, Type *t node->viral_state_flags |= te->x->viral_state_flags; if (te->y != nullptr) { - check_expr_or_type(c, &y, te->y, type_hint); + Type *th = type_hint; + if (type_hint == nullptr && is_type_typed(x.type)) { + th = x.type; + } + check_expr_or_type(c, &y, te->y, th); node->viral_state_flags |= te->y->viral_state_flags; } else { error(node, "A ternary expression must have an else clause"); @@ -8161,7 +8165,10 @@ ExprKind check_compound_literal(CheckerContext *c, Operand *o, Ast *node, Type * case Type_Basic: { if (!is_type_any(t)) { if (cl->elems.count != 0) { - error(node, "Illegal compound literal"); + gbString s = type_to_string(t); + error(node, "Illegal compound literal, %s cannot be used as a compound literal with fields", s); + gb_string_free(s); + is_constant = false; } break; } |