Skip to content

Commit

Permalink
[misc] Fix typo in error messages (#1184)
Browse files Browse the repository at this point in the history
  • Loading branch information
SamChou19815 authored Feb 25, 2024
1 parent 63268d4 commit bf0509e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions crates/samlang-checker/src/checker_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3020,7 +3020,7 @@ Found 3 errors.
r#"
Error ---------------------------------- DUMMY.sam:1:25-1:64
This pattern-matching is not exhausive.
This pattern-matching is not exhaustive.
Here is an example of a non-matching value: `Bar(_)`.
1| { let _ = (t: Test2) -> match (t) { Foo(_) -> 1, Baz(s) -> 2, }; }
Expand Down Expand Up @@ -3267,7 +3267,7 @@ Found 1 error.
r#"
Error ----------------------------------- DUMMY.sam:1:6-1:12
This pattern-matching is not exhausive.
This pattern-matching is not exhaustive.
Here is an example of a non-matching value: `Bar(_)`.
1| {let Foo(_) = Test2.Foo(false);}
Expand Down
2 changes: 1 addition & 1 deletion crates/samlang-checker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mod checker_tests;
mod global_signature;
/// The main checker that connects everything together.
mod main_checker;
/// The module that verify the usefulness and exhausiveness of patterns.
/// The module that verify the usefulness and exhaustiveness of patterns.
mod pattern_matching;
/// Computing the SSA graph.
mod ssa_analysis;
Expand Down
10 changes: 5 additions & 5 deletions crates/samlang-checker/src/main_checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,7 @@ fn check_match(
if let Some(description) =
pattern_matching::incomplete_counterexample(cx, &abstract_pattern_nodes)
{
cx.error_set.report_non_exhausive_match_error(expression.common.loc, description);
cx.error_set.report_non_exhaustive_match_error(expression.common.loc, description);
}
expr::E::Match(expr::Match {
common: expression.common.with_new_type(Rc::new(
Expand Down Expand Up @@ -1224,7 +1224,7 @@ fn check_matching_pattern(
abstract_pattern_nodes.push(abstract_node);
}
if fields.len() > checked_destructured_names.len() {
cx.error_set.report_non_exhausive_tuple_binding_error(
cx.error_set.report_non_exhaustive_tuple_binding_error(
*pattern_loc,
fields.len(),
checked_destructured_names.len(),
Expand Down Expand Up @@ -1318,7 +1318,7 @@ fn check_matching_pattern(
abstract_pattern_nodes[*field_order] = abstract_node;
}
if !not_mentioned_fields.is_empty() {
cx.error_set.report_non_exhausive_struct_binding_error(
cx.error_set.report_non_exhaustive_struct_binding_error(
*pattern_loc,
not_mentioned_fields.into_iter().collect(),
);
Expand Down Expand Up @@ -1418,7 +1418,7 @@ fn check_matching_pattern(
(0, None)
};
if resolved_enum_variant.types.len() > checked_data_variables_len {
cx.error_set.report_non_exhausive_tuple_binding_error(
cx.error_set.report_non_exhaustive_tuple_binding_error(
*loc,
resolved_enum_variant.types.len(),
checked_data_variables_len,
Expand Down Expand Up @@ -1487,7 +1487,7 @@ fn check_statement(
if let Some(description) =
pattern_matching::incomplete_counterexample(cx, &[abstract_pattern_node])
{
cx.error_set.report_non_exhausive_match_error(*checked_pattern.loc(), description);
cx.error_set.report_non_exhaustive_match_error(*checked_pattern.loc(), description);
}
expr::DeclarationStatement {
loc: *loc,
Expand Down
34 changes: 17 additions & 17 deletions crates/samlang-errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,9 +586,9 @@ pub enum ErrorDetail {
MissingClassMemberDefinitions { missing_definitions: Vec<PStr> },
MissingExport { module_reference: ModuleReference, name: PStr },
NameAlreadyBound { name: PStr, old_loc: Location },
NonExhausiveStructBinding { missing_bindings: Vec<PStr> },
NonExhausiveTupleBinding { expected_count: usize, actual_count: usize },
NonExhausiveMatch { counter_example: Description },
NonExhaustiveStructBinding { missing_bindings: Vec<PStr> },
NonExhaustiveTupleBinding { expected_count: usize, actual_count: usize },
NonExhaustiveMatch { counter_example: Description },
NotAnEnum { description: Description },
NotAStruct { description: Description },
Stacked(StackableError),
Expand Down Expand Up @@ -678,7 +678,7 @@ impl ErrorDetail {
printable_stream.push_location(old_loc);
printable_stream.push_text(".");
}
ErrorDetail::NonExhausiveStructBinding { missing_bindings } => {
ErrorDetail::NonExhaustiveStructBinding { missing_bindings } => {
printable_stream.push_text(
"The pattern does not bind all fields. The following names have not been mentioned:",
);
Expand All @@ -688,17 +688,17 @@ impl ErrorDetail {
printable_stream.push_text("`");
}
}
ErrorDetail::NonExhausiveTupleBinding { expected_count, actual_count } => {
ErrorDetail::NonExhaustiveTupleBinding { expected_count, actual_count } => {
printable_stream
.push_text("The pattern does not bind all fields. Expected number of elements: ");
printable_stream.push_size(*expected_count);
printable_stream.push_text(", actual number of elements: ");
printable_stream.push_size(*actual_count);
printable_stream.push_text(".");
}
ErrorDetail::NonExhausiveMatch { counter_example } => {
ErrorDetail::NonExhaustiveMatch { counter_example } => {
printable_stream.push_text(
"This pattern-matching is not exhausive.\nHere is an example of a non-matching value: `",
"This pattern-matching is not exhaustive.\nHere is an example of a non-matching value: `",
);
printable_stream.push_description(counter_example);
printable_stream.push_text("`.");
Expand Down Expand Up @@ -1014,25 +1014,25 @@ impl ErrorSet {
self.report_error(new_loc, ErrorDetail::NameAlreadyBound { name, old_loc })
}

pub fn report_non_exhausive_struct_binding_error(
pub fn report_non_exhaustive_struct_binding_error(
&mut self,
loc: Location,
missing_bindings: Vec<PStr>,
) {
self.report_error(loc, ErrorDetail::NonExhausiveStructBinding { missing_bindings })
self.report_error(loc, ErrorDetail::NonExhaustiveStructBinding { missing_bindings })
}

pub fn report_non_exhausive_tuple_binding_error(
pub fn report_non_exhaustive_tuple_binding_error(
&mut self,
loc: Location,
expected_count: usize,
actual_count: usize,
) {
self.report_error(loc, ErrorDetail::NonExhausiveTupleBinding { expected_count, actual_count })
self.report_error(loc, ErrorDetail::NonExhaustiveTupleBinding { expected_count, actual_count })
}

pub fn report_non_exhausive_match_error(&mut self, loc: Location, counter_example: Description) {
self.report_error(loc, ErrorDetail::NonExhausiveMatch { counter_example })
pub fn report_non_exhaustive_match_error(&mut self, loc: Location, counter_example: Description) {
self.report_error(loc, ErrorDetail::NonExhaustiveMatch { counter_example })
}

pub fn report_not_an_enum_error(&mut self, loc: Location, description: Description) {
Expand Down Expand Up @@ -1207,12 +1207,12 @@ Found 2 errors."#
heap.alloc_str_for_test("bar"),
);
error_set.report_name_already_bound_error(Location::dummy(), PStr::LOWER_A, Location::dummy());
error_set.report_non_exhausive_struct_binding_error(
error_set.report_non_exhaustive_struct_binding_error(
Location::dummy(),
vec![PStr::UPPER_A, PStr::UPPER_B],
);
error_set.report_non_exhausive_tuple_binding_error(Location::dummy(), 7, 4);
error_set.report_non_exhausive_match_error(Location::dummy(), Description::IntType);
error_set.report_non_exhaustive_tuple_binding_error(Location::dummy(), 7, 4);
error_set.report_non_exhaustive_match_error(Location::dummy(), Description::IntType);
error_set.report_not_an_enum_error(Location::dummy(), Description::IntType);
error_set.report_not_a_struct_error(Location::dummy(), Description::IntType);
error_set.report_stackable_error(Location::dummy(), {
Expand Down Expand Up @@ -1321,7 +1321,7 @@ The pattern does not bind all fields. Expected number of elements: 7, actual num
Error ------------------------------------ DUMMY.sam:0:0-0:0
This pattern-matching is not exhausive.
This pattern-matching is not exhaustive.
Here is an example of a non-matching value: `int`.
Expand Down
Binary file modified packages/samlang-website/src/components/samlang_wasm_bg.wasm
Binary file not shown.

0 comments on commit bf0509e

Please sign in to comment.