pub fn check_mixed_arithmetic_operation(
context: &CompilationContext,
left_type: &TypeId,
right_type: &TypeId,
bin_expr: &BinaryExpr,
) -> SemanticResult
Expand description
Checks if mixed-type arithmetic operations are allowed, particularly handling unspecified literals that can be coerced to match the other operand’s type. This function handles type coercion for arithmetic operations when operands have different types.
§Supported Cases
- Unspecified integer literal + specific integer type
- Unspecified float literal + specific float type
- String concatenation with the + operator
§Arguments
context
- The compilation contextleft_type
- The type of the left operandright_type
- The type of the right operandbin_expr
- The binary expression containing both operands and the operator
§Returns
Ok(type_id)
with the resulting operation type if allowedErr
with a descriptive error message if the operation is not allowed