OxL Справочник OxL
РусскийEnglish

error refinement-violated

error Стандарт: [§3.6]

Константа нарушает предикат уточнённого типа.

What it means#

A refined type T where P carries the invariant P (§3.6). When a literal constant is used where such a type is expected, the compiler checks P at compile time and rejects values that do not satisfy it. Values that are only known at run time are obtained with Port.from(x), which returns Port | InvalidValue.

Example#

oxl✓ проверяется в CI
type Port = u16 where 1..=65535

fn main() {
  let p: Port = 0      // <- refinement-violated
}
error
refinement-violated

How to fix#

oxl✓ проверяется в CI
type Port = u16 where 1..=65535

fn main() {
  let p: Port = 8080
}

Use a value that satisfies the predicate, or construct the value at run time with Port.from(x) and handle InvalidValue.

See also#

OxL 1.0.0-beta · Версия документации 1.0.0-beta© OxwaldLink · сгенерировано из Стандарта, исходников std и руководства