diff options
| author | gingerBill <bill@gingerbill.org> | 2017-11-09 22:48:00 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2017-11-09 22:48:00 +0000 |
| commit | eb4b3f5976d1563cd97841964e829fc638179cc5 (patch) | |
| tree | 4031277bf8d44d261a5c8a10ad2c62aed9e3dbfb /src/check_expr.cpp | |
| parent | dbb070524ffde7d392c6776dae41ea440b0e84c6 (diff) | |
Change push allocator system; update core libraries
Diffstat (limited to 'src/check_expr.cpp')
| -rw-r--r-- | src/check_expr.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 2e36a5c1f..5e24c575e 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -5179,7 +5179,6 @@ bool ternary_compare_types(Type *x, Type *y) { return are_types_identical(x, y); } - ExprKind check_expr_base_internal(Checker *c, Operand *o, AstNode *node, Type *type_hint) { ExprKind kind = Expr_Stmt; @@ -5550,16 +5549,17 @@ ExprKind check_expr_base_internal(Checker *c, Operand *o, AstNode *node, Type *t } } - isize field_index = 0; + bool seen_field_value = false; + for_array(index, cl->elems) { - Entity *field = t->Struct.fields_in_src_order[field_index++]; - if (!all_fields_are_blank && is_blank_ident(field->token)) { - // NOTE(bill): Ignore blank identifiers - continue; - } + Entity *field = nullptr; AstNode *elem = cl->elems[index]; if (elem->kind == AstNode_FieldValue) { - error(elem, "Mixture of `field = value` and value elements in a literal is not allowed"); + seen_field_value = true; + // error(elem, "Mixture of `field = value` and value elements in a literal is not allowed"); + // continue; + } else if (seen_field_value) { + error(elem, "Value elements cannot be used after a `field = value`"); continue; } if (index >= field_count) { @@ -5567,6 +5567,14 @@ ExprKind check_expr_base_internal(Checker *c, Operand *o, AstNode *node, Type *t break; } + if (field == nullptr) { + field = t->Struct.fields_in_src_order[index]; + } + if (!all_fields_are_blank && is_blank_ident(field->token)) { + // NOTE(bill): Ignore blank identifiers + continue; + } + check_expr_with_type_hint(c, o, elem, field->type); if (!check_is_field_exported(c, field)) { |