aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2020-05-14 00:34:27 +0100
committergingerBill <bill@gingerbill.org>2020-05-14 00:34:27 +0100
commitcd4403be0c2656f0d4ba74a96eccaf905beae2ff (patch)
tree413ca9145d119519fc604bfd4416836eb7df5279 /src
parentf661d3404952d33d4cb683899ebd05d4b580b2bc (diff)
Fix Assertion failure in ir_print_exact_value #620
Diffstat (limited to 'src')
-rw-r--r--src/check_expr.cpp17
-rw-r--r--src/ir_print.cpp11
2 files changed, 16 insertions, 12 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index 159ae5e3a..4d3268f44 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -8168,16 +8168,18 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type
}
fields_visited[sel.index[0]] = true;
- check_expr_or_type(c, o, fv->value, field->type);
+
+ Operand o = {};
+ check_expr_or_type(c, &o, fv->value, field->type);
if (is_type_any(field->type) || is_type_union(field->type) || is_type_raw_union(field->type) || is_type_typeid(field->type)) {
is_constant = false;
}
if (is_constant) {
- is_constant = o->mode == Addressing_Constant;
+ is_constant = o.mode == Addressing_Constant;
}
- check_assignment(c, o, field->type, str_lit("structure literal"));
+ check_assignment(c, &o, field->type, str_lit("structure literal"));
}
} else {
bool seen_field_value = false;
@@ -8194,7 +8196,7 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type
continue;
}
if (index >= field_count) {
- error(o->expr, "Too many values in structure literal, expected %td, got %td", field_count, cl->elems.count);
+ error(elem, "Too many values in structure literal, expected %td, got %td", field_count, cl->elems.count);
break;
}
@@ -8202,16 +8204,17 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type
field = t->Struct.fields[index];
}
- check_expr_or_type(c, o, elem, field->type);
+ Operand o = {};
+ check_expr_or_type(c, &o, elem, field->type);
if (is_type_any(field->type) || is_type_union(field->type) || is_type_raw_union(field->type) || is_type_typeid(field->type)) {
is_constant = false;
}
if (is_constant) {
- is_constant = o->mode == Addressing_Constant;
+ is_constant = o.mode == Addressing_Constant;
}
- check_assignment(c, o, field->type, str_lit("structure literal"));
+ check_assignment(c, &o, field->type, str_lit("structure literal"));
}
if (cl->elems.count < field_count) {
if (min_field_count < field_count) {
diff --git a/src/ir_print.cpp b/src/ir_print.cpp
index 591fdc420..c54ddc26e 100644
--- a/src/ir_print.cpp
+++ b/src/ir_print.cpp
@@ -1200,8 +1200,8 @@ void ir_print_exact_value(irFileBuffer *f, irModule *m, ExactValue value, Type *
Selection sel = lookup_field(type, name, false);
Entity *f = type->Struct.fields[sel.index[0]];
- values[f->Variable.field_index] = tav.value;
- visited[f->Variable.field_index] = true;
+ values[f->Variable.field_src_index] = tav.value;
+ visited[f->Variable.field_src_index] = true;
}
} else {
for_array(i, cl->elems) {
@@ -1211,8 +1211,8 @@ void ir_print_exact_value(irFileBuffer *f, irModule *m, ExactValue value, Type *
if (tav.mode != Addressing_Invalid) {
val = tav.value;
}
- values[f->Variable.field_index] = val;
- visited[f->Variable.field_index] = true;
+ values[f->Variable.field_src_index] = val;
+ visited[f->Variable.field_src_index] = true;
}
}
}
@@ -1231,7 +1231,8 @@ void ir_print_exact_value(irFileBuffer *f, irModule *m, ExactValue value, Type *
for (isize i = 0; i < value_count; i++) {
if (i > 0) ir_write_string(f, str_lit(", "));
Entity *e = type->Struct.fields[i];
- ir_print_compound_element(f, m, values[i], e->type);
+ GB_ASSERT(e->kind == Entity_Variable);
+ ir_print_compound_element(f, m, values[e->Variable.field_src_index], e->type);
}