Skip to content
Playground(another site)

bynk.types.inverted_range

Error An InRange predicate has its bounds inverted.

InRange(lo, hi) is inclusive at both ends, so it needs lo <= hi. With the bounds the wrong way round the refinement admits no value, which is almost certainly a slip, so the compiler refuses it. Swap them; the diagnostic offers that fix. On an Int or Float the empty range is also reported as bynk.types.empty_refinement, which is what contradictory predicates give too. An inverted range in a match arm is bynk.types.empty_range_pattern.

Example

type Price = Decimal where InRange(100.00d, 0.00d) // ✗ the minimum is above the maximum
type Price = Decimal where InRange(0.00d, 100.00d) // ✓

In the Book

See also

  • The grammar rule it governs: refinement.
  • Every code in its category, Type checking, on the diagnostic index.
  • bynk explain bynk.types.inverted_range shows the same from the installed toolchain, without a network.