Function check_relational_operation

Source
pub fn check_relational_operation(
    context: &CompilationContext,
    left_type: &TypeId,
    right_type: &TypeId,
    operator: &BinaryOperator,
    location: &Location,
) -> SemanticResult
Expand description

Checks if types are compatible for relational operations (>, <, >=, <=, ==, !=). Types must be comparable with each other, which means they’re either:

  • Exactly the same type (except Unit)
  • Unspecified integer literal and an integer type
  • Unspecified float literal and a float type

§Arguments

  • context - The compilation context
  • left_type - The type of the left operand
  • right_type - The type of the right operand
  • operator - The relational operator
  • location - The source location of the operation

§Returns

  • Ok(bool_type()) if the types are comparable
  • Err with a descriptive error message otherwise