mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 22:34:45 +00:00
use EitherIndex<Type, Variable> to halve number of types stored
This commit is contained in:
parent
da03b0c2b3
commit
b3d9f9c2de
3 changed files with 69 additions and 34 deletions
|
@ -414,11 +414,18 @@ fn solve(
|
|||
copy
|
||||
}
|
||||
Eq(type_index, expectation_index, category_index, region) => {
|
||||
let typ = &constraints.types[type_index.index()];
|
||||
let expectation = &constraints.expectations[expectation_index.index()];
|
||||
let category = &constraints.categories[category_index.index()];
|
||||
|
||||
let actual = type_to_var(subs, rank, pools, cached_aliases, typ);
|
||||
let actual = either_type_index_to_var(
|
||||
constraints,
|
||||
subs,
|
||||
rank,
|
||||
pools,
|
||||
cached_aliases,
|
||||
*type_index,
|
||||
);
|
||||
|
||||
let expectation = &constraints.expectations[expectation_index.index()];
|
||||
let expected = type_to_var(
|
||||
subs,
|
||||
rank,
|
||||
|
@ -457,11 +464,16 @@ fn solve(
|
|||
}
|
||||
}
|
||||
Store(source_index, target, _filename, _linenr) => {
|
||||
let source = &constraints.types[source_index.index()];
|
||||
|
||||
// a special version of Eq that is used to store types in the AST.
|
||||
// IT DOES NOT REPORT ERRORS!
|
||||
let actual = type_to_var(subs, rank, pools, cached_aliases, source);
|
||||
let actual = either_type_index_to_var(
|
||||
constraints,
|
||||
subs,
|
||||
rank,
|
||||
pools,
|
||||
cached_aliases,
|
||||
*source_index,
|
||||
);
|
||||
let target = *target;
|
||||
|
||||
match unify(subs, actual, target, Mode::EQ) {
|
||||
|
@ -572,11 +584,18 @@ fn solve(
|
|||
}
|
||||
Pattern(type_index, expectation_index, category_index, region)
|
||||
| PatternPresence(type_index, expectation_index, category_index, region) => {
|
||||
let typ = &constraints.types[type_index.index()];
|
||||
let expectation = &constraints.pattern_expectations[expectation_index.index()];
|
||||
let category = &constraints.pattern_categories[category_index.index()];
|
||||
|
||||
let actual = type_to_var(subs, rank, pools, cached_aliases, typ);
|
||||
let actual = either_type_index_to_var(
|
||||
constraints,
|
||||
subs,
|
||||
rank,
|
||||
pools,
|
||||
cached_aliases,
|
||||
*type_index,
|
||||
);
|
||||
|
||||
let expectation = &constraints.pattern_expectations[expectation_index.index()];
|
||||
let expected = type_to_var(
|
||||
subs,
|
||||
rank,
|
||||
|
@ -700,9 +719,15 @@ fn solve(
|
|||
}
|
||||
}
|
||||
IsOpenType(type_index) => {
|
||||
let typ = &constraints.types[type_index.index()];
|
||||
let actual = either_type_index_to_var(
|
||||
constraints,
|
||||
subs,
|
||||
rank,
|
||||
pools,
|
||||
cached_aliases,
|
||||
*type_index,
|
||||
);
|
||||
|
||||
let actual = type_to_var(subs, rank, pools, cached_aliases, typ);
|
||||
let mut new_desc = subs.get(actual);
|
||||
match new_desc.content {
|
||||
Content::Structure(FlatType::TagUnion(tags, _)) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue