mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 15:18:49 +00:00
Fix bug with too many field values in a structure literal.
This commit is contained in:
+7
-8
@@ -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");
|
error_node(elem, "Mixture of `field = value` and value elements in a structure literal is not allowed");
|
||||||
continue;
|
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) {
|
if (index >= field_count) {
|
||||||
error_node(o->expr, "Too many values in structure literal, expected %td", field_count);
|
error_node(o->expr, "Too many values in structure literal, expected %td", field_count);
|
||||||
break;
|
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)) {
|
if (!check_is_field_exported(c, field)) {
|
||||||
gbString t = type_to_string(type);
|
gbString t = type_to_string(type);
|
||||||
error_node(o->expr, "Implicit assignment to an unexported field `%.*s` in `%s` literal",
|
error_node(o->expr, "Implicit assignment to an unexported field `%.*s` in `%s` literal",
|
||||||
|
|||||||
Reference in New Issue
Block a user