| ... | ... | @@ -19393,13 +19393,14 @@ fn zirArrayInit( |
| 19393 | 19393 | }, |
| 19394 | 19394 | else => |e| return e, |
| 19395 | 19395 | }; |
| 19396 | const is_tuple = array_ty.zigTypeTag(mod) == .Struct; |
| 19396 | 19397 | const sentinel_val = array_ty.sentinel(mod); |
| 19397 | 19398 | |
| 19398 | 19399 | const resolved_args = try gpa.alloc(Air.Inst.Ref, args.len - 1 + @intFromBool(sentinel_val != null)); |
| 19399 | 19400 | defer gpa.free(resolved_args); |
| 19400 | 19401 | for (args[1..], 0..) |arg, i| { |
| 19401 | 19402 | const resolved_arg = try sema.resolveInst(arg); |
| 19402 | | const elem_ty = if (array_ty.zigTypeTag(mod) == .Struct) |
| 19403 | const elem_ty = if (is_tuple) |
| 19403 | 19404 | array_ty.structFieldType(i, mod) |
| 19404 | 19405 | else |
| 19405 | 19406 | array_ty.elemType2(mod); |
| ... | ... | @@ -19412,6 +19413,18 @@ fn zirArrayInit( |
| 19412 | 19413 | }, |
| 19413 | 19414 | else => return err, |
| 19414 | 19415 | }; |
| 19416 | if (is_tuple) if (try array_ty.structFieldValueComptime(mod, i)) |field_val| { |
| 19417 | const init_val = try sema.resolveMaybeUndefVal(resolved_args[i]) orelse { |
| 19418 | const decl = mod.declPtr(block.src_decl); |
| 19419 | const elem_src = mod.initSrc(src.node_offset.x, decl, i); |
| 19420 | return sema.failWithNeededComptime(block, elem_src, "value stored in comptime field must be comptime-known"); |
| 19421 | }; |
| 19422 | if (!field_val.eql(init_val, elem_ty, mod)) { |
| 19423 | const decl = mod.declPtr(block.src_decl); |
| 19424 | const elem_src = mod.initSrc(src.node_offset.x, decl, i); |
| 19425 | return sema.failWithInvalidComptimeFieldStore(block, elem_src, array_ty, i); |
| 19426 | } |
| 19427 | }; |
| 19415 | 19428 | } |
| 19416 | 19429 | |
| 19417 | 19430 | if (sentinel_val) |some| { |