We're confident that we're handling all branches that can reasonably occur from valid AST, any other cases should be considered a critical evaluator bug and panic rather than surfacing something that looks like user error. Change-Id: If96966eb32b8ff12fcaeb9ea3b0c8fc51b6abd11 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6205 Reviewed-by: grfn <grfn@gws.fyi> Tested-by: BuildkiteCI
39 lines
796 B
Rust
39 lines
796 B
Rust
use std::fmt::Display;
|
|
|
|
#[derive(Debug)]
|
|
pub enum Error {
|
|
DuplicateAttrsKey {
|
|
key: String,
|
|
},
|
|
|
|
AttributeNotFound {
|
|
name: String,
|
|
},
|
|
|
|
TypeError {
|
|
expected: &'static str,
|
|
actual: &'static str,
|
|
},
|
|
|
|
Incomparable {
|
|
lhs: &'static str,
|
|
rhs: &'static str,
|
|
},
|
|
|
|
// Resolving a user-supplied path literal failed in some way.
|
|
PathResolution(String),
|
|
|
|
// Dynamic keys are not allowed in let.
|
|
DynamicKeyInLet(rnix::SyntaxNode),
|
|
|
|
// Unknown variable in statically known scope.
|
|
UnknownStaticVariable(rnix::types::Ident),
|
|
}
|
|
|
|
impl Display for Error {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
writeln!(f, "{:?}", self)
|
|
}
|
|
}
|
|
|
|
pub type EvalResult<T> = Result<T, Error>;
|