diff options
| author | gingerBill <bill@gingerbill.org> | 2020-03-05 20:34:30 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2020-03-05 20:34:30 +0000 |
| commit | e92fdb4a99bf9d27009dd35fdd074ff14facfc03 (patch) | |
| tree | e74c13d12da216f2548db0a8359e491263dc6acd /src/check_type.cpp | |
| parent | 2fe0eaf2adf952867d4ce4fba53b4b3ac75e1ba5 (diff) | |
`x if cond else y` and `x when cond else y` expressions
Diffstat (limited to 'src/check_type.cpp')
| -rw-r--r-- | src/check_type.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/check_type.cpp b/src/check_type.cpp index 6194951c9..010b31f03 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -3454,6 +3454,26 @@ bool check_type_internal(CheckerContext *ctx, Ast *e, Type **type, Type *named_t return true; } case_end; + + case_ast_node(te, TernaryIfExpr, e); + Operand o = {}; + check_expr_or_type(ctx, &o, e); + if (o.mode == Addressing_Type) { + *type = o.type; + set_base_type(named_type, *type); + return true; + } + case_end; + + case_ast_node(te, TernaryWhenExpr, e); + Operand o = {}; + check_expr_or_type(ctx, &o, e); + if (o.mode == Addressing_Type) { + *type = o.type; + set_base_type(named_type, *type); + return true; + } + case_end; } *type = t_invalid; |