Skip to content

Commit

Permalink
[errors] Tweak some error names and messages (#1115)
Browse files Browse the repository at this point in the history
  • Loading branch information
SamChou19815 authored Oct 28, 2023
1 parent 105cda9 commit d196887
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 86 deletions.
56 changes: 28 additions & 28 deletions crates/samlang-core/src/checker/checker_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ Found 1 error.
r#"
Error ----------------------------------- DUMMY.sam:1:6-1:17
Cannot find member `helloWorld2` on `Test`.
Cannot resolve member `helloWorld2` on `Test`.
1| Test.helloWorld2
^^^^^^^^^^^
Expand Down Expand Up @@ -949,7 +949,7 @@ Found 1 error.
r#"
Error ------------------------------------ DUMMY.sam:1:6-1:9
Cannot find member `Foo` on `Test`.
Cannot resolve member `Foo` on `Test`.
1| Test.Foo(true)
^^^
Expand All @@ -965,7 +965,7 @@ Found 1 error.
r#"
Error ------------------------------------ DUMMY.sam:1:6-1:9
Cannot find member `Bar` on `Test`.
Cannot resolve member `Bar` on `Test`.
1| Test.Bar(42)
^^^
Expand Down Expand Up @@ -1063,7 +1063,7 @@ Found 2 errors.
r#"
Error ------------------------------------ DUMMY.sam:1:1-1:7
Class `Test44` is not resolved.
Cannot resolve class `Test44`.
1| Test44.Bar(42)
^^^^^^
Expand All @@ -1079,7 +1079,7 @@ Found 1 error.
r#"
Error ----------------------------------- DUMMY.sam:1:7-1:11
Cannot find member `Tars` on `Test2`.
Cannot resolve member `Tars` on `Test2`.
1| Test2.Tars(42)
^^^^
Expand Down Expand Up @@ -1143,7 +1143,7 @@ Found 1 error.
r#"
Error ---------------------------------- DUMMY.sam:1:20-1:24
Cannot find member `bazz` on `Test`.
Cannot resolve member `bazz` on `Test`.
1| Test.init(true, 3).bazz
^^^^
Expand All @@ -1159,7 +1159,7 @@ Found 1 error.
r#"
Error ---------------------------------- DUMMY.sam:1:35-1:38
Cannot find member `bar` on `Test3`.
Cannot resolve member `bar` on `Test3`.
1| { let _ = (t3: Test3<bool>) -> t3.bar; }
^^^
Expand All @@ -1175,7 +1175,7 @@ Found 1 error.
r#"
Error ---------------------------------- DUMMY.sam:1:17-1:20
Cannot find member `foo` on `Test2`.
Cannot resolve member `foo` on `Test2`.
1| Test2.Foo(true).foo
^^^
Expand Down Expand Up @@ -2756,15 +2756,15 @@ let _ = (t: Test2) -> if let Foo111(_) = t then 1 else 2;
r#"
Error ---------------------------------- DUMMY.sam:1:32-1:35
Cannot find member `bar` on `Test`.
Cannot resolve member `bar` on `Test`.
1| { let _ = (t: Test) -> if let {bar, boo} = t then 1 else 2;
^^^
Error ---------------------------------- DUMMY.sam:1:37-1:40
Cannot find member `boo` on `Test`.
Cannot resolve member `boo` on `Test`.
1| { let _ = (t: Test) -> if let {bar, boo} = t then 1 else 2;
^^^
Expand All @@ -2788,7 +2788,7 @@ Cannot access member of `Test2` at index 1.
Error ---------------------------------- DUMMY.sam:5:30-5:36
Cannot find member `Foo111` on `Test2`.
Cannot resolve member `Foo111` on `Test2`.
5| let _ = (t: Test2) -> if let Foo111(_) = t then 1 else 2;
^^^^^^
Expand All @@ -2806,15 +2806,15 @@ Found 5 errors.
r#"
Error ---------------------------------- DUMMY.sam:1:13-1:16
Cannot find member `Foo` on `int`.
Cannot resolve member `Foo` on `int`.
1| match (3) { Foo(_) -> 1, Bar(s) -> 2 }
^^^
Error ---------------------------------- DUMMY.sam:1:26-1:29
Cannot find member `Bar` on `int`.
Cannot resolve member `Bar` on `int`.
1| match (3) { Foo(_) -> 1, Bar(s) -> 2 }
^^^
Expand All @@ -2830,15 +2830,15 @@ Found 2 errors.
r#"
Error ---------------------------------- DUMMY.sam:1:30-1:33
Cannot find member `Foo` on `Test`.
Cannot resolve member `Foo` on `Test`.
1| match (Test.init(true, 3)) { Foo(_) -> 1, Bar(s) -> 2, }
^^^
Error ---------------------------------- DUMMY.sam:1:43-1:46
Cannot find member `Bar` on `Test`.
Cannot resolve member `Bar` on `Test`.
1| match (Test.init(true, 3)) { Foo(_) -> 1, Bar(s) -> 2, }
^^^
Expand All @@ -2863,7 +2863,7 @@ The match is not exhausive. The following variants have not been handled:
Error ---------------------------------- DUMMY.sam:1:50-1:53
Cannot find member `Baz` on `Test2`.
Cannot resolve member `Baz` on `Test2`.
1| { let _ = (t: Test2) -> match (t) { Foo(_) -> 1, Baz(s) -> 2, }; }
^^^
Expand Down Expand Up @@ -3007,7 +3007,7 @@ Found 2 errors.
r#"
Error ---------------------------------- DUMMY.sam:1:10-1:11
Cannot find member `b` on `A`.
Cannot resolve member `b` on `A`.
1| {let {a, b as c} = A.init();}
^
Expand All @@ -3023,15 +3023,15 @@ Found 1 error.
r#"
Error ------------------------------------ DUMMY.sam:1:7-1:8
Cannot find member `a` on `C`.
Cannot resolve member `a` on `C`.
1| {let {a, b as c} = C.init();}
^
Error ---------------------------------- DUMMY.sam:1:10-1:11
Cannot find member `b` on `C`.
Cannot resolve member `b` on `C`.
1| {let {a, b as c} = C.init();}
^
Expand All @@ -3047,15 +3047,15 @@ Found 2 errors.
r#"
Error ------------------------------------ DUMMY.sam:1:7-1:8
Cannot find member `a` on `int`.
Cannot resolve member `a` on `int`.
1| {let {a, b as c} = 1;}
^
Error ---------------------------------- DUMMY.sam:1:10-1:11
Cannot find member `b` on `int`.
Cannot resolve member `b` on `int`.
1| {let {a, b as c} = 1;}
^
Expand All @@ -3071,7 +3071,7 @@ Found 2 errors.
r#"
Error ---------------------------------- DUMMY.sam:1:10-1:11
Cannot find member `d` on `A`.
Cannot resolve member `d` on `A`.
1| {let {a, d as c} = A.init();}
^
Expand Down Expand Up @@ -3251,7 +3251,7 @@ Found 5 errors.
r#"
Error --------------------------------------- A.sam:1:1-1:20
Module `K` is not resolved.
Cannot resolve module `K`.
1| import { Z } from K
^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -3614,7 +3614,7 @@ Type parameter name mismatch. Expected exact match of `<TC>`.
Error ------------------------------------ A.sam:38:16-38:18
Name `TA` is not resolved.
Cannot resolve name `TA`.
38| method <TA1: TA, TB1, TC> f1(a: TA1, b: TB1): TC // has bound mismatch
^^
Expand Down Expand Up @@ -3654,23 +3654,23 @@ Type parameter name mismatch. Expected exact match of `<TE : Foo>`.
Error ------------------------------------ A.sam:50:34-50:35
Name `T` is not resolved.
Cannot resolve name `T`.
50| interface WithBound { method <T: T> f(): int }
^
Error ------------------------------------ A.sam:51:47-51:48
Name `T` is not resolved.
Cannot resolve name `T`.
51| interface WithBound2 : WithBound { method <T: T> f(): int }
^
Error ------------------------------------ A.sam:52:19-52:25
Name `DumDum` is not resolved.
Cannot resolve name `DumDum`.
52| class Z<T: Foo> : DumDum {} // error
^^^^^^
Expand Down Expand Up @@ -3837,7 +3837,7 @@ Error --------------------- bounded-generics.sam:28:20-28:30
Error --------------------- bounded-generics.sam:29:21-29:22
Name `T` is not resolved.
Cannot resolve name `T`.
29| class ImplTArg<T> : T {} // error: T not resolved
^
Expand Down
18 changes: 11 additions & 7 deletions crates/samlang-core/src/checker/main_checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ fn check_member_with_unresolved_tparams(
});
(partially_checked_expr, vec![])
} else {
cx.error_set.report_member_missing_error(
cx.error_set.report_cannot_resolve_member_error(
expression.field_name.loc,
Description::NominalType { name: class_id, type_args: vec![] },
expression.field_name.name,
Expand Down Expand Up @@ -940,7 +940,7 @@ fn check_match(
let mapping_data_types = match unused_mappings.remove(&tag.name) {
Some(types) => types,
None => {
cx.error_set.report_member_missing_error(
cx.error_set.report_cannot_resolve_member_error(
tag.loc,
checked_matched_type.to_description(),
tag.name,
Expand Down Expand Up @@ -1113,7 +1113,7 @@ fn check_destructuring_pattern(
{
if let Some((field_type, is_public)) = field_mappings.get(&field_name.name) {
if !is_public {
cx.error_set.report_member_missing_error(
cx.error_set.report_cannot_resolve_member_error(
field_name.loc,
pattern_type.to_description(),
field_name.name,
Expand All @@ -1131,7 +1131,7 @@ fn check_destructuring_pattern(
});
continue;
}
cx.error_set.report_member_missing_error(
cx.error_set.report_cannot_resolve_member_error(
field_name.loc,
pattern_type.to_description(),
field_name.name,
Expand Down Expand Up @@ -1208,7 +1208,7 @@ fn check_matching_pattern(
{
if let Some((field_type, is_public)) = field_mappings.get(&field_name.name) {
if !is_public {
cx.error_set.report_member_missing_error(
cx.error_set.report_cannot_resolve_member_error(
field_name.loc,
pattern_type.to_description(),
field_name.name,
Expand All @@ -1226,7 +1226,7 @@ fn check_matching_pattern(
});
continue;
}
cx.error_set.report_member_missing_error(
cx.error_set.report_cannot_resolve_member_error(
field_name.loc,
pattern_type.to_description(),
field_name.name,
Expand Down Expand Up @@ -1254,7 +1254,11 @@ fn check_matching_pattern(
let Some((tag_order, resolved_enum)) =
cx.resolve_enum_definitions(pattern_type).into_iter().find_position(|e| e.name == tag.name)
else {
cx.error_set.report_member_missing_error(tag.loc, pattern_type.to_description(), tag.name);
cx.error_set.report_cannot_resolve_member_error(
tag.loc,
pattern_type.to_description(),
tag.name,
);
let type_ = Rc::new(Type::Any(Reason::new(*loc, Some(*loc)), false));
return pattern::MatchingPattern::Variant(pattern::VariantPattern {
loc: *loc,
Expand Down
Loading

0 comments on commit d196887

Please sign in to comment.