From 8557aa5c251b174bd608267d01c734a5ba12e0fd Mon Sep 17 00:00:00 2001 From: Jake Fecher Date: Tue, 24 Oct 2023 11:14:42 -0500 Subject: [PATCH] Fix lexer error formatting --- compiler/noirc_frontend/src/lexer/errors.rs | 10 +++++----- compiler/noirc_frontend/src/parser/errors.rs | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/compiler/noirc_frontend/src/lexer/errors.rs b/compiler/noirc_frontend/src/lexer/errors.rs index 9bc9a820239..a2a4056f1d0 100644 --- a/compiler/noirc_frontend/src/lexer/errors.rs +++ b/compiler/noirc_frontend/src/lexer/errors.rs @@ -11,15 +11,15 @@ use thiserror::Error; pub enum LexerErrorKind { #[error("An unexpected character {:?} was found.", found)] UnexpectedCharacter { span: Span, expected: String, found: Option }, - #[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 }, diff --git a/compiler/noirc_frontend/src/parser/errors.rs b/compiler/noirc_frontend/src/parser/errors.rs index 0c0d4e7645c..b9b11d8c99e 100644 --- a/compiler/noirc_frontend/src/parser/errors.rs +++ b/compiler/noirc_frontend/src/parser/errors.rs @@ -128,7 +128,7 @@ impl std::fmt::Display for ParserError { impl From for Diagnostic { fn from(error: ParserError) -> Diagnostic { - match &error.reason { + match error.reason { Some(reason) => { match reason { ParserErrorReason::ConstrainDeprecated => Diagnostic::simple_error( @@ -146,11 +146,11 @@ impl From 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) } }