mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 22:34:45 +00:00
all the work
This commit is contained in:
parent
1cee8f77b9
commit
69c224843e
10 changed files with 582 additions and 366 deletions
|
@ -5,7 +5,7 @@ use roc_module::symbol::Symbol;
|
|||
use roc_region::all::{Located, Region};
|
||||
use roc_types::solved_types::Solved;
|
||||
use roc_types::subs::{
|
||||
Content, Descriptor, FlatType, Mark, OptVariable, Rank, Subs, SubsSlice, Variable,
|
||||
Content, Descriptor, FlatType, Mark, OptVariable, Rank, RecordFields, Subs, SubsSlice, Variable,
|
||||
};
|
||||
use roc_types::types::Type::{self, *};
|
||||
use roc_types::types::{Alias, Category, ErrorType, PatternCategory};
|
||||
|
@ -698,7 +698,11 @@ fn type_to_variable(
|
|||
Err((new, _)) => new,
|
||||
};
|
||||
|
||||
let record_fields = field_vars.into_iter().collect();
|
||||
let mut all_fields: Vec<_> = field_vars.into_iter().collect();
|
||||
all_fields.sort_unstable_by(RecordFields::compare);
|
||||
|
||||
let record_fields = RecordFields::insert_into_subs(subs, all_fields);
|
||||
|
||||
let content = Content::Structure(FlatType::Record(record_fields, new_ext_var));
|
||||
|
||||
register(subs, rank, pools, content)
|
||||
|
@ -1089,9 +1093,9 @@ fn adjust_rank_content(
|
|||
Record(fields, ext_var) => {
|
||||
let mut rank = adjust_rank(subs, young_mark, visit_mark, group_rank, *ext_var);
|
||||
|
||||
for var in fields.iter_variables() {
|
||||
rank =
|
||||
rank.max(adjust_rank(subs, young_mark, visit_mark, group_rank, *var));
|
||||
for index in fields.iter_variables() {
|
||||
let var = subs[index];
|
||||
rank = rank.max(adjust_rank(subs, young_mark, visit_mark, group_rank, var));
|
||||
}
|
||||
|
||||
rank
|
||||
|
@ -1239,8 +1243,9 @@ fn instantiate_rigids_help(
|
|||
EmptyRecord | EmptyTagUnion | Erroneous(_) => {}
|
||||
|
||||
Record(fields, ext_var) => {
|
||||
for var in fields.iter_variables() {
|
||||
instantiate_rigids_help(subs, max_rank, pools, *var);
|
||||
for index in fields.iter_variables() {
|
||||
let var = subs[index];
|
||||
instantiate_rigids_help(subs, max_rank, pools, var);
|
||||
}
|
||||
|
||||
instantiate_rigids_help(subs, max_rank, pools, ext_var);
|
||||
|
@ -1386,12 +1391,30 @@ fn deep_copy_var_help(
|
|||
|
||||
same @ EmptyRecord | same @ EmptyTagUnion | same @ Erroneous(_) => same,
|
||||
|
||||
Record(mut fields, ext_var) => {
|
||||
for var in fields.iter_variables_mut() {
|
||||
*var = deep_copy_var_help(subs, max_rank, pools, *var);
|
||||
Record(fields, ext_var) => {
|
||||
let mut new_vars = Vec::with_capacity(fields.len());
|
||||
for index in fields.iter_variables() {
|
||||
let var = subs[index];
|
||||
let copy_var = deep_copy_var_help(subs, max_rank, pools, var);
|
||||
new_vars.push(copy_var);
|
||||
}
|
||||
|
||||
Record(fields, deep_copy_var_help(subs, max_rank, pools, ext_var))
|
||||
let it = fields.iter_all().zip(new_vars).map(|((i1, _, i3), var)| {
|
||||
let label = subs[i1].clone();
|
||||
let record_field = subs[i3].map(|_| var);
|
||||
|
||||
(label, record_field)
|
||||
});
|
||||
|
||||
// lifetime troubles
|
||||
let vec: Vec<_> = it.collect();
|
||||
|
||||
let record_fields = RecordFields::insert_into_subs(subs, vec);
|
||||
|
||||
Record(
|
||||
record_fields,
|
||||
deep_copy_var_help(subs, max_rank, pools, ext_var),
|
||||
)
|
||||
}
|
||||
|
||||
TagUnion(tags, ext_var) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue