Skip to main content

ParseError

Enum ParseError 

Source
pub enum ParseError {
Show 25 variants UnexpectedEOF(FileId, Vec<String>), UnexpectedToken(RawSpan, Vec<String>), ExtraToken(RawSpan), UnmatchedCloseBrace(RawSpan), InvalidEscapeSequence(RawSpan), InvalidAsciiEscapeCode(RawSpan), InvalidUnicodeEscapeCode(RawSpan), StringDelimiterMismatch { opening_delimiter: RawSpan, closing_delimiter: RawSpan, }, ExternalFormatError(String, String, Option<RawSpan>), UnboundTypeVariables(Vec<LocIdent>), InvalidRecordType { record_span: RawSpan, tail_span: Option<RawSpan>, cause: InvalidRecordTypeError, }, RecursiveLetPattern(RawSpan), PatternInLetBlock(RawSpan), TypeVariableKindMismatch { ty_var: LocIdent, span: RawSpan, }, TypedFieldWithoutDefinition { field_span: RawSpan, annot_span: RawSpan, }, InterpolationInStaticPath { input: String, path_elem_span: RawSpan, }, DuplicateIdentInRecordPattern { ident: LocIdent, prev_ident: LocIdent, }, DuplicateIdentInLetBlock { ident: LocIdent, prev_ident: LocIdent, }, DisabledFeature { feature: String, span: RawSpan, }, InvalidContract(RawSpan), InvalidImportFormat { span: RawSpan, }, SigilExprMissingColon(RawSpan), UnknownSigilSelector { selector: String, span: RawSpan, }, UnknownSigilAttribute { selector: String, attribute: String, span: RawSpan, }, MultipleFieldDecls { ident: Ident, include_span: RawSpan, other_span: RawSpan, },
}
Expand description

An error occurring during parsing.

Variants§

§

UnexpectedEOF(FileId, Vec<String>)

Unexpected end of file.

§

UnexpectedToken(RawSpan, Vec<String>)

Unexpected token.

§

ExtraToken(RawSpan)

Superfluous, unexpected token.

§

UnmatchedCloseBrace(RawSpan)

A closing brace ‘}’ does not match an opening brace ‘{’. This rather precise error is detected because of how interpolated strings are lexed.

§

InvalidEscapeSequence(RawSpan)

Invalid escape sequence in a string literal.

§

InvalidAsciiEscapeCode(RawSpan)

Invalid ASCII escape code in a string literal.

§

InvalidUnicodeEscapeCode(RawSpan)

Invalid unicode escape code in a string literal.

§

StringDelimiterMismatch

A multiline string was closed with a delimiter which has a % count higher than the opening delimiter.

Fields

§opening_delimiter: RawSpan
§closing_delimiter: RawSpan
§

ExternalFormatError(String, String, Option<RawSpan>)

Error when parsing an external format such as JSON, YAML, etc.

§

UnboundTypeVariables(Vec<LocIdent>)

Unbound type variable

§

InvalidRecordType

Illegal record type literal.

This occurs when failing to convert from the uniterm syntax to a record type literal. See RFC002 for more details.

Fields

§record_span: RawSpan

The position of the invalid record.

§tail_span: Option<RawSpan>

Position of the tail, if there was one.

§cause: InvalidRecordTypeError

The reason that interpretation as a record type failed.

§

RecursiveLetPattern(RawSpan)

A recursive let pattern was encountered. They are not currently supported because we decided it was too involved to implement them.

§

PatternInLetBlock(RawSpan)

Let blocks can currently only contain plain bindings, not pattern bindings.

§

TypeVariableKindMismatch

A type variable is used in ways that imply it has muiltiple different kinds.

This can happen in several situations, for example:

  • a variable is used as both a type variable and a row type variable, e.g. in the signature forall r. { ; r } -> r,
  • a variable is used as both a record and enum row variable, e.g. in the signature forall r. [| ; r |] -> { ; r }.

Fields

§ty_var: LocIdent
§span: RawSpan
§

TypedFieldWithoutDefinition

A record literal, which isn’t a record type, has a field with a type annotation but without a definition. While we could technically handle this situation, this is most probably an error from the user, because this type annotation is useless and, maybe non-intuitively, won’t have any effect as part of a larger contract:

let MixedContract = {foo : String, bar | Number} in
{ foo = 1, bar = 2} | MixedContract

This example works, because the foo : String annotation doesn’t propagate, and contract application is mostly merging, which is probably not the intent. It might become a warning in a future version, but we don’t have warnings for now, so we rather forbid such constructions.

Fields

§field_span: RawSpan

The position of the field definition.

§annot_span: RawSpan

The position of the type annotation.

§

InterpolationInStaticPath

The user provided a field path on the CLI, which is expected to be only composed of literals, but the parsed field path contains string interpolation.

Fields

§input: String
§path_elem_span: RawSpan
§

DuplicateIdentInRecordPattern

A duplicate binding was encountered in a record destructuring pattern.

Fields

§ident: LocIdent

The duplicate identifier.

§prev_ident: LocIdent

The previous instance of the duplicated identifier.

§

DuplicateIdentInLetBlock

A duplicate binding was encountered in a let block.

Fields

§ident: LocIdent

The duplicate identifier.

§prev_ident: LocIdent

The previous instance of the duplicated identifier.

§

DisabledFeature

There was an attempt to use a feature that hasn’t been enabled.

Fields

§feature: String
§span: RawSpan
§

InvalidContract(RawSpan)

A term was used as a contract in type position, but this term has no chance to make any sense as a contract. What terms make sense might evolve with time, but any given point in time, there are a set of expressions that can be excluded syntactically. Currently, it’s mostly constants.

§

InvalidImportFormat

Unrecognized explicit import format tag

Fields

§span: RawSpan
§

SigilExprMissingColon(RawSpan)

A CLI sigil expression such as @env:FOO is invalid because no : separator was found.

§

UnknownSigilSelector

A CLI sigil expression is unknown or unsupported, such as @unknown:value.

Fields

§selector: String
§span: RawSpan
§

UnknownSigilAttribute

A CLI sigil attribute is unknown or unsupported, such as @file/unsupported:value.

Fields

§selector: String
§attribute: String
§span: RawSpan
§

MultipleFieldDecls

An included field has several definitions. While we could just merge both at runtime like a piecewise field definition, we entirely forbid this situation for now.

Fields

§ident: Ident

The identifier.

§include_span: RawSpan

The identifier and the position of the include expression. The ident part is the same as the ident part of ident.

§other_span: RawSpan

The span of the other declaration, which can be either a field definition or an include expression as well.

Implementations§

Source§

impl ParseError

Source

pub fn from_serde_json(error: Error, location: Option<(FileId, &Files)>) -> Self

Source

pub fn from_yaml(error: ScanError, file_id: Option<FileId>) -> Self

Source

pub fn from_toml(error: TomlError, file_id: FileId) -> Self

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<T> From<ParseError> for ParseError<usize, T, ParseOrLexError>

Source§

fn from(e: ParseError) -> Self

Converts to this type from the input type.
Source§

impl From<ParseError> for ParseErrors

Source§

fn from(e: ParseError) -> ParseErrors

Converts to this type from the input type.
Source§

impl From<ParseError> for ParseOrLexError

Source§

fn from(e: ParseError) -> Self

Converts to this type from the input type.
Source§

impl From<UnboundTypeVariableError> for ParseError

Source§

fn from(err: UnboundTypeVariableError) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for ParseError

Source§

fn eq(&self, other: &ParseError) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for ParseError

Source§

impl StructuralPartialEq for ParseError

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

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

Source§

fn exact_from(value: T) -> U

Source§

impl<T, U> ExactInto<U> for T
where U: ExactFrom<T>,

Source§

fn exact_into(self) -> U

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> 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, U> OverflowingInto<U> for T
where U: OverflowingFrom<T>,

Source§

impl<T, U> RoundingInto<U> for T
where U: RoundingFrom<T>,

Source§

impl<T, U> SaturatingInto<U> for T
where U: SaturatingFrom<T>,

Source§

impl<T> ToDebugString for T
where T: Debug,

Source§

fn to_debug_string(&self) -> String

Returns the String produced by Ts Debug implementation.

§Examples
use malachite_base::strings::ToDebugString;

assert_eq!([1, 2, 3].to_debug_string(), "[1, 2, 3]");
assert_eq!(
    [vec![2, 3], vec![], vec![4]].to_debug_string(),
    "[[2, 3], [], [4]]"
);
assert_eq!(Some(5).to_debug_string(), "Some(5)");
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, U> TryConvert<'_, T> for U
where U: TryFrom<T>,

Source§

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

Source§

fn try_convert( _: &AstAlloc, from: T, ) -> Result<U, <U as TryConvert<'_, T>>::Error>

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.
Source§

impl<T, U> WrappingInto<U> for T
where U: WrappingFrom<T>,

Source§

fn wrapping_into(self) -> U