mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 22:34:45 +00:00
remove chase_record_ext_var
This commit is contained in:
parent
7a44572ebc
commit
83ad331bb1
6 changed files with 56 additions and 88 deletions
|
@ -9,7 +9,7 @@ use roc_types::subs::{
|
|||
Variable, VariableSubsSlice,
|
||||
};
|
||||
use roc_types::types::Type::{self, *};
|
||||
use roc_types::types::{Alias, Category, ErrorType, PatternCategory};
|
||||
use roc_types::types::{gather_fields_unsorted_iter, Alias, Category, ErrorType, PatternCategory};
|
||||
use roc_unify::unify::unify;
|
||||
use roc_unify::unify::Unified::*;
|
||||
|
||||
|
@ -676,29 +676,28 @@ fn type_to_variable(
|
|||
register(subs, rank, pools, content)
|
||||
}
|
||||
Record(fields, ext) => {
|
||||
let mut field_vars = MutMap::with_capacity_and_hasher(fields.len(), default_hasher());
|
||||
let mut field_vars = Vec::with_capacity(fields.len());
|
||||
|
||||
for (field, field_type) in fields {
|
||||
let field_var =
|
||||
field_type.map(|typ| type_to_variable(subs, rank, pools, cached, typ));
|
||||
|
||||
field_vars.insert(field.clone(), field_var);
|
||||
field_vars.push((field.clone(), field_var));
|
||||
}
|
||||
|
||||
let temp_ext_var = type_to_variable(subs, rank, pools, cached, ext);
|
||||
let new_ext_var = match roc_types::pretty_print::chase_ext_record(
|
||||
subs,
|
||||
temp_ext_var,
|
||||
&mut field_vars,
|
||||
) {
|
||||
Ok(()) => Variable::EMPTY_RECORD,
|
||||
Err((new, _)) => new,
|
||||
};
|
||||
|
||||
let mut all_fields: Vec<_> = field_vars.into_iter().collect();
|
||||
all_fields.sort_unstable_by(RecordFields::compare);
|
||||
let (it, new_ext_var) =
|
||||
gather_fields_unsorted_iter(subs, RecordFields::empty(), temp_ext_var);
|
||||
|
||||
let record_fields = RecordFields::insert_into_subs(subs, all_fields);
|
||||
let it = it
|
||||
.into_iter()
|
||||
.map(|(field, field_type)| (field.clone(), field_type));
|
||||
|
||||
field_vars.extend(it);
|
||||
field_vars.sort_unstable_by(RecordFields::compare);
|
||||
|
||||
let record_fields = RecordFields::insert_into_subs(subs, field_vars);
|
||||
|
||||
let content = Content::Structure(FlatType::Record(record_fields, new_ext_var));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue