Remove opt_rec_var

This commit is contained in:
ayazhafiz 2022-02-11 08:51:08 -05:00
parent 8c0e39211d
commit c71854d5a4

View file

@ -1612,7 +1612,6 @@ fn correct_mutual_recursive_type_alias<'a>(
let is_mutually_recursive = cycle.len() > 1; let is_mutually_recursive = cycle.len() > 1;
if is_self_recursive || is_mutually_recursive { if is_self_recursive || is_mutually_recursive {
let mut opt_rec_var = None;
let _made_recursive = make_tag_union_of_alias_recursive( let _made_recursive = make_tag_union_of_alias_recursive(
env, env,
rec, rec,
@ -1620,7 +1619,6 @@ fn correct_mutual_recursive_type_alias<'a>(
vec![], vec![],
var_store, var_store,
&mut can_still_report_error, &mut can_still_report_error,
&mut opt_rec_var,
); );
} }
} }
@ -1664,7 +1662,6 @@ fn make_tag_union_of_alias_recursive<'a>(
others: Vec<Symbol>, others: Vec<Symbol>,
var_store: &mut VarStore, var_store: &mut VarStore,
can_report_error: &mut bool, can_report_error: &mut bool,
opt_rec_var: &mut Option<Variable>,
) -> Result<(), ()> { ) -> Result<(), ()> {
let alias_args = alias let alias_args = alias
.type_variables .type_variables
@ -1680,7 +1677,6 @@ fn make_tag_union_of_alias_recursive<'a>(
&mut alias.typ, &mut alias.typ,
var_store, var_store,
can_report_error, can_report_error,
opt_rec_var,
) )
} }
@ -1713,7 +1709,6 @@ fn make_tag_union_recursive_help<'a>(
typ: &mut Type, typ: &mut Type,
var_store: &mut VarStore, var_store: &mut VarStore,
can_report_error: &mut bool, can_report_error: &mut bool,
opt_rec_var: &mut Option<Variable>,
) -> Result<(), ()> { ) -> Result<(), ()> {
let Loc { let Loc {
value: (symbol, args), value: (symbol, args),
@ -1722,10 +1717,7 @@ fn make_tag_union_recursive_help<'a>(
let vars = args.iter().map(|(_, t)| t.clone()).collect::<Vec<_>>(); let vars = args.iter().map(|(_, t)| t.clone()).collect::<Vec<_>>();
match typ { match typ {
Type::TagUnion(tags, ext) => { Type::TagUnion(tags, ext) => {
if opt_rec_var.is_none() { let rec_var = var_store.fresh();
*opt_rec_var = Some(var_store.fresh());
}
let rec_var = opt_rec_var.unwrap();
let mut pending_typ = Type::RecursiveTagUnion(rec_var, tags.to_vec(), ext.clone()); let mut pending_typ = Type::RecursiveTagUnion(rec_var, tags.to_vec(), ext.clone());
let substitution_result = let substitution_result =
pending_typ.substitute_alias(symbol, &vars, &Type::Variable(rec_var)); pending_typ.substitute_alias(symbol, &vars, &Type::Variable(rec_var));
@ -1758,7 +1750,6 @@ fn make_tag_union_recursive_help<'a>(
actual, actual,
var_store, var_store,
can_report_error, can_report_error,
opt_rec_var,
), ),
_ => { _ => {
mark_cyclic_alias(env, typ, symbol, region, others.clone(), *can_report_error); mark_cyclic_alias(env, typ, symbol, region, others.clone(), *can_report_error);