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...@@ -6151,7 +6151,11 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A
6151 init_array_type_source_node = container_type->source_node;6151 init_array_type_source_node = container_type->source_node;
6152 } else {6152 } else {
6153 child_result_loc = parent_result_loc;6153 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 }
6155 }6159 }
61566160
6157 switch (kind) {6161 switch (kind) {
...@@ -15935,6 +15939,10 @@ static IrInstruction *ir_analyze_instruction_resolve_result(IrAnalyze *ira,...@@ -15935,6 +15939,10 @@ static IrInstruction *ir_analyze_instruction_resolve_result(IrAnalyze *ira,
15935 instruction->result_loc->source_instruction->child);15939 instruction->result_loc->source_instruction->child);
15936 if (type_is_invalid(implicit_elem_type))15940 if (type_is_invalid(implicit_elem_type))
15937 return ira->codegen->invalid_instruction;15941 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;
15938 } else {15946 } else {
15939 Buf *bare_name = buf_alloc();15947 Buf *bare_name = buf_alloc();
15940 Buf *name = get_anon_type_name(ira->codegen, nullptr, container_string(ContainerKindStruct),15948 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" {...@@ -559,10 +559,14 @@ test "anonymous union literal syntax" {
559559
560 fn doTheTest() void {560 fn doTheTest() void {
561 var i: Number = .{.int = 42};561 var i: Number = .{.int = 42};
562 var f: Number = .{.float = 12.34};562 var f = makeNumber();
563 expect(i.int == 42);563 expect(i.int == 42);
564 expect(f.float == 12.34);564 expect(f.float == 12.34);
565 }565 }
566
567 fn makeNumber() Number {
568 return .{.float = 12.34};
569 }
566 };570 };
567 S.doTheTest();571 S.doTheTest();
568 comptime S.doTheTest();572 comptime S.doTheTest();