mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 14:54:47 +00:00
Push checkmate through env
This commit is contained in:
parent
8097ee3342
commit
87d108eccc
16 changed files with 190 additions and 29 deletions
|
@ -24,7 +24,7 @@ impl Collector {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn unify(&mut self, subs: &s::Subs, to: s::Variable, from: s::Variable) {
|
||||
pub fn unify(&mut self, subs: &s::Subs, from: s::Variable, to: s::Variable) {
|
||||
let to = to.as_schema(subs);
|
||||
let from = from.as_schema(subs);
|
||||
self.add_event(VariableEvent::Unify { to, from });
|
||||
|
@ -61,7 +61,7 @@ impl Collector {
|
|||
});
|
||||
}
|
||||
|
||||
pub fn start_unification(&mut self, subs: &s::Subs, left: &s::Variable, right: &s::Variable) {
|
||||
pub fn start_unification(&mut self, subs: &s::Subs, left: s::Variable, right: s::Variable) {
|
||||
let left = left.as_schema(subs);
|
||||
let right = right.as_schema(subs);
|
||||
// TODO add mode
|
||||
|
@ -72,11 +72,32 @@ impl Collector {
|
|||
right,
|
||||
mode,
|
||||
subevents,
|
||||
success: None,
|
||||
});
|
||||
}
|
||||
|
||||
pub fn end_unification(&mut self) {
|
||||
pub fn end_unification(
|
||||
&mut self,
|
||||
subs: &s::Subs,
|
||||
left: s::Variable,
|
||||
right: s::Variable,
|
||||
success: bool,
|
||||
) {
|
||||
let current_event = self.get_path_event();
|
||||
match current_event {
|
||||
Event::Unification {
|
||||
left: l,
|
||||
right: r,
|
||||
success: s,
|
||||
..
|
||||
} => {
|
||||
assert_eq!(left.as_schema(subs), *l);
|
||||
assert_eq!(right.as_schema(subs), *r);
|
||||
assert!(s.is_none());
|
||||
*s = Some(success);
|
||||
}
|
||||
_ => panic!("end_unification called when not in a unification"),
|
||||
}
|
||||
assert!(matches!(current_event, Event::Unification { .. }));
|
||||
self.current_event_path.pop();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue