@@ -7994,6 +7994,7 @@ static ImplicitCastMatchResult ir_types_match_with_implicit_cast(IrAnalyze *ira,
79947994 // implicit &const [N]T to []const T
79957995 if (is_slice(expected_type) &&
79967996 actual_type->id == TypeTableEntryIdPointer &&
7997+ actual_type->data.pointer.ptr_len == PtrLenSingle &&
79977998 actual_type->data.pointer.is_const &&
79987999 actual_type->data.pointer.child_type->id == TypeTableEntryIdArray)
79998000 {
@@ -8012,6 +8013,7 @@ static ImplicitCastMatchResult ir_types_match_with_implicit_cast(IrAnalyze *ira,
80128013 // implicit [N]T to &const []const T
80138014 if (expected_type->id == TypeTableEntryIdPointer &&
80148015 expected_type->data.pointer.is_const &&
8016+ expected_type->data.pointer.ptr_len == PtrLenSingle &&
80158017 is_slice(expected_type->data.pointer.child_type) &&
80168018 actual_type->id == TypeTableEntryIdArray)
80178019 {
@@ -8074,6 +8076,7 @@ static ImplicitCastMatchResult ir_types_match_with_implicit_cast(IrAnalyze *ira,
80748076 actual_type->id == TypeTableEntryIdComptimeInt)
80758077 {
80768078 if (expected_type->id == TypeTableEntryIdPointer &&
8079+ expected_type->data.pointer.ptr_len == PtrLenSingle &&
80778080 expected_type->data.pointer.is_const)
80788081 {
80798082 if (ir_num_lit_fits_in_other_type(ira, value, expected_type->data.pointer.child_type, false)) {
@@ -8121,7 +8124,10 @@ static ImplicitCastMatchResult ir_types_match_with_implicit_cast(IrAnalyze *ira,
81218124 }
81228125
81238126 // implicit enum to &const union which has the enum as the tag type
8124- if (actual_type->id == TypeTableEntryIdEnum && expected_type->id == TypeTableEntryIdPointer) {
8127+ if (actual_type->id == TypeTableEntryIdEnum &&
8128+ expected_type->id == TypeTableEntryIdPointer &&
8129+ expected_type->data.pointer.ptr_len == PtrLenSingle)
8130+ {
81258131 TypeTableEntry *union_type = expected_type->data.pointer.child_type;
81268132 if (union_type->data.unionation.decl_node->data.container_decl.auto_enum ||
81278133 union_type->data.unionation.decl_node->data.container_decl.init_arg_expr != nullptr)
@@ -8141,7 +8147,11 @@ static ImplicitCastMatchResult ir_types_match_with_implicit_cast(IrAnalyze *ira,
81418147 // implicitly take a const pointer to something
81428148 if (!type_requires_comptime(actual_type)) {
81438149 TypeTableEntry *const_ptr_actual = get_pointer_to_type(ira->codegen, actual_type, true);
8144- if (types_match_const_cast_only(ira, expected_type, const_ptr_actual, source_node).id == ConstCastResultIdOk) {
8150+ if (expected_type->id == TypeTableEntryIdPointer &&
8151+ expected_type->data.pointer.ptr_len == PtrLenSingle &&
8152+ types_match_const_cast_only(ira, expected_type, const_ptr_actual,
8153+ source_node).id == ConstCastResultIdOk)
8154+ {
81458155 return ImplicitCastMatchResultYes;
81468156 }
81478157 }
0 commit comments