Improve error messages involving ignored variables

Fix #3987
This commit is contained in:
Ajai Nelson 2023-05-23 23:22:52 -04:00 committed by Ajai Nelson
parent 10dd57d45d
commit 2e5fef5231
No known key found for this signature in database
GPG key ID: 8B74EF43FD4CCEFF
14 changed files with 289 additions and 46 deletions

View file

@ -335,7 +335,11 @@ impl Problem {
})
| Problem::RuntimeError(RuntimeError::UnsupportedPattern(region))
| Problem::RuntimeError(RuntimeError::MalformedPattern(_, region))
| Problem::RuntimeError(RuntimeError::LookupNotInScope(Loc { region, .. }, _))
| Problem::RuntimeError(RuntimeError::LookupNotInScope {
loc_name: Loc { region, .. },
suggestion_options: _,
underscored_suggestion_region: _,
})
| Problem::RuntimeError(RuntimeError::OpaqueNotDefined {
usage: Loc { region, .. },
..
@ -505,7 +509,14 @@ pub enum RuntimeError {
UnresolvedTypeVar,
ErroneousType,
LookupNotInScope(Loc<Ident>, MutSet<Box<str>>),
LookupNotInScope {
loc_name: Loc<Ident>,
/// All of the names in scope (for the error message)
suggestion_options: MutSet<Box<str>>,
/// If the unfound variable is `name` and there's an ignored variable called `_name`,
/// this is the region where `_name` is defined (for the error message)
underscored_suggestion_region: Option<Region>,
},
OpaqueNotDefined {
usage: Loc<Ident>,
opaques_in_scope: MutSet<Box<str>>,