authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-11-11 13:18:16-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-11-11 13:18:16-05:00
log1bca8e693d42256d575c76fbab5c68d86c0c4bc3
tree6b0f6d80f83eb13a719d32bcbbacb38d1a0551a4
parentd4e6a6d5e27df845d47b254aab9d14f44d68d620
signaturelock-open Commit is signed but in an unrecognized format.

fix anon literal used with return result loc


2 files changed, 14 insertions(+), 2 deletions(-)

src/ir.cpp+9-1
......@@ -6151,7 +6151,11 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A
61516151 init_array_type_source_node = container_type->source_node;
61526152 } else {
61536153 child_result_loc = parent_result_loc;
6154 init_array_type_source_node = parent_result_loc->source_instruction->source_node;
6154 if (parent_result_loc->source_instruction != nullptr) {
6155 init_array_type_source_node = parent_result_loc->source_instruction->source_node;
6156 } else {
6157 init_array_type_source_node = node;
6158 }
61556159 }
61566160
61576161 switch (kind) {
......@@ -15935,6 +15939,10 @@ static IrInstruction *ir_analyze_instruction_resolve_result(IrAnalyze *ira,
1593515939 instruction->result_loc->source_instruction->child);
1593615940 if (type_is_invalid(implicit_elem_type))
1593715941 return ira->codegen->invalid_instruction;
15942 } else if (instruction->result_loc->id == ResultLocIdReturn) {
15943 implicit_elem_type = ira->explicit_return_type;
15944 if (type_is_invalid(implicit_elem_type))
15945 return ira->codegen->invalid_instruction;
1593815946 } else {
1593915947 Buf *bare_name = buf_alloc();
1594015948 Buf *name = get_anon_type_name(ira->codegen, nullptr, container_string(ContainerKindStruct),
test/stage1/behavior/union.zig+5-1
......@@ -559,10 +559,14 @@ test "anonymous union literal syntax" {
559559
560560 fn doTheTest() void {
561561 var i: Number = .{.int = 42};
562 var f: Number = .{.float = 12.34};
562 var f = makeNumber();
563563 expect(i.int == 42);
564564 expect(f.float == 12.34);
565565 }
566
567 fn makeNumber() Number {
568 return .{.float = 12.34};
569 }
566570 };
567571 S.doTheTest();
568572 comptime S.doTheTest();