Skip to content

Commit

Permalink
Fix missing delay in list_access_to_uplc. Also fix one of the unit te…
Browse files Browse the repository at this point in the history
…sts.
  • Loading branch information
MicroProofs authored and rvcas committed Jun 14, 2024
1 parent ef7fb31 commit 3529972
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 52 deletions.
3 changes: 2 additions & 1 deletion crates/aiken-lang/src/gen_uplc/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1517,7 +1517,8 @@ pub fn list_access_to_uplc(
.choose_list(acc.delay(), otherwise_delayed.clone())
.force()
.lambda(name)
.apply(head_item),
.apply(head_item)
.delay(),
)
.force()
.lambda(tail_name)
Expand Down
106 changes: 55 additions & 51 deletions crates/aiken-project/src/tests/gen_uplc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5065,17 +5065,17 @@ fn expect_head3_cast_data_no_tail() {
assert_uplc(
src,
Term::var("tail_0")
.delayed_choose_list(
Term::Error.delayed_trace(Term::var("expect[h,i,j]:List<Int>=a")),
.choose_list(
Term::var("expect[h,i,j]:List<Int>=a"),
Term::var("tail_1")
.delayed_choose_list(
Term::Error.delayed_trace(Term::var("expect[h,i,j]:List<Int>=a")),
.choose_list(
Term::var("expect[h,i,j]:List<Int>=a"),
Term::var("tail_2")
.delayed_choose_list(
Term::Error.delayed_trace(Term::var("expect[h,i,j]:List<Int>=a")),
.choose_list(
Term::var("expect[h,i,j]:List<Int>=a"),
Term::tail_list()
.apply(Term::var("tail_2"))
.delayed_choose_list(
.choose_list(
Term::equals_integer()
.apply(Term::var("h"))
.apply(Term::var("h"))
Expand All @@ -5090,89 +5090,93 @@ fn expect_head3_cast_data_no_tail() {
.apply(Term::var("j"))
.apply(Term::var("j")),
Term::bool(false),
),
Term::Error
.delayed_trace(Term::var("expect[h,i,j]:List<Int>=a")),
)
.delay(),
Term::var("expect[h,i,j]:List<Int>=a"),
)
.force()
.lambda("j")
.apply(
Term::var("__var")
.delayed_choose_data(
Term::Error.delayed_trace(Term::var(
"expect[h,i,j]:List<Int>=a",
)),
Term::Error.delayed_trace(Term::var(
"expect[h,i,j]:List<Int>=a",
)),
Term::Error.delayed_trace(Term::var(
"expect[h,i,j]:List<Int>=a",
)),
Term::un_i_data().apply(Term::var("__var")),
Term::Error.delayed_trace(Term::var(
"expect[h,i,j]:List<Int>=a",
)),
.choose_data(
Term::var("expect[h,i,j]:List<Int>=a"),
Term::var("expect[h,i,j]:List<Int>=a"),
Term::var("expect[h,i,j]:List<Int>=a"),
Term::un_i_data().apply(Term::var("__var")).delay(),
Term::var("expect[h,i,j]:List<Int>=a"),
)
.force()
.lambda("__var")
.apply(Term::head_list().apply(Term::var("tail_2"))),
),
)
.delay(),
)
.force()
.lambda("tail_2")
.apply(Term::tail_list().apply(Term::var("tail_1")))
.lambda("i")
.apply(
Term::var("__var")
.delayed_choose_data(
Term::Error
.delayed_trace(Term::var("expect[h,i,j]:List<Int>=a")),
Term::Error
.delayed_trace(Term::var("expect[h,i,j]:List<Int>=a")),
Term::Error
.delayed_trace(Term::var("expect[h,i,j]:List<Int>=a")),
Term::un_i_data().apply(Term::var("__var")),
Term::Error
.delayed_trace(Term::var("expect[h,i,j]:List<Int>=a")),
.choose_data(
Term::var("expect[h,i,j]:List<Int>=a"),
Term::var("expect[h,i,j]:List<Int>=a"),
Term::var("expect[h,i,j]:List<Int>=a"),
Term::un_i_data().apply(Term::var("__var")).delay(),
Term::var("expect[h,i,j]:List<Int>=a"),
)
.force()
.lambda("__var")
.apply(Term::head_list().apply(Term::var("tail_1"))),
),
)
.delay(),
)
.force()
.lambda("tail_1")
.apply(Term::tail_list().apply(Term::var("tail_0")))
.lambda("h")
.apply(
Term::var("__var")
.delayed_choose_data(
Term::Error.delayed_trace(Term::var("expect[h,i,j]:List<Int>=a")),
Term::Error.delayed_trace(Term::var("expect[h,i,j]:List<Int>=a")),
Term::Error.delayed_trace(Term::var("expect[h,i,j]:List<Int>=a")),
Term::un_i_data().apply(Term::var("__var")),
Term::Error.delayed_trace(Term::var("expect[h,i,j]:List<Int>=a")),
.choose_data(
Term::var("expect[h,i,j]:List<Int>=a"),
Term::var("expect[h,i,j]:List<Int>=a"),
Term::var("expect[h,i,j]:List<Int>=a"),
Term::un_i_data().apply(Term::var("__var")).delay(),
Term::var("expect[h,i,j]: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()),
Data::integer(3.into()),
]))
.delayed_choose_data(
Term::Error.delayed_trace(Term::var("expect[h,i,j]:List<Int>=a")),
Term::Error.delayed_trace(Term::var("expect[h,i,j]:List<Int>=a")),
.choose_data(
Term::var("expect[h,i,j]:List<Int>=a"),
Term::var("expect[h,i,j]:List<Int>=a"),
Term::list_values(vec![
Constant::Data(Data::integer(1.into())),
Constant::Data(Data::integer(2.into())),
Constant::Data(Data::integer(3.into())),
]),
Term::Error.delayed_trace(Term::var("expect[h,i,j]:List<Int>=a")),
Term::Error.delayed_trace(Term::var("expect[h,i,j]:List<Int>=a")),
),
])
.delay(),
Term::var("expect[h,i,j]:List<Int>=a"),
Term::var("expect[h,i,j]:List<Int>=a"),
)
.force(),
)
.lambda("expect[h,i,j]:List<Int>=a")
.apply(Term::string("expect [h, i, j]: List<Int> = a")),
.apply(
Term::Error
.delayed_trace(Term::string("expect [h, i, j]: List<Int> = a"))
.delay(),
),
false,
);
}
Expand Down

0 comments on commit 3529972

Please sign in to comment.