diff --git a/code/demo.odin b/code/demo.odin index 6f6610260..d75250c6b 100644 --- a/code/demo.odin +++ b/code/demo.odin @@ -1,6 +1,14 @@ -#import "fmt.odin"; -#import "sync.odin"; +Test1 :: type union { + A: int; + B: int; +}; + +Test :: type struct { + a: Test1; +}; main :: proc() { - fmt.println("Hellope"); -} + test: Test; + match type x : ^test.a { + } +}; diff --git a/src/ssa.c b/src/ssa.c index 12ffb752a..95a7a58ef 100644 --- a/src/ssa.c +++ b/src/ssa.c @@ -1579,12 +1579,14 @@ ssaValue *ssa_emit_union_tag_ptr(ssaProcedure *proc, ssaValue *u) { Type *t = ssa_type(u); GB_ASSERT(is_type_pointer(t) && is_type_union(type_deref(t))); + GB_ASSERT(are_types_identical(t, ssa_type(u))); return ssa_emit(proc, ssa_make_instr_union_tag_ptr(proc, u)); } ssaValue *ssa_emit_union_tag_value(ssaProcedure *proc, ssaValue *u) { Type *t = ssa_type(u); GB_ASSERT(is_type_union(t)); + GB_ASSERT(are_types_identical(t, ssa_type(u))); return ssa_emit(proc, ssa_make_instr_union_tag_value(proc, u)); } diff --git a/src/ssa_opt.c b/src/ssa_opt.c index 5fccbfcb6..42ce830c9 100644 --- a/src/ssa_opt.c +++ b/src/ssa_opt.c @@ -54,7 +54,11 @@ void ssa_opt_add_operands(ssaValueArray *ops, ssaInstr *i) { array_add(ops, i->Phi.edges.e[j]); } break; - case ssaInstr_Unreachable: break; + case ssaInstr_Unreachable: + break; + case ssaInstr_UnaryOp: + array_add(ops, i->UnaryOp.expr); + break; case ssaInstr_BinaryOp: array_add(ops, i->BinaryOp.left); array_add(ops, i->BinaryOp.right); @@ -88,8 +92,6 @@ void ssa_opt_add_operands(ssaValueArray *ops, ssaInstr *i) { array_add(ops, i->SliceBoundsCheck.high); array_add(ops, i->SliceBoundsCheck.max); break; - - } } diff --git a/src/ssa_print.c b/src/ssa_print.c index 707140bea..31463bd17 100644 --- a/src/ssa_print.c +++ b/src/ssa_print.c @@ -204,12 +204,7 @@ void ssa_print_type(ssaFileBuffer *f, ssaModule *m, Type *t) { if (i > 0) { ssa_fprintf(f, ", "); } - Type *ft = t->Record.fields[i]->type; - Type *bft = base_type(ft); - if (!is_type_struct(bft)) { - ft = bft; - } - ssa_print_type(f, m, ft); + ssa_print_type(f, m, t->Record.fields[i]->type); } ssa_fprintf(f, "}"); if (t->Record.struct_is_packed) { @@ -242,7 +237,6 @@ void ssa_print_type(ssaFileBuffer *f, ssaModule *m, Type *t) { String *name = map_string_get(&m->type_names, hash_pointer(t)); GB_ASSERT_MSG(name != NULL, "%.*s", LIT(t->Named.name)); ssa_print_encoded_local(f, *name); - // ssa_print_encoded_local(f, t->Named.name); } else { ssa_print_type(f, m, base_type(t)); }