Skip to content

Commit

Permalink
fix: Fix lexer error formatting (#3274)
Browse files Browse the repository at this point in the history
  • Loading branch information
jfecher authored and guipublic committed Oct 26, 2023
1 parent 95dc22c commit 3a8e7b7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
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

0 comments on commit 3a8e7b7

Please sign in to comment.