authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-06-25 13:57:45-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-06-25 13:57:45-04:00
logcb55803a59d4fe99b527dc3ffc5674666511f729
treea925b3e8bf37daee79077730bb41b87f7cf78c26
parentc61e0a078cea2a6845ed7b03189409829d2cdf24
signaturelock-open Commit is signed but in an unrecognized format.

fix implicit cast vector to array


2 files changed, 16 insertions(+), 0 deletions(-)

src/ir.cpp+3
......@@ -12283,6 +12283,9 @@ static IrInstruction *ir_analyze_vector_to_array(IrAnalyze *ira, IrInstruction *
1228312283 result->value.type = array_type;
1228412284 return result;
1228512285 }
12286 if (result_loc == nullptr) {
12287 result_loc = no_result_loc();
12288 }
1228612289 IrInstruction *result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, array_type, nullptr, true, false);
1228712290 if (type_is_invalid(result_loc_inst->value.type) || instr_is_unreachable(result_loc_inst)) {
1228812291 return result_loc_inst;
test/stage1/behavior/vector.zig+13
......@@ -61,3 +61,16 @@ test "vector bit operators" {
6161 S.doTheTest();
6262 comptime S.doTheTest();
6363}
64
65test "implicit cast vector to array" {
66 const S = struct {
67 fn doTheTest() void {
68 var a: @Vector(4, i32) = [_]i32{ 1, 2, 3, 4 };
69 var result_array: [4]i32 = a;
70 result_array = a;
71 expect(mem.eql(i32, result_array, [4]i32{ 1, 2, 3, 4 }));
72 }
73 };
74 S.doTheTest();
75 comptime S.doTheTest();
76}