mirror of
https://github.com/roc-lang/roc.git
synced 2024-11-11 05:34:11 +03:00
is_open_type expects type index
This commit is contained in:
parent
0f0c02965a
commit
556222caa1
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user