| ... | @@ -22779,7 +22779,11 @@ fn ptrCastFull( | ... | @@ -22779,7 +22779,11 @@ fn ptrCastFull( |
| 22779 | } | 22779 | } |
| 22780 | | 22780 | |
| 22781 | const ptr = if (src_info.flags.size == .Slice and dest_info.flags.size != .Slice) ptr: { | 22781 | const ptr = if (src_info.flags.size == .Slice and dest_info.flags.size != .Slice) ptr: { |
| 22782 | break :ptr try sema.analyzeSlicePtr(block, operand_src, operand, operand_ty); | 22782 | if (operand_ty.zigTypeTag(mod) == .Optional) { |
| | 22783 | break :ptr try sema.analyzeOptionalSlicePtr(block, operand_src, operand, operand_ty); |
| | 22784 | } else { |
| | 22785 | break :ptr try sema.analyzeSlicePtr(block, operand_src, operand, operand_ty); |
| | 22786 | } |
| 22783 | } else operand; | 22787 | } else operand; |
| 22784 | | 22788 | |
| 22785 | const dest_ptr_ty = if (dest_info.flags.size == .Slice and src_info.flags.size != .Slice) blk: { | 22789 | const dest_ptr_ty = if (dest_info.flags.size == .Slice and src_info.flags.size != .Slice) blk: { |
| ... | @@ -32564,6 +32568,32 @@ fn analyzeSlicePtr( | ... | @@ -32564,6 +32568,32 @@ fn analyzeSlicePtr( |
| 32564 | return block.addTyOp(.slice_ptr, result_ty, slice); | 32568 | return block.addTyOp(.slice_ptr, result_ty, slice); |
| 32565 | } | 32569 | } |
| 32566 | | 32570 | |
| | 32571 | fn analyzeOptionalSlicePtr( |
| | 32572 | sema: *Sema, |
| | 32573 | block: *Block, |
| | 32574 | opt_slice_src: LazySrcLoc, |
| | 32575 | opt_slice: Air.Inst.Ref, |
| | 32576 | opt_slice_ty: Type, |
| | 32577 | ) CompileError!Air.Inst.Ref { |
| | 32578 | const mod = sema.mod; |
| | 32579 | const result_ty = opt_slice_ty.optionalChild(mod).slicePtrFieldType(mod); |
| | 32580 | |
| | 32581 | if (try sema.resolveValue(opt_slice)) |opt_val| { |
| | 32582 | if (opt_val.isUndef(mod)) return mod.undefRef(result_ty); |
| | 32583 | const slice_ptr: InternPool.Index = if (opt_val.optionalValue(mod)) |val| |
| | 32584 | val.slicePtr(mod).toIntern() |
| | 32585 | else |
| | 32586 | .null_value; |
| | 32587 | |
| | 32588 | return Air.internedToRef(slice_ptr); |
| | 32589 | } |
| | 32590 | |
| | 32591 | try sema.requireRuntimeBlock(block, opt_slice_src, null); |
| | 32592 | |
| | 32593 | const slice = try block.addTyOp(.optional_payload, opt_slice_ty, opt_slice); |
| | 32594 | return block.addTyOp(.slice_ptr, result_ty, slice); |
| | 32595 | } |
| | 32596 | |
| 32567 | fn analyzeSliceLen( | 32597 | fn analyzeSliceLen( |
| 32568 | sema: *Sema, | 32598 | sema: *Sema, |
| 32569 | block: *Block, | 32599 | block: *Block, |