fix: exhaustiveness on types from other modules
This commit is contained in:
parent
7e531d0da1
commit
a6b230aad4
|
@ -290,6 +290,10 @@ pub fn prelude(id_gen: &IdGenerator) -> TypeInfo {
|
|||
);
|
||||
|
||||
// Void
|
||||
prelude
|
||||
.types_constructors
|
||||
.insert(VOID.to_string(), vec![VOID.to_string()]);
|
||||
|
||||
prelude.values.insert(
|
||||
VOID.to_string(),
|
||||
ValueConstructor::public(
|
||||
|
|
|
@ -176,7 +176,7 @@ fn expect_sugar_incorrect_type() {
|
|||
"#;
|
||||
|
||||
assert!(matches!(
|
||||
dbg!(check(parse(source_code))),
|
||||
check(parse(source_code)),
|
||||
Err((_, Error::CouldNotUnify { .. }))
|
||||
))
|
||||
}
|
||||
|
|
|
@ -1470,12 +1470,11 @@ impl<'a> Environment<'a> {
|
|||
|
||||
let missing_patterns = matrix.collect_missing_patterns(1).flatten();
|
||||
|
||||
for missing in &missing_patterns {
|
||||
dbg!(missing);
|
||||
}
|
||||
|
||||
if !missing_patterns.is_empty() {
|
||||
let unmatched = missing_patterns.into_iter().map(|p| p.pretty()).collect();
|
||||
let unmatched = missing_patterns
|
||||
.into_iter()
|
||||
.map(|pattern| pattern.pretty())
|
||||
.collect();
|
||||
|
||||
return Err(Error::NotExhaustivePatternMatch {
|
||||
location,
|
||||
|
|
|
@ -566,20 +566,24 @@ pub(super) fn simplify(
|
|||
ast::Pattern::Constructor {
|
||||
name,
|
||||
arguments,
|
||||
module,
|
||||
location,
|
||||
tipo,
|
||||
with_spread,
|
||||
module,
|
||||
..
|
||||
} => {
|
||||
let (type_name, arity) = match tipo.deref() {
|
||||
let (type_module, type_name, arity) = match tipo.deref() {
|
||||
tipo::Type::App {
|
||||
name: type_name, ..
|
||||
} => (type_name, 0),
|
||||
name: type_name,
|
||||
module,
|
||||
..
|
||||
} => (module, type_name, 0),
|
||||
tipo::Type::Fn { ret, args, .. } => match ret.deref() {
|
||||
tipo::Type::App {
|
||||
name: type_name, ..
|
||||
} => (type_name, args.len()),
|
||||
name: type_name,
|
||||
module,
|
||||
..
|
||||
} => (module, type_name, args.len()),
|
||||
_ => {
|
||||
unreachable!("ret should be a Type::App")
|
||||
}
|
||||
|
@ -587,8 +591,15 @@ pub(super) fn simplify(
|
|||
_ => unreachable!("tipo should be a Type::App"),
|
||||
};
|
||||
|
||||
let module_opt = if type_module.is_empty() || environment.current_module == type_module
|
||||
{
|
||||
None
|
||||
} else {
|
||||
Some(type_module.clone())
|
||||
};
|
||||
|
||||
let constructors = environment
|
||||
.get_constructors_for_type(module, type_name, *location)?
|
||||
.get_constructors_for_type(&module_opt, type_name, *location)?
|
||||
.clone();
|
||||
|
||||
let mut alts = Vec::new();
|
||||
|
|
Loading…
Reference in New Issue