| ... | ... | @@ -3628,6 +3628,10 @@ fn zirAllocExtended( |
| 3628 | 3628 | } |
| 3629 | 3629 | } |
| 3630 | 3630 | |
| 3631 | if (small.has_type and try var_ty.comptimeOnlySema(pt)) { |
| 3632 | return sema.analyzeComptimeAlloc(block, var_ty, alignment); |
| 3633 | } |
| 3634 | |
| 3631 | 3635 | if (small.has_type) { |
| 3632 | 3636 | if (!small.is_const) { |
| 3633 | 3637 | try sema.validateVarType(block, ty_src, var_ty, false); |
| ... | ... | @@ -4075,7 +4079,7 @@ fn zirAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I |
| 4075 | 4079 | const ty_src = block.src(.{ .node_offset_var_decl_ty = inst_data.src_node }); |
| 4076 | 4080 | |
| 4077 | 4081 | const var_ty = try sema.resolveType(block, ty_src, inst_data.operand); |
| 4078 | | if (block.is_comptime) { |
| 4082 | if (block.is_comptime or try var_ty.comptimeOnlySema(pt)) { |
| 4079 | 4083 | return sema.analyzeComptimeAlloc(block, var_ty, .none); |
| 4080 | 4084 | } |
| 4081 | 4085 | if (sema.func_is_naked and try var_ty.hasRuntimeBitsSema(pt)) { |
| ... | ... | @@ -31938,6 +31942,17 @@ fn storePtr2( |
| 31938 | 31942 | } else break :rs ptr_src; |
| 31939 | 31943 | } else ptr_src; |
| 31940 | 31944 | |
| 31945 | // We're performing the store at runtime; as such, we need to make sure the pointee type |
| 31946 | // is not comptime-only. We can hit this case with a `@ptrFromInt` pointer. |
| 31947 | if (try elem_ty.comptimeOnlySema(pt)) { |
| 31948 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 31949 | const msg = try sema.errMsg(src, "cannot store comptime-only type '{}' at runtime", .{elem_ty.fmt(pt)}); |
| 31950 | errdefer msg.destroy(sema.gpa); |
| 31951 | try sema.errNote(ptr_src, msg, "operation is runtime due to this pointer", .{}); |
| 31952 | break :msg msg; |
| 31953 | }); |
| 31954 | } |
| 31955 | |
| 31941 | 31956 | // We do this after the possible comptime store above, for the case of field_ptr stores |
| 31942 | 31957 | // to unions because we want the comptime tag to be set, even if the field type is void. |
| 31943 | 31958 | if ((try sema.typeHasOnePossibleValue(elem_ty)) != null) { |