diff options
| author | gingerBill <bill@gingerbill.org> | 2018-12-08 13:31:25 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2018-12-08 13:31:25 +0000 |
| commit | 4369a1714e9e039abc09bdb095b8044ad2f5d2ff (patch) | |
| tree | 93e19dcf5241a889a3560b24bd5818a539d69acc /src/ir.cpp | |
| parent | 13f084a219320a39eaa06dc4527f720231cc9710 (diff) | |
Fix automatic subtype casting bug
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 77587516d..44095a4a9 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -4581,15 +4581,14 @@ irValue *ir_emit_conv(irProcedure *proc, irValue *value, Type *t) { Type *pst = st; st = type_deref(st); - bool st_is_ptr = st != pst; + bool st_is_ptr = is_type_pointer(src_type); st = base_type(st); Type *dt = t; bool dt_is_ptr = is_type_pointer(dt); - GB_ASSERT(is_type_struct(st) || is_type_union(st)); - String field_name = ir_lookup_subtype_polymorphic_field(proc->module->info, t, st); - // gb_printf("field_name: %.*s\n", LIT(field_name)); + GB_ASSERT(is_type_struct(st) || is_type_raw_union(st)); + String field_name = ir_lookup_subtype_polymorphic_field(proc->module->info, t, src_type); if (field_name.len > 0) { // NOTE(bill): It can be casted Selection sel = lookup_field(st, field_name, false); @@ -4614,7 +4613,11 @@ irValue *ir_emit_conv(irProcedure *proc, irValue *value, Type *t) { return ir_emit_deep_field_ev(proc, value, sel); } + } else { + GB_PANIC("invalid subtype cast"); } + } else { + GB_PANIC("invalid subtype cast"); } } |