snix/tvix/eval/src/errors.rs
Vincent Ambo 342b233a0a feat(tvix/eval): add local identifier access
This makes basic `let ... in ...` statements work correctly. It does
not yet account for the call frames pushed into the VM during function
application.

Change-Id: I67155171daf1a43011b96716dd9d1ab04b27db33
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6190
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
2022-08-28 17:50:34 +00:00

43 lines
854 B
Rust

use std::fmt::Display;
#[derive(Debug)]
pub enum Error {
DuplicateAttrsKey {
key: String,
},
InvalidKeyType {
given: &'static str,
},
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>;