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("post-FOLD WHERE in rule '{rule}' requires a FOLD clause")]
21    HavingWithoutFold { rule: String },
22
23    #[error("wardedness violation: variable '{variable}' in rule '{rule}' not bound by MATCH")]
24    WardednessViolation { rule: String, variable: String },
25
26    #[error("YIELD schema mismatch in rule '{rule}': {detail}")]
27    YieldSchemaMismatch { rule: String, detail: String },
28
29    #[error("mixed priority in rule '{rule}': some clauses have PRIORITY, others don't")]
30    MixedPriority { rule: String },
31
32    #[error("module not found: {name}")]
33    ModuleNotFound { name: String },
34
35    #[error("import not found: rule '{rule}' in module '{module}'")]
36    ImportNotFound { module: String, rule: String },
37
38    #[error(
39        "IS arity mismatch in rule '{rule}': reference to '{target}' provides {actual} bindings, but '{target}' yields {expected} columns"
40    )]
41    IsArityMismatch {
42        rule: String,
43        target: String,
44        expected: usize,
45        actual: usize,
46    },
47
48    #[error(
49        "prev.{field} in rule '{rule}' references unknown column; available columns from IS references: {available}"
50    )]
51    PrevFieldNotInSchema {
52        rule: String,
53        field: String,
54        available: String,
55    },
56
57    #[error("rule '{rule}' has {count} PROB columns; at most 1 is allowed")]
58    MultipleProbColumns { rule: String, count: usize },
59}