fix: to_data_builtin to operate on arg not func result
This commit is contained in:
parent
b36cf1c029
commit
49898f7420
|
@ -4083,6 +4083,7 @@ impl<'a> CodeGenerator<'a> {
|
||||||
for arg in arg_vec {
|
for arg in arg_vec {
|
||||||
term = term.apply(arg.clone());
|
term = term.apply(arg.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
term
|
term
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1845,27 +1845,37 @@ pub fn to_data_builtin(
|
||||||
func: &DefaultFunction,
|
func: &DefaultFunction,
|
||||||
count: usize,
|
count: usize,
|
||||||
tipo: &Arc<Type>,
|
tipo: &Arc<Type>,
|
||||||
args: Vec<Term<Name>>,
|
mut args: Vec<Term<Name>>,
|
||||||
) -> Term<Name> {
|
) -> Term<Name> {
|
||||||
let mut term: Term<Name> = (*func).into();
|
let mut term: Term<Name> = (*func).into();
|
||||||
|
|
||||||
term = apply_builtin_forces(term, func.force_count());
|
term = apply_builtin_forces(term, func.force_count());
|
||||||
|
|
||||||
for arg in args {
|
if count == 0 {
|
||||||
|
assert!(args.is_empty());
|
||||||
|
|
||||||
|
for arg_index in 0..func.arity() {
|
||||||
|
let temp_var = format!("__item_index_{}", arg_index);
|
||||||
|
|
||||||
|
args.push(Term::var(temp_var))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (index, arg) in args.into_iter().enumerate() {
|
||||||
|
if index == 0 || matches!(func, DefaultFunction::MkPairData) {
|
||||||
|
term = term.apply(convert_type_to_data(arg, tipo));
|
||||||
|
} else {
|
||||||
term = term.apply(arg);
|
term = term.apply(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
let temp_var = "__item_x";
|
|
||||||
|
|
||||||
if count == 0 {
|
|
||||||
term = term.apply(Term::var(temp_var));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
term = convert_type_to_data(term, tipo);
|
|
||||||
|
|
||||||
if count == 0 {
|
if count == 0 {
|
||||||
|
for arg_index in (0..func.arity()).rev() {
|
||||||
|
let temp_var = format!("__item_index_{}", arg_index);
|
||||||
term = term.lambda(temp_var);
|
term = term.lambda(temp_var);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
term
|
term
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue