Skip to content

Commit

Permalink
Unify error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
asterite committed Jul 5, 2024
1 parent 2a68af8 commit 1dcd073
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion compiler/noirc_frontend/src/hir/type_check/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub enum Source {
pub enum TypeCheckError {
#[error("Operator {op:?} cannot be used in a {place:?}")]
OpCannotBeUsed { op: HirBinaryOp, place: &'static str, span: Span },
#[error("The literal `{expr:?}` cannot fit into `{ty}` which has range `{range}`")]
#[error("The value `{expr:?}` cannot fit into `{ty}` which has range `{range}`")]
OverflowingAssignment { expr: FieldElement, ty: Type, range: String, span: Span },
#[error("Type {typ:?} cannot be used in a {place:?}")]
TypeCannotBeUsed { typ: Type, place: &'static str, span: Span },
Expand Down
8 changes: 4 additions & 4 deletions compiler/noirc_frontend/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1920,7 +1920,7 @@ fn overflowing_u8() {
if let CompilationError::TypeError(error) = &errors[0].0 {
assert_eq!(
error.to_string(),
"The literal `2⁸` cannot fit into `u8` which has range `0..=255`"
"The value `2⁸` cannot fit into `u8` which has range `0..=255`"
);
} else {
panic!("Expected OverflowingAssignment error, got {:?}", errors[0].0);
Expand All @@ -1939,7 +1939,7 @@ fn underflowing_u8() {
if let CompilationError::TypeError(error) = &errors[0].0 {
assert_eq!(
error.to_string(),
"The literal `-1` cannot fit into `u8` which has range `0..=255`"
"The value `-1` cannot fit into `u8` which has range `0..=255`"
);
} else {
panic!("Expected OverflowingAssignment error, got {:?}", errors[0].0);
Expand All @@ -1958,7 +1958,7 @@ fn overflowing_i8() {
if let CompilationError::TypeError(error) = &errors[0].0 {
assert_eq!(
error.to_string(),
"The literal `2⁷` cannot fit into `i8` which has range `-128..=127`"
"The value `2⁷` cannot fit into `i8` which has range `-128..=127`"
);
} else {
panic!("Expected OverflowingAssignment error, got {:?}", errors[0].0);
Expand All @@ -1977,7 +1977,7 @@ fn underflowing_i8() {
if let CompilationError::TypeError(error) = &errors[0].0 {
assert_eq!(
error.to_string(),
"The literal `-129` cannot fit into `i8` which has range `-128..=127`"
"The value `-129` cannot fit into `i8` which has range `-128..=127`"
);
} else {
panic!("Expected OverflowingAssignment error, got {:?}", errors[0].0);
Expand Down

0 comments on commit 1dcd073

Please sign in to comment.