| ... | ... | @@ -2318,7 +2318,7 @@ fn zirAllocExtended( |
| 2318 | 2318 | else |
| 2319 | 2319 | Type.initTag(.inferred_alloc_mut); |
| 2320 | 2320 | |
| 2321 | | if (small.is_comptime) { |
| 2321 | if (block.is_comptime or small.is_comptime) { |
| 2322 | 2322 | if (small.has_type) { |
| 2323 | 2323 | return sema.analyzeComptimeAlloc(block, var_ty, alignment, ty_src); |
| 2324 | 2324 | } else { |
| ... | ... | @@ -2379,7 +2379,10 @@ fn zirAllocInferredComptime( |
| 2379 | 2379 | sema.src = src; |
| 2380 | 2380 | return sema.addConstant( |
| 2381 | 2381 | inferred_alloc_ty, |
| 2382 | | try Value.Tag.inferred_alloc_comptime.create(sema.arena, undefined), |
| 2382 | try Value.Tag.inferred_alloc_comptime.create(sema.arena, .{ |
| 2383 | .decl = undefined, |
| 2384 | .alignment = 0, |
| 2385 | }), |
| 2383 | 2386 | ); |
| 2384 | 2387 | } |
| 2385 | 2388 | |
| ... | ... | @@ -2440,7 +2443,10 @@ fn zirAllocInferred( |
| 2440 | 2443 | if (block.is_comptime) { |
| 2441 | 2444 | return sema.addConstant( |
| 2442 | 2445 | inferred_alloc_ty, |
| 2443 | | try Value.Tag.inferred_alloc_comptime.create(sema.arena, undefined), |
| 2446 | try Value.Tag.inferred_alloc_comptime.create(sema.arena, .{ |
| 2447 | .decl = undefined, |
| 2448 | .alignment = 0, |
| 2449 | }), |
| 2444 | 2450 | ); |
| 2445 | 2451 | } |
| 2446 | 2452 | |
| ... | ... | @@ -11341,7 +11347,14 @@ fn zirPtrCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 11341 | 11347 | const operand_ty = sema.typeOf(operand); |
| 11342 | 11348 | try sema.checkPtrType(block, dest_ty_src, dest_ty); |
| 11343 | 11349 | try sema.checkPtrOperand(block, operand_src, operand_ty); |
| 11344 | | return sema.coerceCompatiblePtrs(block, dest_ty, operand, operand_src); |
| 11350 | if (dest_ty.isSlice()) { |
| 11351 | return sema.fail(block, dest_ty_src, "illegal pointer cast to slice", .{}); |
| 11352 | } |
| 11353 | const ptr = if (operand_ty.isSlice()) |
| 11354 | try sema.analyzeSlicePtr(block, operand_src, operand, operand_ty) |
| 11355 | else |
| 11356 | operand; |
| 11357 | return sema.coerceCompatiblePtrs(block, dest_ty, ptr, operand_src); |
| 11345 | 11358 | } |
| 11346 | 11359 | |
| 11347 | 11360 | fn zirTruncate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| ... | ... | @@ -13081,7 +13094,7 @@ fn fieldVal( |
| 13081 | 13094 | try sema.analyzeLoad(block, src, object, object_src) |
| 13082 | 13095 | else |
| 13083 | 13096 | object; |
| 13084 | | return sema.analyzeSlicePtr(block, src, slice, inner_ty, object_src); |
| 13097 | return sema.analyzeSlicePtr(block, object_src, slice, inner_ty); |
| 13085 | 13098 | } else if (mem.eql(u8, field_name, "len")) { |
| 13086 | 13099 | const slice = if (is_pointer_to) |
| 13087 | 13100 | try sema.analyzeLoad(block, src, object, object_src) |
| ... | ... | @@ -15584,19 +15597,17 @@ fn analyzeLoad( |
| 15584 | 15597 | fn analyzeSlicePtr( |
| 15585 | 15598 | sema: *Sema, |
| 15586 | 15599 | block: *Block, |
| 15587 | | src: LazySrcLoc, |
| 15600 | slice_src: LazySrcLoc, |
| 15588 | 15601 | slice: Air.Inst.Ref, |
| 15589 | 15602 | slice_ty: Type, |
| 15590 | | slice_src: LazySrcLoc, |
| 15591 | 15603 | ) CompileError!Air.Inst.Ref { |
| 15592 | 15604 | const buf = try sema.arena.create(Type.SlicePtrFieldTypeBuffer); |
| 15593 | 15605 | const result_ty = slice_ty.slicePtrFieldType(buf); |
| 15594 | | |
| 15595 | 15606 | if (try sema.resolveMaybeUndefVal(block, slice_src, slice)) |val| { |
| 15596 | 15607 | if (val.isUndef()) return sema.addConstUndef(result_ty); |
| 15597 | 15608 | return sema.addConstant(result_ty, val.slicePtr()); |
| 15598 | 15609 | } |
| 15599 | | try sema.requireRuntimeBlock(block, src); |
| 15610 | try sema.requireRuntimeBlock(block, slice_src); |
| 15600 | 15611 | return block.addTyOp(.slice_ptr, result_ty, slice); |
| 15601 | 15612 | } |
| 15602 | 15613 | |
| ... | ... | @@ -15729,7 +15740,7 @@ fn analyzeSlice( |
| 15729 | 15740 | } |
| 15730 | 15741 | |
| 15731 | 15742 | const ptr = if (slice_ty.isSlice()) |
| 15732 | | try sema.analyzeSlicePtr(block, src, ptr_or_slice, slice_ty, ptr_src) |
| 15743 | try sema.analyzeSlicePtr(block, ptr_src, ptr_or_slice, slice_ty) |
| 15733 | 15744 | else |
| 15734 | 15745 | ptr_or_slice; |
| 15735 | 15746 | |