mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 23:04:49 +00:00
don't create IsOpenType constraint for obvious non-types
This commit is contained in:
parent
f5ebc5bec9
commit
6aaef49aa7
1 changed files with 15 additions and 6 deletions
|
@ -172,18 +172,23 @@ pub fn constrain_pattern(
|
|||
// A -> ""
|
||||
// _ -> ""
|
||||
// so, we know that "x" (in this case, a tag union) must be open.
|
||||
if could_be_a_tag_union(expected.get_type_ref()) {
|
||||
state
|
||||
.constraints
|
||||
.push(constraints.is_open_type(expected.get_type()));
|
||||
}
|
||||
}
|
||||
UnsupportedPattern(_) | MalformedPattern(_, _) | OpaqueNotInScope(..) => {
|
||||
// Erroneous patterns don't add any constraints.
|
||||
}
|
||||
|
||||
Identifier(symbol) | Shadowed(_, _, symbol) => {
|
||||
if could_be_a_tag_union(expected.get_type_ref()) {
|
||||
state
|
||||
.constraints
|
||||
.push(constraints.is_open_type(expected.get_type_ref().clone()));
|
||||
}
|
||||
|
||||
state.headers.insert(
|
||||
*symbol,
|
||||
Loc {
|
||||
|
@ -552,3 +557,7 @@ pub fn constrain_pattern(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn could_be_a_tag_union(typ: &Type) -> bool {
|
||||
!matches!(typ, Type::Apply(..) | Type::Function(..) | Type::Record(..))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue