`bynk.refine.literal_violates`
[bynk.refine.literal_violates] Error: literal 0 does not satisfy `InRange` required by type `Reps`What it means
Section titled “What it means”You wrote a literal in a position whose expected type is a refined type, and the literal does not satisfy that type’s predicate. Because Bynk checks admitted literals at compile time, this is a build error rather than a runtime failure.
commons demo { type Reps = Int where InRange(1, 100)
fn bad() -> Reps { 0 -- 0 is outside InRange(1, 100) }}Pick the option that matches where the value comes from:
-
It should be a different literal. Use one that satisfies the predicate (e.g.
1). -
It comes from runtime input. Don’t use a bare literal — validate with
.of, which returns aResultyou handle:fn parse(n: Int) -> Result[Reps, ValidationError] {Reps.of(n)} -
The predicate is wrong. If
0should be allowed, widen the type (e.g.InRange(0, 100)).