Skip to content
Playground(another site)

bynk.types.empty_refinement

Error A refinement admits no values (contradictory predicates).

A refinement is a base type plus predicates, and a value must satisfy all of them. When the predicates contradict each other, nothing can satisfy them: the type has no values, and every .of and every boundary check would fail. The compiler works out the combined range of Positive, NonNegative and InRange, and the combined length of the length predicates, and refuses one that is empty. Drop or correct the predicate that conflicts, and read the note, which gives the empty range it found.

Example

type Debt = Int where Positive && InRange(-10, -1) // ✗ positive, yet at most -1
type Debt = Int where Positive && InRange(1, 10) // ✓

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.empty_refinement shows the same from the installed toolchain, without a network.