Skip to main content

CompileError

Enum CompileError 

Source
pub enum CompileError {
Show 22 variants UnsupportedConstruct { construct: &'static str, evaluator: &'static str, detail: String, }, DoublyDefinedUnknown { name: String, differential: String, algebraic: String, }, CompilerRefusedRule { compiler: &'static str, kind: &'static str, rule: String, tier: &'static str, reason: String, }, UnsupportedFeatureError { feature: String, message: String, }, UnsupportedDimensionalityError { independent_variables: Vec<String>, }, InterpreterBuildError { details: String, }, UnloweredOperatorError { op: String, }, InvalidOperatorArity { op: String, got: usize, expected: String, }, MakearrayRegionInvalid { reason: String, }, InvalidBroadcastFn { reason: String, }, UnevaluableOperatorError { op: String, }, ValueInventionRefused { code: &'static str, reason: String, }, TableLookupLowering { code: &'static str, reason: String, }, UnsupportedElementType { element_type: String, }, Float32Unsupported { construct: String, reason: String, }, ElementTypeUncarried { construct: String, reason: String, }, MixedElementType { op: String, lhs_name: String, lhs_type: String, rhs_name: String, rhs_type: String, }, UnalignableArrayShape { operand: String, axis: String, result: String, result_axes: Vec<String>, }, ObservedCycle { cycle: Vec<String>, }, MissingData { parameter: String, detail: String, }, MissingInitialValue { slot: String, detail: String, }, Flatten(FlattenError),
}
Expand description

Errors raised when building a compiled model from a flattened system.

Variants§

§

UnsupportedConstruct

A model construct this evaluator cannot run: a continuous or discrete event, an implicit equation (an equation whose LHS is an expression rather than an unknown, D(unknown) or ic(unknown)), or a Wiener-noise parameter. esm-spec §9.6.6 unsupported_construct.

Refused at build rather than skipped: a model run without its event, or without its residual solved, reports a wrong answer, and nothing in that answer says a construct was dropped.

Fields

§construct: &'static str

Which construct: [CONTINUOUS_EVENT], [DISCRETE_EVENT], [IMPLICIT_EQUATION] or [WIENER_NOISE].

§evaluator: &'static str

Which evaluator refused it, e.g. "Rust array evaluator".

§detail: String

The offending instance: an event’s name, or an equation’s LHS.

§

DoublyDefinedUnknown

One unknown carries BOTH a derivative equation and a bare-LHS one (esm-spec §4.9.4 equation_count_mismatch).

§4.9.4 counts an equation against the unknowns “whichever form its LHS takes”, so D(x) ~ f beside x ~ g is two equations binding one unknown: the document is unbalanced, and validate reports exactly that. This crate used to tie-break in favour of the derivative, which integrates a system free of a constraint the file declares and reports the trajectory as the answer. The build is the other place that same document arrives, so it refuses under the same code.

Fields

§name: String

The unknown both equations define, spelled as the system spells it.

§differential: String

The derivative equation, rendered lhs ~ rhs.

§algebraic: String

The competing bare-LHS equation, rendered lhs ~ rhs.

§

CompilerRefusedRule

The chosen compiler cannot run one of this document’s rules (esm-spec §9.6.6 compiler_refused_rule, esm-libraries-spec §2.5.10).

Raised at CONSTRUCTION, naming the compiler, the rule — an equation or an observed, component-qualified — the cadence tier the rule would have run at, and the DEEPEST decline reason reached while trying to lower it. A refusal, never a fallback: the compiler does not run that rule on a slower path, because a caller who asked for a compiled program and got a tree walk has no way to find that out.

Fields

§compiler: &'static str

The vocabulary spelling of the compiler that refused.

§kind: &'static str

"observed" or "state derivative".

§rule: String

The rule, component-qualified.

§tier: &'static str

The cadence tier the rule would have run at: "const", "discrete" or "continuous".

§reason: String

The deepest decline reason reached while trying to lower it.

§

UnsupportedFeatureError

The flattened system contains a feature the v1 simulator does not support (e.g. a join over data-derived columns).

Fields

§feature: String

Feature name (e.g. "value-equality join over data-derived columns").

§message: String

Why this is rejected and what to do about it.

§

UnsupportedDimensionalityError

The flattened system still carries a spatial independent variable — a spatial operator that was never discretized into a faq stencil. Discretized PDEs fold their spatial axis into array dimensions, leaving independent_variables == ["t"], and simulate fine.

Fields

§independent_variables: Vec<String>

The actual independent variables found.

§

InterpreterBuildError

The interpreter could not build a callable representation of the flattened equations.

Fields

§details: String

Human-readable failure description.

§

UnloweredOperatorError

A rewrite-target operator (a spatial / right-hand-side D, or the optional sugar ops grad / div / laplacian / …) survived the lowering fixpoint into an evaluation position (esm-spec §4.2 / §9.6.8). Such ops carry NO evaluator: a discretization match rewrite rule MUST lower them to a faq / makearray stencil before evaluation. The gate fires here — before evaluation, not at load — with the uniform unlowered_operator code that supersedes the former per-binding UnreachableSpatialOperatorError / UnsupportedDimensionality errors. Silently producing zeros (the previous behavior) would mask a broken pipeline. This format ships no discretization rules — they live in EarthSciDiscretizations.

Fields

§op: String

The offending operator name (e.g. "grad" or "D").

§

InvalidOperatorArity

An evaluable-core operator (esm-spec §4.2) applied to the wrong number of arguments — e.g. atan2 with one argument, or min with fewer than two. The schema cannot express per-operator arity (args is minItems: 0), so this is the gate that keeps a malformed-but- schema-valid node out of the evaluators, where it would otherwise either panic on an out-of-bounds index or — worse — be silently assigned two different values by the per-cell oracle and the vectorized overlay. See [crate::op_registry].

Fields

§op: String

The offending operator name (e.g. "atan2").

§got: usize

How many arguments the node actually carried.

§expected: String

What the spec says the operator takes (e.g. "exactly 2").

§

MakearrayRegionInvalid

A makearray node whose regions are malformed: either the regions disagree on rank (a ragged regions list), or a bound pair is inverted beyond the legal empty spelling. Per esm-spec §4.3.2 a pair with stop == start - 1 is the canonical empty region and is legal; anything further inverted (stop < start - 1) is rejected with makearray_region_inverted.

Fields

§reason: String

What is wrong with the regions.

§

InvalidBroadcastFn

A broadcast node whose fn field is absent or does not name a scalar operator (esm-spec §4.3.4). broadcast is the one op whose OPERATOR is data — the node says broadcast, the arithmetic is named by a sibling string — and nothing used to check that string, so a typo’d or missing fn was silently evaluated as + (issue #101).

Fields

§reason: String

Why the fn is rejected.

§

UnevaluableOperatorError

An evaluable-core operator (esm-spec §4.2) that this interpreter has no evaluation rule for reached the evaluator.

These ops are legal in an AST but are eliminated before the per-cell evaluator ever runs: the build-time query ops (skolem, rank, distinct, argmin, argmax) are resolved by [crate::value_invention], and the form/lowering ops (ic, true, enum, table_lookup, apply_expression_template) are consumed by their respective lowering passes. One arriving at the evaluator means the pipeline is broken.

It is reported rather than evaluated to a NaN sentinel: a silent NaN is indistinguishable from a legitimate numerical result and would propagate into the solution, whereas the pipeline stage that should have eliminated the op is the actual defect.

Raised by the array runtime’s build gate and by the single-expression crate::expression::evaluate, whose scalar bindings additionally give the array / tensor and geometry ops no value. The invariant is the same either way: an unevaluable op is a diagnostic, never a number.

Fields

§op: String

The offending operator name (e.g. "skolem").

§

ValueInventionRefused

An expression ranges over a kind: "derived" index set whose value-invention producer could not be materialized at build (esm-spec §4.2 / §9.6.6). Refused rather than contracted as an empty range, which folds to the additive identity and reads as a plausible 0.

Fields

§code: &'static str

derived_index_set_unmaterialized, or relational_node_in_continuous when the producer reads live state.

§reason: String

The index set, its producer, and why the producer could not run.

§

TableLookupLowering

A table_lookup node that cannot be lowered to its esm-spec §9.5.3 interp.linear / interp.bilinear / index form — an unknown table, an axis-key set that does not match the table’s declared axes, an out-of-range output, or a table whose interpolation and axis count disagree.

Raised by [crate::lower_table_lookup] during the build rather than by the evaluator: unevaluable_operator would name table_lookup without saying which of the §9.5.5 conditions the document actually trips.

Fields

§code: &'static str

The esm-spec §9.5.5 diagnostic code.

§reason: String

What is wrong with this table_lookup (or the table it names).

§

UnsupportedElementType

domain.element_type names a precision this evaluator does not have.

Reported rather than defaulted to binary64: a document that asks for a precision and silently gets a different one is the same class of defect as an element_type that is accepted and then ignored.

Fields

§element_type: String

The offending element_type spelling.

§

Float32Unsupported

A construct that cannot be evaluated in binary32 appears in a document declaring domain.element_type: "Float32".

The alternative — evaluating just that construct in binary64 — is a silent fallback: the document asked for one precision and part of the answer would be computed in another, with nothing in the result to say which part. So it is an error naming the construct.

Fields

§construct: String

The offending construct, named (e.g. operator `intersect_polygon` ).

§reason: String

Why binary32 cannot carry it.

§

ElementTypeUncarried

A declared working precision reaches a construct this evaluator cannot carry it through (esm-spec §11.3.1, §4.7 “Working precision crosses a mount”).

Refused rather than evaluated in another precision: the declaration would otherwise be accepted and ignored.

Fields

§construct: String

The construct whose declared precision cannot be carried.

§reason: String

Why this evaluator cannot carry it.

§

MixedElementType

One operator’s operands carry DIFFERENT declared element types (ModelVariable.element_type, esm-spec §11.3.1).

Refused rather than resolved by a usual-arithmetic-conversions rule, because every resolution is a silent answer to a question only the author can settle. Widening to the wider operand makes a quantity declared binary32 come out binary64 — the declaration ignored, with nothing in the result to say so. Narrowing to the narrower destroys the binary64 operand, which is the very corruption per-variable element types exist to prevent (a ten-digit key rounded to binary32 collides with its neighbours). So the mix is an error naming both variables, and the author states the intent by computing the mixed step into a variable whose own element_type says which precision it is in.

Fields

§op: String

The operator whose operands disagree (or "equation" for an equation whose right-hand side disagrees with its left-hand side).

§lhs_name: String

A variable supplying the first element type.

§lhs_type: String

That variable’s element type.

§rhs_name: String

A variable supplying the conflicting element type.

§rhs_type: String

That variable’s element type.

§

UnalignableArrayShape

A BARE array-level expression whose operand is declared over an index set the result does not have (esm-spec §4.3.4).

Operands of an array-level expression align by index-set NAME: an operand declared over a SUBSET of the result’s index sets broadcasts along the ones it is missing. An operand carrying an index set the result does not carry has no axis to align to and no defensible value to take, so it is rejected rather than reinterpreted positionally — the positional flatten this replaces produced plausible, non-NaN, zero-padded garbage (issue #100).

The shapes are fully known statically, so validate() reports the same defect as an array_shape_mismatch structural error before any build is attempted; this is the build-time backstop for a model compiled without being validated first.

Fields

§operand: String

The offending operand’s variable name.

§axis: String

The index set the operand carries and the result does not.

§result: String

The name of the array-level expression’s result.

§result_axes: Vec<String>

The result’s declared index sets, in declaration order.

§

ObservedCycle

A dependency cycle among the model’s OBSERVED unknowns (esm-spec §4.9.6): each observed on the cycle is defined by an equation whose RHS names the next, so no evaluation order satisfies every definition.

The equations decide this on their own, so validate() reports the same defect as an observed_cycle structural error before any build is attempted; this is the build-time backstop for a model compiled without being validated first — and it is the reason this variant exists at all. The ordering sweep used to tolerate an unorderable rule set, appending the stuck rules in declaration order so “the build still proceeds”; what actually proceeded was a materialization pass that read an observed with no value yet and reported E_TREEWALK_UNBOUND_NAME against whichever name it reached first — routinely an observed that is declared, defined and referenced perfectly well (issue #181).

Fields

§cycle: Vec<String>

The observeds on the cycle, in traversal order, with the entry node repeated to close it (["a", "b", "a"]).

§

MissingData

A shaped parameter reached construction with no value: no default, no caller array, and — for one the document refreshes from a data source or a registered handler — no provider data either. esm-spec §10.10 makes “a parameter with neither a default nor a supplied value” an error when a problem is built. detail names what the document says feeds the parameter and how a caller supplies it.

Fields

§parameter: String

The parameter, as the compiled model names it.

§detail: String

The whole diagnostic after the code.

§

MissingInitialValue

An unknown that needs a starting value reached construction with none: no default, no initial condition or ic equation, and no caller u0 (esm-spec §11.4).

Fields

§slot: String

The first state slot with no starting value.

§detail: String

The whole diagnostic after the code.

§

Flatten(FlattenError)

The convenience constructors flattened the input first; that step failed.

Implementations§

Source§

impl CompileError

Source

pub fn build_err(details: impl Into<String>) -> Self

Shorthand constructor for CompileError::InterpreterBuildError, the catch-all build failure, whose { details: format!(…) } spelling is otherwise repeated at every raise site.

Trait Implementations§

Source§

impl Debug for CompileError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for CompileError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for CompileError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<CompileError> for SimulateError

Source§

fn from(source: CompileError) -> Self

Converts to this type from the input type.
Source§

impl From<FlattenError> for CompileError

Source§

fn from(source: FlattenError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> DistributionExt for T
where T: ?Sized,

Source§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V