fix: builtins using the incorrect data to type conversion when used as a function param.

This commit is contained in:
microproofs 2023-06-23 14:30:29 -04:00 committed by Kasey
parent db369da96e
commit 226556bdd6
3 changed files with 15 additions and 2 deletions

View File

@ -22,6 +22,7 @@
- **aiken-lang**: Fix for tuple clause not consuming the next case causing - **aiken-lang**: Fix for tuple clause not consuming the next case causing
incomplete contracts. Now tuple clause will always consume the next case incomplete contracts. Now tuple clause will always consume the next case
unless it is the final clause unless it is the final clause
- **aiken-lang**: Fix for builtins using the incorrect data to type conversion when used as a function param.
## v1.0.10-alpha - 2023-06-13 ## v1.0.10-alpha - 2023-06-13

View File

@ -4168,6 +4168,11 @@ impl<'a> CodeGenerator<'a> {
arg_vec.push(arg_stack.pop().unwrap()); arg_vec.push(arg_stack.pop().unwrap());
} }
let tipo = match tipo.as_ref() {
Type::Fn { ret, .. } => ret,
_ => &tipo,
};
let term = match &func { let term = match &func {
DefaultFunction::IfThenElse DefaultFunction::IfThenElse
| DefaultFunction::ChooseUnit | DefaultFunction::ChooseUnit
@ -4181,11 +4186,11 @@ impl<'a> CodeGenerator<'a> {
DefaultFunction::FstPair DefaultFunction::FstPair
| DefaultFunction::SndPair | DefaultFunction::SndPair
| DefaultFunction::HeadList => { | DefaultFunction::HeadList => {
builder::undata_builtin(&func, count, &tipo, arg_vec) builder::undata_builtin(&func, count, tipo, arg_vec)
} }
DefaultFunction::MkCons | DefaultFunction::MkPairData => { DefaultFunction::MkCons | DefaultFunction::MkPairData => {
builder::to_data_builtin(&func, count, &tipo, arg_vec) builder::to_data_builtin(&func, count, tipo, arg_vec)
} }
_ => { _ => {
let mut term: Term<Name> = func.into(); let mut term: Term<Name> = func.into();

View File

@ -1,3 +1,5 @@
use aiken/builtin.{snd_pair}
use aiken/cbor
use aiken/list use aiken/list
test tuple_when() { test tuple_when() {
@ -20,3 +22,8 @@ test tuple_when() {
) )
list.length(filtered) > 0 list.length(filtered) > 0
} }
test t() {
trace cbor.diagnostic(list.map([(#"", 20)], snd_pair))
True
}