mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
Mark named destructures under records as open
This commit is contained in:
parent
9b58c0fb9c
commit
815ae5df9d
2 changed files with 27 additions and 0 deletions
|
@ -676,6 +676,17 @@ pub fn constrain_pattern(
|
|||
RecordField::Optional(pat_type)
|
||||
}
|
||||
DestructType::Required => {
|
||||
// Named destructures like
|
||||
// {foo} -> ...
|
||||
// are equivalent to wildcards on the type of `foo`, so if `foo` is a tag
|
||||
// union, we must add a constraint to ensure that this destructure opens it
|
||||
// up.
|
||||
if could_be_a_tag_union(types, pat_type_index) {
|
||||
state
|
||||
.delayed_is_open_constraints
|
||||
.push(constraints.is_open_type(pat_type_index));
|
||||
}
|
||||
|
||||
// No extra constraints necessary.
|
||||
RecordField::Demanded(pat_type)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue