commit 3c541d7be38d625645276f8a0dee57774fe94134 (tree)
parent 6217b401f94380a0a82aa979bc4ac90e7431267d
Author: Andrew Kelley <andrew@ziglang.org>
Date: Wed, 19 Jun 2019 23:52:51 -0400
fix peer result loc fn call with comptime condition
Diffstat:
3 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/src/ir.cpp b/src/ir.cpp
@@ -16004,7 +16004,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
IrInstruction *result_loc;
if (handle_is_ptr(impl_fn_type_id->return_type)) {
result_loc = ir_resolve_result(ira, &call_instruction->base, call_instruction->result_loc,
- impl_fn_type_id->return_type, nullptr, true, false);
+ impl_fn_type_id->return_type, nullptr, true, true);
if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) {
return result_loc;
}
@@ -16124,7 +16124,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
IrInstruction *result_loc;
if (handle_is_ptr(return_type)) {
result_loc = ir_resolve_result(ira, &call_instruction->base, call_instruction->result_loc,
- return_type, nullptr, true, false);
+ return_type, nullptr, true, true);
if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) {
return result_loc;
}
diff --git a/test/stage1/behavior.zig b/test/stage1/behavior.zig
@@ -76,7 +76,7 @@ comptime {
_ = @import("behavior/sizeof_and_typeof.zig");
_ = @import("behavior/slice.zig");
_ = @import("behavior/slicetobytes.zig");
- _ = @import("behavior/struct.zig"); // TODO
+ _ = @import("behavior/struct.zig");
_ = @import("behavior/struct_contains_null_ptr_itself.zig");
_ = @import("behavior/struct_contains_slice_of_itself.zig");
_ = @import("behavior/switch.zig");
diff --git a/test/stage1/behavior/struct.zig b/test/stage1/behavior/struct.zig
@@ -529,26 +529,26 @@ test "access to global struct fields" {
expect(g_foo.bar.value == 42);
}
-//test "packed struct with fp fields" {
-// const S = packed struct {
-// data: [3]f32,
-//
-// pub fn frob(self: *@This()) void {
-// self.data[0] += self.data[1] + self.data[2];
-// self.data[1] += self.data[0] + self.data[2];
-// self.data[2] += self.data[0] + self.data[1];
-// }
-// };
-//
-// var s: S = undefined;
-// s.data[0] = 1.0;
-// s.data[1] = 2.0;
-// s.data[2] = 3.0;
-// s.frob();
-// expectEqual(f32(6.0), s.data[0]);
-// expectEqual(f32(11.0), s.data[1]);
-// expectEqual(f32(20.0), s.data[2]);
-//}
+test "packed struct with fp fields" {
+ const S = packed struct {
+ data: [3]f32,
+
+ pub fn frob(self: *@This()) void {
+ self.data[0] += self.data[1] + self.data[2];
+ self.data[1] += self.data[0] + self.data[2];
+ self.data[2] += self.data[0] + self.data[1];
+ }
+ };
+
+ var s: S = undefined;
+ s.data[0] = 1.0;
+ s.data[1] = 2.0;
+ s.data[2] = 3.0;
+ s.frob();
+ expectEqual(f32(6.0), s.data[0]);
+ expectEqual(f32(11.0), s.data[1]);
+ expectEqual(f32(20.0), s.data[2]);
+}
test "use within struct scope" {
const S = struct {