Skip to content

Incompatible dimensions with -> <fn> gives poor error message compared to |> <fn> #713

@triallax

Description

@triallax

Compare:

>>> 2 |> celsius
error: while type checking
   ┌─ Module 'physics::temperature_conversion', File <builtin>/modules/physics/temperature_conversion.nbt:15:12
   │
15 │ fn celsius(t_kelvin: Temperature) -> Scalar = t_kelvin / kelvin - _offset_celsius
   │            ^^^^^^^^ Temperature
   │
   ┌─ <input:14>:1:1
   │
 1 │ 2 |> celsius
   │ ^    ------- incompatible dimensions in argument 1 of function call to 'celsius'
   │ │     
   │ Angle or Scalar or SolidAngle
   │
   = parameter type: Temperature
      argument type: Scalar         [= Angle, Scalar, SolidAngle]
     
     Suggested fix: multiply the function argument by a `Temperature` factor

>>> 2 -> celsius
error: while type checking
  ┌─ <input:16>:1:1
  │
1 │ 2 -> celsius
  │ ^ Scalar
  │
  = Incompatible types in function call: expected 'Temperature', got 'Scalar' instead

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions