Skip to main content

uni_locy/compiler/
errors.rs

1use thiserror::Error;
2
3#[derive(Debug, Error, Clone, PartialEq)]
4pub enum LocyCompileError {
5    #[error("cyclic negation among rules: {}", rules.join(", "))]
6    CyclicNegation { rules: Vec<String> },
7
8    #[error("undefined rule: {name}")]
9    UndefinedRule { name: String },
10
11    #[error("prev reference in non-recursive rule '{rule}', field '{field}'")]
12    PrevInBaseCase { rule: String, field: String },
13
14    #[error("non-monotonic aggregate '{aggregate}' in recursive rule '{rule}'")]
15    NonMonotonicInRecursion { rule: String, aggregate: String },
16
17    #[error("BEST BY with monotonic fold '{fold}' in rule '{rule}'")]
18    BestByWithMonotonicFold { rule: String, fold: String },
19
20    #[error("wardedness violation: variable '{variable}' in rule '{rule}' not bound by MATCH")]
21    WardednessViolation { rule: String, variable: String },
22
23    #[error("YIELD schema mismatch in rule '{rule}': {detail}")]
24    YieldSchemaMismatch { rule: String, detail: String },
25
26    #[error("mixed priority in rule '{rule}': some clauses have PRIORITY, others don't")]
27    MixedPriority { rule: String },
28
29    #[error("module not found: {name}")]
30    ModuleNotFound { name: String },
31
32    #[error("import not found: rule '{rule}' in module '{module}'")]
33    ImportNotFound { module: String, rule: String },
34
35    #[error(
36        "IS arity mismatch in rule '{rule}': reference to '{target}' provides {actual} bindings, but '{target}' yields {expected} columns"
37    )]
38    IsArityMismatch {
39        rule: String,
40        target: String,
41        expected: usize,
42        actual: usize,
43    },
44
45    #[error(
46        "prev.{field} in rule '{rule}' references unknown column; available columns from IS references: {available}"
47    )]
48    PrevFieldNotInSchema {
49        rule: String,
50        field: String,
51        available: String,
52    },
53
54    #[error("rule '{rule}' has {count} PROB columns; at most 1 is allowed")]
55    MultipleProbColumns { rule: String, count: usize },
56}