fix: redundant might be wildcard which doesn't match technically

This commit is contained in:
rvcas 2023-08-01 16:06:05 -04:00 committed by Lucas
parent a6b230aad4
commit 75e18d485d
1 changed files with 4 additions and 6 deletions

View File

@ -1451,18 +1451,16 @@ impl<'a> Environment<'a> {
if matrix.is_useful(&pattern_stack) {
matrix.push(pattern_stack);
} else {
let index = matrix
let original = matrix
.flatten()
.into_iter()
.enumerate()
.find(|(_, p)| p == pattern_stack.head())
.map(|(i, _)| i)
.expect("should find index");
let typed_pattern = unchecked_patterns[index];
.and_then(|(index, _)| unchecked_patterns.get(index))
.map(|typed_pattern| typed_pattern.location());
return Err(Error::RedundantMatchClause {
original: typed_pattern.location(),
original,
redundant: unchecked_pattern.location(),
});
}