fix: headlist builtin on assoc lists
implement chooseunit for 0 args
This commit is contained in:
parent
c7af27a6ba
commit
d26524048e
|
@ -3770,14 +3770,25 @@ impl<'a> CodeGenerator<'a> {
|
||||||
builder::special_case_builtin(builtin, 0, vec![])
|
builder::special_case_builtin(builtin, 0, vec![])
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultFunction::FstPair
|
DefaultFunction::FstPair | DefaultFunction::SndPair => {
|
||||||
| DefaultFunction::SndPair
|
builder::undata_builtin(
|
||||||
| DefaultFunction::HeadList => builder::undata_builtin(
|
builtin,
|
||||||
builtin,
|
0,
|
||||||
0,
|
&constructor.tipo.return_type().unwrap(),
|
||||||
&constructor.tipo.return_type().unwrap(),
|
vec![],
|
||||||
vec![],
|
)
|
||||||
),
|
}
|
||||||
|
|
||||||
|
DefaultFunction::HeadList
|
||||||
|
if !constructor.tipo.return_type().unwrap().is_2_tuple() =>
|
||||||
|
{
|
||||||
|
builder::undata_builtin(
|
||||||
|
builtin,
|
||||||
|
0,
|
||||||
|
&constructor.tipo.return_type().unwrap(),
|
||||||
|
vec![],
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
DefaultFunction::MkCons | DefaultFunction::MkPairData => {
|
DefaultFunction::MkCons | DefaultFunction::MkPairData => {
|
||||||
unimplemented!("MkCons and MkPairData should be handled by an anon function or using [] or ( a, b, .., z).\n")
|
unimplemented!("MkCons and MkPairData should be handled by an anon function or using [] or ( a, b, .., z).\n")
|
||||||
|
@ -4164,9 +4175,11 @@ impl<'a> CodeGenerator<'a> {
|
||||||
builder::special_case_builtin(&func, count, arg_vec)
|
builder::special_case_builtin(&func, count, arg_vec)
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultFunction::FstPair
|
DefaultFunction::FstPair | DefaultFunction::SndPair => {
|
||||||
| DefaultFunction::SndPair
|
builder::undata_builtin(&func, count, tipo, arg_vec)
|
||||||
| DefaultFunction::HeadList => {
|
}
|
||||||
|
|
||||||
|
DefaultFunction::HeadList if !tipo.is_2_tuple() => {
|
||||||
builder::undata_builtin(&func, count, tipo, arg_vec)
|
builder::undata_builtin(&func, count, tipo, arg_vec)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1543,7 +1543,14 @@ pub fn special_case_builtin(
|
||||||
mut args: Vec<Term<Name>>,
|
mut args: Vec<Term<Name>>,
|
||||||
) -> Term<Name> {
|
) -> Term<Name> {
|
||||||
match func {
|
match func {
|
||||||
DefaultFunction::IfThenElse
|
DefaultFunction::ChooseUnit if count > 0 => {
|
||||||
|
let term = args.pop().unwrap();
|
||||||
|
let unit = args.pop().unwrap();
|
||||||
|
|
||||||
|
term.lambda("_").apply(unit)
|
||||||
|
}
|
||||||
|
DefaultFunction::ChooseUnit
|
||||||
|
| DefaultFunction::IfThenElse
|
||||||
| DefaultFunction::ChooseList
|
| DefaultFunction::ChooseList
|
||||||
| DefaultFunction::ChooseData
|
| DefaultFunction::ChooseData
|
||||||
| DefaultFunction::Trace => {
|
| DefaultFunction::Trace => {
|
||||||
|
@ -1580,16 +1587,6 @@ pub fn special_case_builtin(
|
||||||
|
|
||||||
term
|
term
|
||||||
}
|
}
|
||||||
DefaultFunction::ChooseUnit => {
|
|
||||||
if count == 0 {
|
|
||||||
unimplemented!("Honestly, why are you doing this?")
|
|
||||||
} else {
|
|
||||||
let term = args.pop().unwrap();
|
|
||||||
let unit = args.pop().unwrap();
|
|
||||||
|
|
||||||
term.lambda("_").apply(unit)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
DefaultFunction::UnConstrData => {
|
DefaultFunction::UnConstrData => {
|
||||||
let mut term: Term<Name> = (*func).into();
|
let mut term: Term<Name> = (*func).into();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue