| ... | @@ -2086,7 +2086,7 @@ fn failWithUseOfAsync(sema: *Sema, block: *Block, src: LazySrcLoc) CompileError | ... | @@ -2086,7 +2086,7 @@ fn failWithUseOfAsync(sema: *Sema, block: *Block, src: LazySrcLoc) CompileError |
| 2086 | | 2086 | |
| 2087 | fn failWithInvalidFieldAccess(sema: *Sema, block: *Block, src: LazySrcLoc, object_ty: Type, field_name: []const u8) CompileError { | 2087 | fn failWithInvalidFieldAccess(sema: *Sema, block: *Block, src: LazySrcLoc, object_ty: Type, field_name: []const u8) CompileError { |
| 2088 | const mod = sema.mod; | 2088 | const mod = sema.mod; |
| 2089 | const inner_ty = if (object_ty.isSinglePointer()) object_ty.childType() else object_ty; | 2089 | const inner_ty = if (object_ty.isSinglePointer(mod)) object_ty.childType() else object_ty; |
| 2090 | | 2090 | |
| 2091 | if (inner_ty.zigTypeTag(mod) == .Optional) opt: { | 2091 | if (inner_ty.zigTypeTag(mod) == .Optional) opt: { |
| 2092 | var buf: Type.Payload.ElemType = undefined; | 2092 | var buf: Type.Payload.ElemType = undefined; |
| ... | @@ -3412,8 +3412,9 @@ fn indexablePtrLen( | ... | @@ -3412,8 +3412,9 @@ fn indexablePtrLen( |
| 3412 | src: LazySrcLoc, | 3412 | src: LazySrcLoc, |
| 3413 | object: Air.Inst.Ref, | 3413 | object: Air.Inst.Ref, |
| 3414 | ) CompileError!Air.Inst.Ref { | 3414 | ) CompileError!Air.Inst.Ref { |
| | 3415 | const mod = sema.mod; |
| 3415 | const object_ty = sema.typeOf(object); | 3416 | const object_ty = sema.typeOf(object); |
| 3416 | const is_pointer_to = object_ty.isSinglePointer(); | 3417 | const is_pointer_to = object_ty.isSinglePointer(mod); |
| 3417 | const indexable_ty = if (is_pointer_to) object_ty.childType() else object_ty; | 3418 | const indexable_ty = if (is_pointer_to) object_ty.childType() else object_ty; |
| 3418 | try checkIndexable(sema, block, src, indexable_ty); | 3419 | try checkIndexable(sema, block, src, indexable_ty); |
| 3419 | return sema.fieldVal(block, src, object, "len", src); | 3420 | return sema.fieldVal(block, src, object, "len", src); |
| ... | @@ -12764,12 +12765,12 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -12764,12 +12765,12 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 12764 | .Pointer => try sema.resolveDefinedValue(block, rhs_src, rhs), | 12765 | .Pointer => try sema.resolveDefinedValue(block, rhs_src, rhs), |
| 12765 | else => unreachable, | 12766 | else => unreachable, |
| 12766 | }) |rhs_val| { | 12767 | }) |rhs_val| { |
| 12767 | const lhs_sub_val = if (lhs_ty.isSinglePointer()) | 12768 | const lhs_sub_val = if (lhs_ty.isSinglePointer(mod)) |
| 12768 | (try sema.pointerDeref(block, lhs_src, lhs_val, lhs_ty)).? | 12769 | (try sema.pointerDeref(block, lhs_src, lhs_val, lhs_ty)).? |
| 12769 | else | 12770 | else |
| 12770 | lhs_val; | 12771 | lhs_val; |
| 12771 | | 12772 | |
| 12772 | const rhs_sub_val = if (rhs_ty.isSinglePointer()) | 12773 | const rhs_sub_val = if (rhs_ty.isSinglePointer(mod)) |
| 12773 | (try sema.pointerDeref(block, rhs_src, rhs_val, rhs_ty)).? | 12774 | (try sema.pointerDeref(block, rhs_src, rhs_val, rhs_ty)).? |
| 12774 | else | 12775 | else |
| 12775 | rhs_val; | 12776 | rhs_val; |
| ... | @@ -13022,7 +13023,7 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -13022,7 +13023,7 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 13022 | if (try sema.resolveDefinedValue(block, lhs_src, lhs)) |lhs_val| { | 13023 | if (try sema.resolveDefinedValue(block, lhs_src, lhs)) |lhs_val| { |
| 13023 | const final_len_including_sent = result_len + @boolToInt(lhs_info.sentinel != null); | 13024 | const final_len_including_sent = result_len + @boolToInt(lhs_info.sentinel != null); |
| 13024 | | 13025 | |
| 13025 | const lhs_sub_val = if (lhs_ty.isSinglePointer()) | 13026 | const lhs_sub_val = if (lhs_ty.isSinglePointer(mod)) |
| 13026 | (try sema.pointerDeref(block, lhs_src, lhs_val, lhs_ty)).? | 13027 | (try sema.pointerDeref(block, lhs_src, lhs_val, lhs_ty)).? |
| 13027 | else | 13028 | else |
| 13028 | lhs_val; | 13029 | lhs_val; |
| ... | @@ -17588,7 +17589,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -17588,7 +17589,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 17588 | const elem_ty = blk: { | 17589 | const elem_ty = blk: { |
| 17589 | const air_inst = try sema.resolveInst(extra.data.elem_type); | 17590 | const air_inst = try sema.resolveInst(extra.data.elem_type); |
| 17590 | const ty = sema.analyzeAsType(block, elem_ty_src, air_inst) catch |err| { | 17591 | const ty = sema.analyzeAsType(block, elem_ty_src, air_inst) catch |err| { |
| 17591 | if (err == error.AnalysisFail and sema.err != null and sema.typeOf(air_inst).isSinglePointer()) { | 17592 | if (err == error.AnalysisFail and sema.err != null and sema.typeOf(air_inst).isSinglePointer(mod)) { |
| 17592 | try sema.errNote(block, elem_ty_src, sema.err.?, "use '.*' to dereference pointer", .{}); | 17593 | try sema.errNote(block, elem_ty_src, sema.err.?, "use '.*' to dereference pointer", .{}); |
| 17593 | } | 17594 | } |
| 17594 | return err; | 17595 | return err; |
| ... | @@ -23902,7 +23903,7 @@ fn fieldVal( | ... | @@ -23902,7 +23903,7 @@ fn fieldVal( |
| 23902 | // Zig allows dereferencing a single pointer during field lookup. Note that | 23903 | // Zig allows dereferencing a single pointer during field lookup. Note that |
| 23903 | // we don't actually need to generate the dereference some field lookups, like the | 23904 | // we don't actually need to generate the dereference some field lookups, like the |
| 23904 | // length of arrays and other comptime operations. | 23905 | // length of arrays and other comptime operations. |
| 23905 | const is_pointer_to = object_ty.isSinglePointer(); | 23906 | const is_pointer_to = object_ty.isSinglePointer(mod); |
| 23906 | | 23907 | |
| 23907 | const inner_ty = if (is_pointer_to) | 23908 | const inner_ty = if (is_pointer_to) |
| 23908 | object_ty.childType() | 23909 | object_ty.childType() |
| ... | @@ -24092,7 +24093,7 @@ fn fieldPtr( | ... | @@ -24092,7 +24093,7 @@ fn fieldPtr( |
| 24092 | // Zig allows dereferencing a single pointer during field lookup. Note that | 24093 | // Zig allows dereferencing a single pointer during field lookup. Note that |
| 24093 | // we don't actually need to generate the dereference some field lookups, like the | 24094 | // we don't actually need to generate the dereference some field lookups, like the |
| 24094 | // length of arrays and other comptime operations. | 24095 | // length of arrays and other comptime operations. |
| 24095 | const is_pointer_to = object_ty.isSinglePointer(); | 24096 | const is_pointer_to = object_ty.isSinglePointer(mod); |
| 24096 | | 24097 | |
| 24097 | const inner_ty = if (is_pointer_to) | 24098 | const inner_ty = if (is_pointer_to) |
| 24098 | object_ty.childType() | 24099 | object_ty.childType() |
| ... | @@ -25622,7 +25623,7 @@ fn coerceExtra( | ... | @@ -25622,7 +25623,7 @@ fn coerceExtra( |
| 25622 | // *T to *[1]T | 25623 | // *T to *[1]T |
| 25623 | single_item: { | 25624 | single_item: { |
| 25624 | if (dest_info.size != .One) break :single_item; | 25625 | if (dest_info.size != .One) break :single_item; |
| 25625 | if (!inst_ty.isSinglePointer()) break :single_item; | 25626 | if (!inst_ty.isSinglePointer(mod)) break :single_item; |
| 25626 | if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :pointer; | 25627 | if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :pointer; |
| 25627 | const ptr_elem_ty = inst_ty.childType(); | 25628 | const ptr_elem_ty = inst_ty.childType(); |
| 25628 | const array_ty = dest_info.pointee_type; | 25629 | const array_ty = dest_info.pointee_type; |
| ... | @@ -25639,7 +25640,7 @@ fn coerceExtra( | ... | @@ -25639,7 +25640,7 @@ fn coerceExtra( |
| 25639 | | 25640 | |
| 25640 | // Coercions where the source is a single pointer to an array. | 25641 | // Coercions where the source is a single pointer to an array. |
| 25641 | src_array_ptr: { | 25642 | src_array_ptr: { |
| 25642 | if (!inst_ty.isSinglePointer()) break :src_array_ptr; | 25643 | if (!inst_ty.isSinglePointer(mod)) break :src_array_ptr; |
| 25643 | if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :pointer; | 25644 | if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :pointer; |
| 25644 | const array_ty = inst_ty.childType(); | 25645 | const array_ty = inst_ty.childType(); |
| 25645 | if (array_ty.zigTypeTag(mod) != .Array) break :src_array_ptr; | 25646 | if (array_ty.zigTypeTag(mod) != .Array) break :src_array_ptr; |
| ... | @@ -25794,7 +25795,7 @@ fn coerceExtra( | ... | @@ -25794,7 +25795,7 @@ fn coerceExtra( |
| 25794 | .One => switch (dest_info.pointee_type.zigTypeTag(mod)) { | 25795 | .One => switch (dest_info.pointee_type.zigTypeTag(mod)) { |
| 25795 | .Union => { | 25796 | .Union => { |
| 25796 | // pointer to anonymous struct to pointer to union | 25797 | // pointer to anonymous struct to pointer to union |
| 25797 | if (inst_ty.isSinglePointer() and | 25798 | if (inst_ty.isSinglePointer(mod) and |
| 25798 | inst_ty.childType().isAnonStruct() and | 25799 | inst_ty.childType().isAnonStruct() and |
| 25799 | sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) | 25800 | sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) |
| 25800 | { | 25801 | { |
| ... | @@ -25803,7 +25804,7 @@ fn coerceExtra( | ... | @@ -25803,7 +25804,7 @@ fn coerceExtra( |
| 25803 | }, | 25804 | }, |
| 25804 | .Struct => { | 25805 | .Struct => { |
| 25805 | // pointer to anonymous struct to pointer to struct | 25806 | // pointer to anonymous struct to pointer to struct |
| 25806 | if (inst_ty.isSinglePointer() and | 25807 | if (inst_ty.isSinglePointer(mod) and |
| 25807 | inst_ty.childType().isAnonStruct() and | 25808 | inst_ty.childType().isAnonStruct() and |
| 25808 | sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) | 25809 | sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) |
| 25809 | { | 25810 | { |
| ... | @@ -25815,7 +25816,7 @@ fn coerceExtra( | ... | @@ -25815,7 +25816,7 @@ fn coerceExtra( |
| 25815 | }, | 25816 | }, |
| 25816 | .Array => { | 25817 | .Array => { |
| 25817 | // pointer to tuple to pointer to array | 25818 | // pointer to tuple to pointer to array |
| 25818 | if (inst_ty.isSinglePointer() and | 25819 | if (inst_ty.isSinglePointer(mod) and |
| 25819 | inst_ty.childType().isTuple() and | 25820 | inst_ty.childType().isTuple() and |
| 25820 | sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) | 25821 | sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) |
| 25821 | { | 25822 | { |
| ... | @@ -25834,7 +25835,7 @@ fn coerceExtra( | ... | @@ -25834,7 +25835,7 @@ fn coerceExtra( |
| 25834 | ); | 25835 | ); |
| 25835 | } | 25836 | } |
| 25836 | | 25837 | |
| 25837 | if (!inst_ty.isSinglePointer()) break :to_slice; | 25838 | if (!inst_ty.isSinglePointer(mod)) break :to_slice; |
| 25838 | const inst_child_ty = inst_ty.childType(); | 25839 | const inst_child_ty = inst_ty.childType(); |
| 25839 | if (!inst_child_ty.isTuple()) break :to_slice; | 25840 | if (!inst_child_ty.isTuple()) break :to_slice; |
| 25840 | | 25841 | |
| ... | @@ -30807,7 +30808,7 @@ fn resolvePeerTypes( | ... | @@ -30807,7 +30808,7 @@ fn resolvePeerTypes( |
| 30807 | .Vector => continue, | 30808 | .Vector => continue, |
| 30808 | else => {}, | 30809 | else => {}, |
| 30809 | }, | 30810 | }, |
| 30810 | .Fn => if (chosen_ty.isSinglePointer() and chosen_ty.isConstPtr() and chosen_ty.childType().zigTypeTag(mod) == .Fn) { | 30811 | .Fn => if (chosen_ty.isSinglePointer(mod) and chosen_ty.isConstPtr() and chosen_ty.childType().zigTypeTag(mod) == .Fn) { |
| 30811 | if (.ok == try sema.coerceInMemoryAllowedFns(block, chosen_ty.childType(), candidate_ty, target, src, src)) { | 30812 | if (.ok == try sema.coerceInMemoryAllowedFns(block, chosen_ty.childType(), candidate_ty, target, src, src)) { |
| 30812 | continue; | 30813 | continue; |
| 30813 | } | 30814 | } |