Fix out of order expect check. Also fix no_inline error in code gen. @acceptance_107
This commit is contained in:
parent
663695558c
commit
05504b9762
|
@ -640,8 +640,6 @@ impl<'a> CodeGenerator<'a> {
|
|||
|
||||
match &branch.is {
|
||||
Some((pattern, tipo)) => {
|
||||
println!("PATTERN TYPE: {:#?}", pattern);
|
||||
println!("Branch TYPE: {:#?}", tipo);
|
||||
AirTree::let_assignment(
|
||||
"acc_var",
|
||||
// use anon function as a delay to avoid evaluating the acc
|
||||
|
@ -4555,7 +4553,7 @@ impl<'a> CodeGenerator<'a> {
|
|||
|
||||
// How we handle zero arg anon functions has changed
|
||||
// We now delay zero arg anon functions and force them on a call operation
|
||||
match &term {
|
||||
match term.pierce_no_inlines() {
|
||||
Term::Var(name) => {
|
||||
let zero_arg_functions = self.zero_arg_functions.clone();
|
||||
let text = &name.text;
|
||||
|
@ -4935,7 +4933,7 @@ impl<'a> CodeGenerator<'a> {
|
|||
Air::CastToData { tipo } => {
|
||||
let mut term = arg_stack.pop().unwrap();
|
||||
|
||||
if extract_constant(&term).is_some() {
|
||||
if extract_constant(term.pierce_no_inlines()).is_some() {
|
||||
term = builder::convert_type_to_data(term, &tipo);
|
||||
|
||||
let mut program: Program<Name> = Program {
|
||||
|
@ -5384,7 +5382,7 @@ impl<'a> CodeGenerator<'a> {
|
|||
.apply(term);
|
||||
|
||||
if arg_vec.iter().all(|item| {
|
||||
let maybe_const = extract_constant(item);
|
||||
let maybe_const = extract_constant(item.pierce_no_inlines());
|
||||
maybe_const.is_some()
|
||||
}) {
|
||||
let mut program: Program<Name> = Program {
|
||||
|
|
|
@ -1457,13 +1457,13 @@ pub fn list_access_to_uplc(
|
|||
.lambda(tail_name)
|
||||
} else {
|
||||
// Custom error if list is not empty after this head
|
||||
Term::var(tail_name.to_string())
|
||||
.choose_list(
|
||||
otherwise_delayed.clone(),
|
||||
head_item(
|
||||
name,
|
||||
tipo,
|
||||
&tail_name,
|
||||
Term::var(tail_name.to_string())
|
||||
.choose_list(
|
||||
otherwise_delayed.clone(),
|
||||
Term::tail_list()
|
||||
.apply(Term::var(tail_name.to_string()))
|
||||
.choose_list(acc.delay(), otherwise_delayed.clone())
|
||||
|
|
|
@ -5233,38 +5233,6 @@ fn expect_head_cast_data_no_tail() {
|
|||
|
||||
assert_uplc(
|
||||
src,
|
||||
Term::var("tail_0")
|
||||
.choose_list(
|
||||
Term::var("expect[h]:List<Int>=a"),
|
||||
Term::tail_list()
|
||||
.apply(Term::var("tail_0"))
|
||||
.choose_list(
|
||||
Term::equals_integer()
|
||||
.apply(Term::var("h"))
|
||||
.apply(Term::var("h"))
|
||||
.delay(),
|
||||
Term::var("expect[h]:List<Int>=a"),
|
||||
)
|
||||
.force()
|
||||
.lambda("h")
|
||||
.apply(
|
||||
Term::var("__var")
|
||||
.choose_data(
|
||||
Term::var("expect[h]:List<Int>=a"),
|
||||
Term::var("expect[h]:List<Int>=a"),
|
||||
Term::var("expect[h]:List<Int>=a"),
|
||||
Term::un_i_data().apply(Term::var("__var")).delay(),
|
||||
Term::var("expect[h]:List<Int>=a"),
|
||||
)
|
||||
.force()
|
||||
.lambda("__var")
|
||||
.apply(Term::head_list().apply(Term::var("tail_0"))),
|
||||
)
|
||||
.delay(),
|
||||
)
|
||||
.force()
|
||||
.lambda("tail_0")
|
||||
.apply(
|
||||
Term::data(Data::list(vec![
|
||||
Data::integer(1.into()),
|
||||
Data::integer(2.into()),
|
||||
|
@ -5278,12 +5246,47 @@ fn expect_head_cast_data_no_tail() {
|
|||
Constant::Data(Data::integer(2.into())),
|
||||
Constant::Data(Data::integer(3.into())),
|
||||
])
|
||||
.choose_list(
|
||||
Term::var("expect[h]:List<Int>=a"),
|
||||
Term::var("__var")
|
||||
.choose_data(
|
||||
Term::var("expect[h]:List<Int>=a"),
|
||||
Term::var("expect[h]:List<Int>=a"),
|
||||
Term::var("expect[h]:List<Int>=a"),
|
||||
Term::tail_list()
|
||||
.apply(Term::list_values(vec![
|
||||
Constant::Data(Data::integer(1.into())),
|
||||
Constant::Data(Data::integer(2.into())),
|
||||
Constant::Data(Data::integer(3.into())),
|
||||
]))
|
||||
.choose_list(
|
||||
Term::equals_integer()
|
||||
.apply(Term::var("h"))
|
||||
.apply(Term::var("h"))
|
||||
.delay(),
|
||||
Term::var("expect[h]:List<Int>=a"),
|
||||
)
|
||||
.force()
|
||||
.lambda("h")
|
||||
.apply(Term::un_i_data().apply(Term::var("__var")))
|
||||
.delay(),
|
||||
Term::var("expect[h]:List<Int>=a"),
|
||||
)
|
||||
.force()
|
||||
.lambda("__var")
|
||||
.apply(Term::head_list().apply(Term::list_values(vec![
|
||||
Constant::Data(Data::integer(1.into())),
|
||||
Constant::Data(Data::integer(2.into())),
|
||||
Constant::Data(Data::integer(3.into())),
|
||||
])))
|
||||
.delay(),
|
||||
)
|
||||
.force()
|
||||
.delay(),
|
||||
Term::var("expect[h]:List<Int>=a"),
|
||||
Term::var("expect[h]:List<Int>=a"),
|
||||
)
|
||||
.force(),
|
||||
)
|
||||
.force()
|
||||
.lambda("expect[h]:List<Int>=a")
|
||||
.apply(
|
||||
Term::Error
|
||||
|
|
Loading…
Reference in New Issue