diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-05-27 20:57:48 +0100 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-05-27 20:57:48 +0100 |
| commit | f8fa7fe3801114da153a28064c68177e13ecece0 (patch) | |
| tree | 11e21fccbb190ae8612bad605b86c0b2796e7560 /src/check_expr.c | |
| parent | 45dbe8d354a776dfc526f5a31b9f49158640e45b (diff) | |
Fix bug with too many field values in a structure literal.
Diffstat (limited to 'src/check_expr.c')
| -rw-r--r-- | src/check_expr.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/check_expr.c b/src/check_expr.c index 27659c800..0854fd17d 100644 --- a/src/check_expr.c +++ b/src/check_expr.c @@ -5391,18 +5391,17 @@ 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 (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 (index >= field_count) { - error_node(o->expr, "Too many values in structure literal, expected %td", field_count); - break; - } if (!check_is_field_exported(c, field)) { gbString t = type_to_string(type); |