Commit cb55803a59
Changed files (2)
src
test
stage1
behavior
src/ir.cpp
@@ -12283,6 +12283,9 @@ static IrInstruction *ir_analyze_vector_to_array(IrAnalyze *ira, IrInstruction *
result->value.type = array_type;
return result;
}
+ if (result_loc == nullptr) {
+ result_loc = no_result_loc();
+ }
IrInstruction *result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, array_type, nullptr, true, false);
if (type_is_invalid(result_loc_inst->value.type) || instr_is_unreachable(result_loc_inst)) {
return result_loc_inst;
test/stage1/behavior/vector.zig
@@ -61,3 +61,16 @@ test "vector bit operators" {
S.doTheTest();
comptime S.doTheTest();
}
+
+test "implicit cast vector to array" {
+ const S = struct {
+ fn doTheTest() void {
+ var a: @Vector(4, i32) = [_]i32{ 1, 2, 3, 4 };
+ var result_array: [4]i32 = a;
+ result_array = a;
+ expect(mem.eql(i32, result_array, [4]i32{ 1, 2, 3, 4 }));
+ }
+ };
+ S.doTheTest();
+ comptime S.doTheTest();
+}