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) { if matrix.is_useful(&pattern_stack) {
matrix.push(pattern_stack); matrix.push(pattern_stack);
} else { } else {
let index = matrix let original = matrix
.flatten() .flatten()
.into_iter() .into_iter()
.enumerate() .enumerate()
.find(|(_, p)| p == pattern_stack.head()) .find(|(_, p)| p == pattern_stack.head())
.map(|(i, _)| i) .and_then(|(index, _)| unchecked_patterns.get(index))
.expect("should find index"); .map(|typed_pattern| typed_pattern.location());
let typed_pattern = unchecked_patterns[index];
return Err(Error::RedundantMatchClause { return Err(Error::RedundantMatchClause {
original: typed_pattern.location(), original,
redundant: unchecked_pattern.location(), redundant: unchecked_pattern.location(),
}); });
} }