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

@ -379,6 +379,12 @@ pub fn canonicalize_pattern<'a>(
Err(pattern) => pattern,
}
}
Underscore(name) => {
// An underscored identifier can't be used, but we'll still add it to the scope
// for better error messages if someone tries to use it.
scope.introduce_ignored_local(name, region);
Pattern::Underscore
}
Tag(name) => {
// Canonicalize the tag's name.
Pattern::AppliedTag {
@ -479,8 +485,6 @@ pub fn canonicalize_pattern<'a>(
ptype => unsupported_pattern(env, ptype, region),
},
Underscore(_) => Pattern::Underscore,
&NumLiteral(str) => match pattern_type {
WhenBranch => match finish_parsing_num(str) {
Err(_error) => {