Fix bug with too many field values in a structure literal.

This commit is contained in:
Ginger Bill
2017-05-27 20:57:48 +01:00
parent 45dbe8d354
commit f8fa7fe380

View File

@@ -5391,19 +5391,18 @@ ExprKind check_expr_base_internal(Checker *c, Operand *o, AstNode *node, Type *t
error_node(elem, "Mixture of `field = value` and value elements in a structure literal is not allowed");
continue;
}
Entity *field = t->Record.fields_in_src_order[index];
if (!all_fields_are_blank && str_eq(field->token.string, str_lit("_"))) {
// NOTE(bill): Ignore blank identifiers
continue;
}
check_expr(c, o, elem);
if (index >= field_count) {
error_node(o->expr, "Too many values in structure literal, expected %td", field_count);
break;
}
Entity *field = t->Record.fields_in_src_order[index];
if (!all_fields_are_blank && str_eq(field->token.string, str_lit("_"))) {
// NOTE(bill): Ignore blank identifiers
continue;
}
check_expr(c, o, elem);
if (!check_is_field_exported(c, field)) {
gbString t = type_to_string(type);
error_node(o->expr, "Implicit assignment to an unexported field `%.*s` in `%s` literal",