Skip to main content

ParseError

Enum ParseError 

Source
pub enum ParseError {
Show 18 variants UnexpectedEof, UnknownCommand(String), Expected { expected: String, found: String, }, InvalidIdent(String), AmbiguousName { written: String, candidates: Vec<String>, }, UnbalancedDocument { unclosed: Vec<String>, overclosed: usize, }, UnknownNamespace(String), InvalidNumber(String), Missing(String), TrailingInput { at: usize, rest: String, }, MacroDepth { limit: usize, }, Unsupported { what: String, why: String, }, MissingEitherClause, MissingVariantName, InvalidConsiderSyntax(String), MissingYield, MissingWhenClause, UnclosedConsiderBlock,
}
Expand description

Parse errors for the Vernacular.

Variants§

§

UnexpectedEof

Unexpected end of input.

§

UnknownCommand(String)

Unknown command keyword.

§

Expected

Expected a specific token.

Fields

§expected: String
§found: String
§

InvalidIdent(String)

Invalid identifier.

§

AmbiguousName

One short name, two or more declared constants, at the same resolution priority.

★ AN AMBIGUOUS NAME IS REPORTED, NEVER PICKED. This is the failure mode the audit called the dangerous one: the prelude already owns Nat, Zero, Succ, Eq, True, False and forty more, so a short name written under an open did not fail to resolve — it resolved to the PRELUDE’s constant and nothing said a word. Both readings type-check and they are different theorems. Lean errors here; we error here and name BOTH candidates, because “ambiguous” without the list is a puzzle rather than a diagnosis.

Fields

§written: String
§candidates: Vec<String>
§

UnbalancedDocument

A document ended in a different scope than it started in.

★ A DOCUMENT IS BALANCED. Namespace N. with no End N. is the quietest failure this surface has: every declaration after it is written into N, nothing is reported, and the file still checks. Lean does NOT refuse one — measured on lean 4.14.0, a file that ends inside namespace N compiles without a word, because a Lean MODULE’s scopes close at its end and the next file starts clean. A document here is not a module: it is handed to a live session that goes on executing commands after it, so an unclosed Namespace N. keys every later one into N and says nothing. The balance rule is therefore ours and deliberate, and the reason is the session rather than Lean. It is stated as BALANCE and not as “empty at the end”, so a caller that was already inside a namespace when it handed the door a document is not punished for it — and a document that closes a scope it did not open is the same mistake pointing the other way.

Fields

§unclosed: Vec<String>

Scopes the document opened and never closed, outermost first.

§overclosed: usize

How many of the CALLER’s scopes the document closed.

§

UnknownNamespace(String)

Open Typo. where nothing has ever been declared into Typo.

An open that brings in NOTHING is indistinguishable from one that worked, and every short name written under it then quietly denotes the root’s constant. Lean refuses an unknown namespace; so do we.

§

InvalidNumber(String)

Invalid number literal.

§

Missing(String)

Missing required component.

§

TrailingInput

A complete term was parsed but input remained after it.

★ THE KERNEL MUST NOT ACCEPT A PREFIX. Parsing one term and discarding whatever followed meant Check Nat -> Nat garbage here checked Nat -> Nat and reported success about a claim nobody made. Every other component here can afford leniency and be merely wrong; this is the one that answers “is this proved”.

Fields

§rest: String
§

MacroDepth

A macro expansion did not reach a fixpoint within the step budget.

A recursive macro_rules whose base case is unreachable must FAIL, loudly and at a stated limit, rather than spin — an expander that hangs is indistinguishable from a kernel that is thinking hard.

Fields

§limit: usize
§

Unsupported

A construct the vernacular REFUSES by name, with the reason.

The distinction that matters is refused-versus-MISPARSED. Inductive Colour := red : Colour deriving BEq. used to be accepted, registering red at type ((Colour deriving) BEq) — a constructor whose declared type applies the inductive to two globals that are not in the context at all. That is strictly worse than rejecting the file: it is a declaration that names things which do not exist.

Fields

§what: String
§

MissingEitherClause

Missing “is either” clause in inductive definition.

§

MissingVariantName

Missing variant name in inductive definition.

§

InvalidConsiderSyntax(String)

Invalid Consider/When/Yield syntax.

§

MissingYield

Missing Yield in function body.

§

MissingWhenClause

Missing When clause in Consider block.

§

UnclosedConsiderBlock

Unclosed Consider block.

Trait Implementations§

Source§

impl Clone for ParseError

Source§

fn clone(&self) -> ParseError

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ParseError

Source§

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

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

impl Display for ParseError

Source§

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

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

impl Error for ParseError

1.30.0 · 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<ParseError> for InterfaceError

Source§

fn from(e: ParseError) -> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.