Function check_negation_operation

Source
pub fn check_negation_operation(
    context: &CompilationContext,
    unary_expr: &UnaryExpr,
    operand_type: &TypeId,
) -> SemanticResult
Expand description

Checks if arithmetic negation (-) is valid for the given operand type. Supports signed integers, floats, and unspecified numeric literals. Unsigned integers cannot be negated.

§Arguments

  • context - The compilation context
  • unary_expr - The unary negation expression
  • operand_type - The type of the operand

§Returns

  • Ok(type_id) with the operand type if negation is valid
  • Err with a descriptive error message if negation is invalid