pub struct SyntaxError {
pub message: String,
pub span: Span,
pub positionless: bool,
}Expand description
A syntax error produced while scanning or parsing.
The message vocabulary follows the upstream QuickJS parser wherever a test
observes it (unexpected character, unterminated string literal, …) so
that the differential harness can compare messages once the parser lands.
Fields§
§message: StringHuman readable message (no position prefix).
span: SpanWhere the error happened.
positionless: boolWhether the reference reports this error without a position.
Almost every syntax error is printed as SyntaxError: <message> followed by
at <file>:<line>:<column>. A handful are not, and the difference is not
cosmetic: the reference raises them from js_resolve_module, after parsing has
succeeded, so there is no position to give —
export {a} with no a prints a bare SyntaxError: exported variable 'a' does not exist. Our parser makes that check itself (it has the declared names in
hand), so it has to say “report me like a link error” explicitly.
Implementations§
Source§impl SyntaxError
impl SyntaxError
Sourcepub fn positionless(self) -> LexError
pub fn positionless(self) -> LexError
Mark this error as one the reference reports without a position.
Trait Implementations§
Source§impl Clone for SyntaxError
impl Clone for SyntaxError
Source§impl Debug for SyntaxError
impl Debug for SyntaxError
Source§impl Display for SyntaxError
impl Display for SyntaxError
impl Eq for SyntaxError
Source§impl Error for SyntaxError
impl Error for SyntaxError
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()