| ... | @@ -11147,7 +11147,7 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -11147,7 +11147,7 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp |
| 11147 | if (type_is_invalid(resolved_type)) | 11147 | if (type_is_invalid(resolved_type)) |
| 11148 | return resolved_type; | 11148 | return resolved_type; |
| 11149 | | 11149 | |
| 11150 | | 11150 | bool operator_allowed; |
| 11151 | switch (resolved_type->id) { | 11151 | switch (resolved_type->id) { |
| 11152 | case TypeTableEntryIdInvalid: | 11152 | case TypeTableEntryIdInvalid: |
| 11153 | zig_unreachable(); // handled above | 11153 | zig_unreachable(); // handled above |
| ... | @@ -11156,6 +11156,7 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -11156,6 +11156,7 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp |
| 11156 | case TypeTableEntryIdComptimeInt: | 11156 | case TypeTableEntryIdComptimeInt: |
| 11157 | case TypeTableEntryIdInt: | 11157 | case TypeTableEntryIdInt: |
| 11158 | case TypeTableEntryIdFloat: | 11158 | case TypeTableEntryIdFloat: |
| | 11159 | operator_allowed = true; |
| 11159 | break; | 11160 | break; |
| 11160 | | 11161 | |
| 11161 | case TypeTableEntryIdBool: | 11162 | case TypeTableEntryIdBool: |
| ... | @@ -11170,19 +11171,8 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -11170,19 +11171,8 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp |
| 11170 | case TypeTableEntryIdBoundFn: | 11171 | case TypeTableEntryIdBoundFn: |
| 11171 | case TypeTableEntryIdArgTuple: | 11172 | case TypeTableEntryIdArgTuple: |
| 11172 | case TypeTableEntryIdPromise: | 11173 | case TypeTableEntryIdPromise: |
| 11173 | if (!is_equality_cmp) { | | |
| 11174 | ir_add_error_node(ira, source_node, | | |
| 11175 | buf_sprintf("operator not allowed for type '%s'", buf_ptr(&resolved_type->name))); | | |
| 11176 | return ira->codegen->builtin_types.entry_invalid; | | |
| 11177 | } | | |
| 11178 | break; | | |
| 11179 | | | |
| 11180 | case TypeTableEntryIdEnum: | 11174 | case TypeTableEntryIdEnum: |
| 11181 | if (!is_equality_cmp) { | 11175 | operator_allowed = is_equality_cmp; |
| 11182 | ir_add_error_node(ira, source_node, | | |
| 11183 | buf_sprintf("operator not allowed for type '%s'", buf_ptr(&resolved_type->name))); | | |
| 11184 | return ira->codegen->builtin_types.entry_invalid; | | |
| 11185 | } | | |
| 11186 | break; | 11176 | break; |
| 11187 | | 11177 | |
| 11188 | case TypeTableEntryIdUnreachable: | 11178 | case TypeTableEntryIdUnreachable: |
| ... | @@ -11190,12 +11180,18 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -11190,12 +11180,18 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp |
| 11190 | case TypeTableEntryIdStruct: | 11180 | case TypeTableEntryIdStruct: |
| 11191 | case TypeTableEntryIdUndefined: | 11181 | case TypeTableEntryIdUndefined: |
| 11192 | case TypeTableEntryIdNull: | 11182 | case TypeTableEntryIdNull: |
| 11193 | case TypeTableEntryIdOptional: | | |
| 11194 | case TypeTableEntryIdErrorUnion: | 11183 | case TypeTableEntryIdErrorUnion: |
| 11195 | case TypeTableEntryIdUnion: | 11184 | case TypeTableEntryIdUnion: |
| 11196 | ir_add_error_node(ira, source_node, | 11185 | operator_allowed = false; |
| 11197 | buf_sprintf("operator not allowed for type '%s'", buf_ptr(&resolved_type->name))); | 11186 | break; |
| 11198 | return ira->codegen->builtin_types.entry_invalid; | 11187 | case TypeTableEntryIdOptional: |
| | 11188 | operator_allowed = is_equality_cmp && get_codegen_ptr_type(resolved_type) != nullptr; |
| | 11189 | break; |
| | 11190 | } |
| | 11191 | if (!operator_allowed) { |
| | 11192 | ir_add_error_node(ira, source_node, |
| | 11193 | buf_sprintf("operator not allowed for type '%s'", buf_ptr(&resolved_type->name))); |
| | 11194 | return ira->codegen->builtin_types.entry_invalid; |
| 11199 | } | 11195 | } |
| 11200 | | 11196 | |
| 11201 | IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, resolved_type); | 11197 | IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, resolved_type); |