#[non_exhaustive]pub enum EvalError {
Show 13 variants
UndefinedVar(String),
TypeError(String),
AttrNotFound(String),
TypeMismatch {
expected: &'static str,
got: &'static str,
},
AssertionFailed(String),
DivisionByZero,
InfiniteRecursion(String),
IoError {
context: String,
message: String,
},
Throw(String),
Abort(String),
NotImplemented(String),
ParseError(String),
RecursionLimit(String),
}Expand description
Evaluation errors produced by the Nix evaluator.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
UndefinedVar(String)
A variable was referenced but not bound in scope.
TypeError(String)
A type mismatch or coercion failure.
AttrNotFound(String)
An attribute was selected from a set that does not contain it.
TypeMismatch
A type mismatch with structured expected/got information.
AssertionFailed(String)
An assert expression’s condition evaluated to false.
DivisionByZero
Integer division by zero.
InfiniteRecursion(String)
Infinite recursion detected (thunk blackhole or eval depth).
IoError
An I/O error from the host filesystem.
Throw(String)
Explicit throw from Nix code — CATCHABLE by builtins.tryEval.
Abort(String)
An abort from Nix code — UNCATCHABLE (CppNix’s abort/builtins.abort
is a hard error tryEval does NOT catch, unlike throw/assert).
Verified: nix eval '(builtins.tryEval (abort "x")).success' errors.
NotImplemented(String)
A language feature that is not yet implemented.
ParseError(String)
A syntax error in the input expression.
RecursionLimit(String)
Maximum recursion depth exceeded.
Implementations§
Source§impl EvalError
impl EvalError
Sourcepub fn type_error(msg: impl Into<String>) -> Self
pub fn type_error(msg: impl Into<String>) -> Self
Convenience constructor for a TypeError variant.
Sourcepub fn type_mismatch(expected: &'static str, got: &'static str) -> Self
pub fn type_mismatch(expected: &'static str, got: &'static str) -> Self
Convenience constructor for a TypeMismatch variant.
Sourcepub fn builtin_type(builtin: &str, expected: &str, got: &str) -> Self
pub fn builtin_type(builtin: &str, expected: &str, got: &str) -> Self
Create a type error for a builtin argument type mismatch.
Sourcepub fn op_type(op: &str, lhs: &str, rhs: &str) -> Self
pub fn op_type(op: &str, lhs: &str, rhs: &str) -> Self
Create a type error for a binary operator type mismatch.
CARRIES THE EVAL FILE (added 2026-07-20). Every arithmetic/comparison
raise site routes through here, and none of them appended
eval_file_ctx() — unlike the ~12 sibling raise sites in eval.rs that
do — so an operator type error named no file at all. Nor could the frame
stack help: NixTraceGuard::drop pops every frame during unwind, so by
the time the error surfaces attach_trace has nothing left to attach.
The cost of that was concrete. “cannot add string and null” was the sole
symptom of the ident-cache aliasing bug that stopped sui evaluating
nixpkgs, and it pointed nowhere: four parallel investigations each spent
most of their budget just locating it, and the only tool that worked was
SUI_TRACE_EVAL=1 dumping 521k lines to be read backwards. One
format! argument here would have named make-derivation.nix
immediately.
Fixing it in op_type rather than at the Add arm means every operator
— add, sub, mul, div, comparison, update — gains the context at once,
instead of the next one to bite us needing its own patch.
Sourcepub fn is_infinite_recursion(&self) -> bool
pub fn is_infinite_recursion(&self) -> bool
Whether this error is an infinite recursion.
Trait Implementations§
impl Eq for EvalError
Source§impl Error for EvalError
impl Error for EvalError
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()
impl StructuralPartialEq for EvalError
Auto Trait Implementations§
impl Freeze for EvalError
impl RefUnwindSafe for EvalError
impl Send for EvalError
impl Sync for EvalError
impl Unpin for EvalError
impl UnsafeUnpin for EvalError
impl UnwindSafe for EvalError
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> ErrorExt for T
impl<T> ErrorExt for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.