Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix lexer error formatting #3274

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions compiler/noirc_frontend/src/lexer/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ use thiserror::Error;
pub enum LexerErrorKind {
#[error("An unexpected character {:?} was found.", found)]
UnexpectedCharacter { span: Span, expected: String, found: Option<char> },
#[error("NotADoubleChar : {:?} is not a double char token", found)]
#[error("Internal error: Tried to lex {:?} as a double char token", found)]
NotADoubleChar { span: Span, found: Token },
#[error("InvalidIntegerLiteral : {:?} is not a integer", found)]
#[error("Invalid integer literal, {:?} is not a integer", found)]
InvalidIntegerLiteral { span: Span, found: String },
#[error("MalformedFuncAttribute : {:?} is not a valid attribute", found)]
#[error("{:?} is not a valid attribute", found)]
MalformedFuncAttribute { span: Span, found: String },
#[error("TooManyBits")]
#[error("Integer type is larger than the maximum supported size of u127")]
TooManyBits { span: Span, max: u32, got: u32 },
#[error("LogicalAnd used instead of bitwise and")]
#[error("Logical and used instead of bitwise and")]
LogicalAnd { span: Span },
#[error("Unterminated block comment")]
UnterminatedBlockComment { span: Span },
Expand Down
8 changes: 4 additions & 4 deletions compiler/noirc_frontend/src/parser/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl std::fmt::Display for ParserError {

impl From<ParserError> for Diagnostic {
fn from(error: ParserError) -> Diagnostic {
match &error.reason {
match error.reason {
Some(reason) => {
match reason {
ParserErrorReason::ConstrainDeprecated => Diagnostic::simple_error(
Expand All @@ -146,11 +146,11 @@ impl From<ParserError> for Diagnostic {
"".into(),
error.span,
),
reason @ ParserErrorReason::ExpectedPatternButFoundType(ty) => {
Diagnostic::simple_error(reason.to_string(), format!("{ty} is a type and cannot be used as a variable name"), error.span)
ParserErrorReason::ExpectedPatternButFoundType(ty) => {
Diagnostic::simple_error("Expected a ; separating these two statements".into(), format!("{ty} is a type and cannot be used as a variable name"), error.span)
}
ParserErrorReason::Lexer(error) => error.into(),
other => {

Diagnostic::simple_error(format!("{other}"), String::new(), error.span)
}
}
Expand Down