Commit 9b4a529164
Changed files (2)
src
test
stage1
behavior
src/ir.cpp
@@ -17640,7 +17640,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct
return ira->codegen->invalid_instruction;
if (array_ptr_val->special == ConstValSpecialUndef && elem_ptr_instruction->init_array_type != nullptr) {
- if (array_type->id == ZigTypeIdArray) {
+ if (array_type->id == ZigTypeIdArray || array_type->id == ZigTypeIdVector) {
array_ptr_val->data.x_array.special = ConstArraySpecialNone;
array_ptr_val->data.x_array.data.s_none.elements = create_const_vals(array_type->data.array.len);
array_ptr_val->special = ConstValSpecialStatic;
test/stage1/behavior/vector.zig
@@ -234,3 +234,19 @@ test "store vector elements via runtime index" {
S.doTheTest();
comptime S.doTheTest();
}
+
+test "initialize vector which is a struct field" {
+ const Vec4Obj = struct {
+ data: @Vector(4, f32),
+ };
+
+ const S = struct {
+ fn doTheTest() void {
+ var foo = Vec4Obj{
+ .data = [_]f32{ 1, 2, 3, 4 },
+ };
+ }
+ };
+ S.doTheTest();
+ comptime S.doTheTest();
+}