is_open_type expects type index

This commit is contained in:
Ayaz Hafiz 2022-10-24 17:51:39 -05:00
parent 0f0c02965a
commit 556222caa1
No known key found for this signature in database
GPG Key ID: 0E2A37416A25EF58
2 changed files with 10 additions and 8 deletions

View File

@ -332,9 +332,7 @@ impl Constraints {
Constraint::PatternPresence(type_index, expected_index, category_index, region)
}
pub fn is_open_type(&mut self, typ: Type) -> Constraint {
let type_index = self.push_type(typ);
pub fn is_open_type(&mut self, type_index: TypeOrVar) -> Constraint {
Constraint::IsOpenType(type_index)
}

View File

@ -182,9 +182,11 @@ pub fn constrain_pattern(
// _ -> ""
// so, we know that "x" (in this case, a tag union) must be open.
if could_be_a_tag_union(expected.get_type_ref()) {
let type_index = constraints.push_type(expected.get_type());
state
.delayed_is_open_constraints
.push(constraints.is_open_type(expected.get_type()));
.push(constraints.is_open_type(type_index));
}
}
UnsupportedPattern(_) | MalformedPattern(_, _) | OpaqueNotInScope(..) => {
@ -193,9 +195,11 @@ pub fn constrain_pattern(
Identifier(symbol) | Shadowed(_, _, symbol) => {
if could_be_a_tag_union(expected.get_type_ref()) {
let type_index = constraints.push_type(expected.get_type_ref().clone());
state
.delayed_is_open_constraints
.push(constraints.is_open_type(expected.get_type_ref().clone()));
.push(constraints.is_open_type(type_index));
}
state.headers.insert(
@ -212,9 +216,9 @@ pub fn constrain_pattern(
specializes: _,
} => {
if could_be_a_tag_union(expected.get_type_ref()) {
state
.constraints
.push(constraints.is_open_type(expected.get_type_ref().clone()));
let type_index = constraints.push_type(expected.get_type_ref().clone());
state.constraints.push(constraints.is_open_type(type_index));
}
state.headers.insert(