mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 13:59:08 +00:00
update deep_copy_var_help
This commit is contained in:
parent
be104d25eb
commit
4550f3fa88
1 changed files with 10 additions and 7 deletions
|
@ -3049,11 +3049,12 @@ fn deep_copy_var_help(
|
|||
use roc_types::subs::FlatType::*;
|
||||
|
||||
let subs_len = subs.len();
|
||||
let desc = subs.get_ref_mut(var);
|
||||
|
||||
if let Some(copy) = desc.copy.into_variable() {
|
||||
let existing_copy = subs.get_copy(var);
|
||||
|
||||
if let Some(copy) = existing_copy.into_variable() {
|
||||
return copy;
|
||||
} else if desc.rank != Rank::NONE {
|
||||
} else if subs.get_rank(var) != Rank::NONE {
|
||||
return var;
|
||||
}
|
||||
|
||||
|
@ -3066,8 +3067,6 @@ fn deep_copy_var_help(
|
|||
copy: OptVariable::NONE,
|
||||
};
|
||||
|
||||
let content = desc.content;
|
||||
|
||||
// Safety: Here we make a variable that is 1 position out of bounds.
|
||||
// The reason is that we can now keep the mutable reference to `desc`
|
||||
// Below, we actually push a new variable onto subs meaning the `copy`
|
||||
|
@ -3080,8 +3079,12 @@ fn deep_copy_var_help(
|
|||
// avoid making multiple copies of the variable we are instantiating.
|
||||
//
|
||||
// Need to do this before recursively copying to avoid looping.
|
||||
desc.mark = Mark::NONE;
|
||||
desc.copy = copy.into();
|
||||
subs.modify(var, |desc| {
|
||||
desc.mark = Mark::NONE;
|
||||
desc.copy = copy.into();
|
||||
});
|
||||
|
||||
let content = *subs.get_content_without_compacting(var);
|
||||
|
||||
let actual_copy = subs.fresh(make_descriptor(content));
|
||||
debug_assert_eq!(copy, actual_copy);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue