| author | |
| committer | |
| log | 9b4a52916472f39a0a9e6d0807240e304a9e9ca6 |
| tree | 2bf61887435fff1328211eec5072ed67bb924ece |
| parent | cbaa10fc3bcd2d5f8d48b9038e840ae508fe2822 |
| signature |
2 files changed, 17 insertions(+), 1 deletions(-)
src/ir.cpp+1-1| ... | ... | @@ -17640,7 +17640,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 17640 | 17640 | return ira->codegen->invalid_instruction; |
| 17641 | 17641 | |
| 17642 | 17642 | if (array_ptr_val->special == ConstValSpecialUndef && elem_ptr_instruction->init_array_type != nullptr) { |
| 17643 | if (array_type->id == ZigTypeIdArray) { | |
| 17643 | if (array_type->id == ZigTypeIdArray || array_type->id == ZigTypeIdVector) { | |
| 17644 | 17644 | array_ptr_val->data.x_array.special = ConstArraySpecialNone; |
| 17645 | 17645 | array_ptr_val->data.x_array.data.s_none.elements = create_const_vals(array_type->data.array.len); |
| 17646 | 17646 | array_ptr_val->special = ConstValSpecialStatic; |
test/stage1/behavior/vector.zig+16| ... | ... | @@ -234,3 +234,19 @@ test "store vector elements via runtime index" { |
| 234 | 234 | S.doTheTest(); |
| 235 | 235 | comptime S.doTheTest(); |
| 236 | 236 | } |
| 237 | ||
| 238 | test "initialize vector which is a struct field" { | |
| 239 | const Vec4Obj = struct { | |
| 240 | data: @Vector(4, f32), | |
| 241 | }; | |
| 242 | ||
| 243 | const S = struct { | |
| 244 | fn doTheTest() void { | |
| 245 | var foo = Vec4Obj{ | |
| 246 | .data = [_]f32{ 1, 2, 3, 4 }, | |
| 247 | }; | |
| 248 | } | |
| 249 | }; | |
| 250 | S.doTheTest(); | |
| 251 | comptime S.doTheTest(); | |
| 252 | } |