#[non_exhaustive]pub enum Error {
StepLimit {
limit: u64,
},
InvalidPattern {
arm: usize,
node: usize,
reason: Reason,
},
Model {
reason: &'static str,
},
TooLarge,
}Expand description
Why a check could not produce a Report.
§Examples
use match_lang::{check, Arm, Error, Model, Pat, Reason, Signature};
struct Bytes;
impl Model for Bytes {
type Ty = ();
fn signature(&self, _: &()) -> Signature<()> {
Signature::Int { min: 0, max: 255 }
}
fn fields(&self, _: &(), _: u32, _: &mut Vec<()>) {}
}
let err = check(&Bytes, &(), &[Arm::new(Pat::int(300))]).unwrap_err();
assert_eq!(err, Error::InvalidPattern { arm: 0, node: 0, reason: Reason::OutOfDomain });Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
StepLimit
The analysis took more steps than the step limit allows. Deciding exhaustiveness is NP-hard in general, so some matrices (typically many columns of overlapping or-patterns or ranges) need exponential work; the limit turns them into this error instead of a hang. Raise the limit if the match is legitimate, or report it to the user as too complex to check.
InvalidPattern
A pattern does not fit the type it is matched against. This is a type error the language’s checker should have caught; nothing was analysed.
Fields
Model
The model answered inconsistently: the same type got different
signatures or field counts during one check, or a signature was
itself invalid (an Int with min > max). Fix the model.
TooLarge
The patterns, or the matrix built from them, need more than
u32::MAX - 1 nodes, rows, or cells.
Trait Implementations§
impl Eq for Error
Source§impl Error for Error
impl Error for Error
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()