Change Union representation for LLVM IR; fix dynamic array size

This commit is contained in:
Ginger Bill
2017-04-19 18:58:23 +01:00
parent 95692fda52
commit c5411a25a9
4 changed files with 62 additions and 25 deletions
+6 -1
View File
@@ -586,7 +586,7 @@ void check_union_type(Checker *c, Type *union_type, AstNode *node) {
Entity *using_index_expr = NULL;
Entity **variants = gb_alloc_array(c->allocator, Entity *, variant_count);
Entity **fields = gb_alloc_array(c->allocator, Entity *, field_count);
Entity **fields = gb_alloc_array(c->allocator, Entity *, field_count);
isize variant_index = 0;
variants[variant_index++] = make_entity_type_name(c->allocator, c->context.scope, empty_token, NULL);
@@ -5194,6 +5194,11 @@ ExprKind check_expr_base_internal(Checker *c, Operand *o, AstNode *node, Type *t
}
Entity *field = t->Record.fields_in_src_order[index];
if (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);