mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 07:14:46 +00:00
feat(unify): start unifying a single-tag union no payload with Func
This commit is contained in:
parent
c2da776ff4
commit
80915105bc
2 changed files with 64 additions and 0 deletions
|
@ -1069,6 +1069,28 @@ fn unify_flat_type(
|
|||
problems
|
||||
}
|
||||
}
|
||||
(TagUnion(tags, ext), Func(args, closure, ret)) if tags.len() == 1 => {
|
||||
let (tag, payload) = tags.iter().next().unwrap();
|
||||
|
||||
if payload.len() == 0 {
|
||||
let mut new_payload = vec![];
|
||||
let mut new_tags = MutMap::default();
|
||||
|
||||
for arg in args {
|
||||
new_payload.push(*arg);
|
||||
}
|
||||
|
||||
new_tags.insert(tag.clone(), new_payload);
|
||||
|
||||
vec![]
|
||||
} else {
|
||||
mismatch!(
|
||||
"Trying to unify two flat types that are incompatible: {:?} ~ {:?}",
|
||||
TagUnion(tags.clone(), ext.clone()),
|
||||
Func(args.clone(), closure.clone(), ret.clone())
|
||||
)
|
||||
}
|
||||
}
|
||||
(other1, other2) => mismatch!(
|
||||
"Trying to unify two flat types that are incompatible: {:?} ~ {:?}",
|
||||
other1,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue