Fix issue with mixture of named and unnamed parameters for a struct literal

This commit is contained in:
gingerBill
2018-12-14 14:35:23 +00:00
parent 3bf01c8498
commit b54c35639b
+5 -4
View File
@@ -5356,6 +5356,8 @@ bool ternary_compare_types(Type *x, Type *y) {
return are_types_identical(x, y);
}
ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type *type_hint) {
ExprKind kind = Expr_Stmt;
@@ -5646,7 +5648,7 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type
break;
}
if (is_type_struct(t)) { // Checker values
isize field_count = t->Struct.fields.count;
isize min_field_count = t->Struct.fields.count;
for (isize i = min_field_count-1; i >= 0; i--) {
@@ -5718,8 +5720,8 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type
Ast *elem = cl->elems[index];
if (elem->kind == Ast_FieldValue) {
seen_field_value = true;
// error(elem, "Mixture of 'field = value' and value elements in a literal is not allowed");
// continue;
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;
@@ -5754,7 +5756,6 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type
}
}
}
}
break;
}