mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 23:31:12 +00:00
Delay add "is open" constraint until we know a type variable
This commit is contained in:
parent
7b2b41869f
commit
504c3f9b49
4 changed files with 54 additions and 8 deletions
|
@ -18,6 +18,7 @@ pub struct PatternState {
|
|||
pub headers: SendMap<Symbol, Loc<Type>>,
|
||||
pub vars: Vec<Variable>,
|
||||
pub constraints: Vec<Constraint>,
|
||||
pub delayed_is_open_constriants: Vec<Constraint>,
|
||||
}
|
||||
|
||||
/// If there is a type annotation, the pattern state headers can be optimized by putting the
|
||||
|
@ -180,7 +181,7 @@ 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()) {
|
||||
state
|
||||
.constraints
|
||||
.delayed_is_open_constriants
|
||||
.push(constraints.is_open_type(expected.get_type()));
|
||||
}
|
||||
}
|
||||
|
@ -191,7 +192,7 @@ pub fn constrain_pattern(
|
|||
Identifier(symbol) | Shadowed(_, _, symbol) => {
|
||||
if could_be_a_tag_union(expected.get_type_ref()) {
|
||||
state
|
||||
.constraints
|
||||
.delayed_is_open_constriants
|
||||
.push(constraints.is_open_type(expected.get_type_ref().clone()));
|
||||
}
|
||||
|
||||
|
@ -494,6 +495,9 @@ pub fn constrain_pattern(
|
|||
state.vars.push(*ext_var);
|
||||
state.constraints.push(whole_con);
|
||||
state.constraints.push(tag_con);
|
||||
state
|
||||
.constraints
|
||||
.extend(state.delayed_is_open_constriants.drain(..));
|
||||
}
|
||||
|
||||
UnwrappedOpaque {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue