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.
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.
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
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”.
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.
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.
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
impl Clone for ParseError
Source§fn clone(&self) -> ParseError
fn clone(&self) -> ParseError
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ParseError
impl Debug for ParseError
Source§impl Display for ParseError
impl Display for ParseError
Source§impl Error for ParseError
impl Error for ParseError
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()
Source§impl From<ParseError> for InterfaceError
impl From<ParseError> for InterfaceError
Source§fn from(e: ParseError) -> InterfaceError
fn from(e: ParseError) -> InterfaceError
Auto Trait Implementations§
impl Freeze for ParseError
impl RefUnwindSafe for ParseError
impl Send for ParseError
impl Sync for ParseError
impl Unpin for ParseError
impl UnsafeUnpin for ParseError
impl UnwindSafe for ParseError
Blanket Implementations§
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,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.