mirror of
https://github.com/ziglang/zig.git
synced 2026-02-19 07:48:31 +00:00
fix initialization of vector in a struct field
This commit is contained in:
parent
cbaa10fc3b
commit
9b4a529164
@ -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;
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user