Remove now-dead code.
This commit is contained in:
parent
f3cab94ae1
commit
00b255e960
|
@ -6,7 +6,7 @@ use std::{
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
ast::{
|
ast::{
|
||||||
Annotation, CallArg, DataType, Definition, Function, ModuleConstant, ModuleKind, Pattern,
|
Annotation, CallArg, DataType, Definition, Function, ModuleConstant, ModuleKind,
|
||||||
RecordConstructor, RecordConstructorArg, Span, TypeAlias, TypedDefinition, TypedPattern,
|
RecordConstructor, RecordConstructorArg, Span, TypeAlias, TypedDefinition, TypedPattern,
|
||||||
UnqualifiedImport, UntypedArg, UntypedDefinition, Use, Validator, PIPE_VARIABLE,
|
UnqualifiedImport, UntypedArg, UntypedDefinition, Use, Validator, PIPE_VARIABLE,
|
||||||
},
|
},
|
||||||
|
@ -19,8 +19,8 @@ use super::{
|
||||||
error::{Error, Snippet, Warning},
|
error::{Error, Snippet, Warning},
|
||||||
exhaustive::{simplify, Matrix, PatternStack},
|
exhaustive::{simplify, Matrix, PatternStack},
|
||||||
hydrator::Hydrator,
|
hydrator::Hydrator,
|
||||||
AccessorsMap, PatternConstructor, RecordAccessor, Type, TypeConstructor, TypeInfo, TypeVar,
|
AccessorsMap, RecordAccessor, Type, TypeConstructor, TypeInfo, TypeVar, ValueConstructor,
|
||||||
ValueConstructor, ValueConstructorVariant,
|
ValueConstructorVariant,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -1484,75 +1484,6 @@ impl<'a> Environment<'a> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_list_pattern_exhaustiveness(
|
|
||||||
&mut self,
|
|
||||||
patterns: Vec<Pattern<PatternConstructor, Arc<Type>>>,
|
|
||||||
) -> Result<(), Vec<String>> {
|
|
||||||
let mut cover_empty = false;
|
|
||||||
let mut cover_tail = false;
|
|
||||||
|
|
||||||
let patterns = patterns.iter().map(|p| match p {
|
|
||||||
Pattern::Assign { pattern, .. } => pattern,
|
|
||||||
_ => p,
|
|
||||||
});
|
|
||||||
|
|
||||||
// TODO: We could also warn on redundant patterns. As soon as we've matched the entire
|
|
||||||
// list, any new pattern is redundant. For example:
|
|
||||||
//
|
|
||||||
// when xs is {
|
|
||||||
// [] => ...
|
|
||||||
// [x, ..] => ...
|
|
||||||
// [y] => ...
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// That last pattern is actually redundant / unreachable.
|
|
||||||
for p in patterns {
|
|
||||||
match p {
|
|
||||||
Pattern::Var { .. } => {
|
|
||||||
cover_empty = true;
|
|
||||||
cover_tail = true;
|
|
||||||
}
|
|
||||||
Pattern::Discard { .. } => {
|
|
||||||
cover_empty = true;
|
|
||||||
cover_tail = true;
|
|
||||||
}
|
|
||||||
Pattern::List { elements, tail, .. } => {
|
|
||||||
if elements.is_empty() {
|
|
||||||
cover_empty = true;
|
|
||||||
}
|
|
||||||
match tail {
|
|
||||||
None => {}
|
|
||||||
Some(p) => match **p {
|
|
||||||
Pattern::Discard { .. } => {
|
|
||||||
cover_tail = true;
|
|
||||||
}
|
|
||||||
Pattern::Var { .. } => {
|
|
||||||
cover_tail = true;
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
unreachable!()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if cover_empty && cover_tail {
|
|
||||||
Ok(())
|
|
||||||
} else {
|
|
||||||
let mut missing = vec![];
|
|
||||||
if !cover_empty {
|
|
||||||
missing.push("[]".to_owned());
|
|
||||||
}
|
|
||||||
if !cover_tail {
|
|
||||||
missing.push("[_, ..]".to_owned());
|
|
||||||
}
|
|
||||||
Err(missing)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Lookup constructors for type in the current scope.
|
/// Lookup constructors for type in the current scope.
|
||||||
///
|
///
|
||||||
pub fn get_constructors_for_type(
|
pub fn get_constructors_for_type(
|
||||||
|
|
|
@ -342,22 +342,9 @@ impl Matrix {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// (:)
|
|
||||||
// <$> Maybe.mapMaybe (isMissing alts ctors) altList
|
|
||||||
// <*> isExhaustive (Maybe.mapMaybe specializeRowByAnything matrix) (n - 1)
|
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
// let
|
|
||||||
// isAltExhaustive (Can.Ctor name _ arity _) =
|
|
||||||
// recoverCtor alts name arity <$>
|
|
||||||
// isExhaustive
|
|
||||||
// (Maybe.mapMaybe (specializeRowByCtor name arity) matrix)
|
|
||||||
// (arity + n - 1)
|
|
||||||
// in
|
|
||||||
// concatMap isAltExhaustive altList
|
|
||||||
//
|
|
||||||
|
|
||||||
alts.iter()
|
alts.iter()
|
||||||
.map(|ctor| {
|
.map(|ctor| {
|
||||||
let tipo::ValueConstructor { variant, .. } = ctor;
|
let tipo::ValueConstructor { variant, .. } = ctor;
|
||||||
|
|
Loading…
Reference in New Issue