diff --git a/CHANGELOG.md b/CHANGELOG.md index 043a6aa0..bc2bc95f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,9 @@ afterwards in nested list cases. - **aiken-lang**: Fix for all elements were being destructured in tuple clauses even if not used. +- **aiken-lang**: Fix for tuple clause not consuming the next case causing + incomplete contracts. Now tuple clause will always consume the next case + unless it is the final clause ## v1.0.10-alpha - 2023-06-13 diff --git a/crates/aiken-lang/src/gen_uplc.rs b/crates/aiken-lang/src/gen_uplc.rs index f0fb2792..3218082c 100644 --- a/crates/aiken-lang/src/gen_uplc.rs +++ b/crates/aiken-lang/src/gen_uplc.rs @@ -969,7 +969,8 @@ impl<'a> CodeGenerator<'a> { subject_name, indices_to_define, prev_defined_tuple_indices, - *clause_properties.is_complex_clause(), + *clause_properties.is_complex_clause() + || (!*clause_properties.is_final_clause()), clause_pattern_stack, ); } diff --git a/examples/acceptance_tests/081/lib/tests.ak b/examples/acceptance_tests/081/lib/tests.ak index 0a7be9b4..9f152e45 100644 --- a/examples/acceptance_tests/081/lib/tests.ak +++ b/examples/acceptance_tests/081/lib/tests.ak @@ -1,15 +1,13 @@ use other.{FFF, GGG} test thing1() { - let x = - other.FFF + let x = other.FFF x == FFF } test thing2() { - let x = - other.GGG(2) + let x = other.GGG(2) x == GGG(2) } diff --git a/examples/acceptance_tests/084/aiken.lock b/examples/acceptance_tests/084/aiken.lock new file mode 100644 index 00000000..0423f31b --- /dev/null +++ b/examples/acceptance_tests/084/aiken.lock @@ -0,0 +1,13 @@ +# This file was generated by Aiken +# You typically do not need to edit this file + +[[requirements]] +name = "aiken-lang/stdlib" +version = "main" +source = "github" + +[[packages]] +name = "aiken-lang/stdlib" +version = "main" +requirements = [] +source = "github" diff --git a/examples/acceptance_tests/084/aiken.toml b/examples/acceptance_tests/084/aiken.toml new file mode 100644 index 00000000..1d26e775 --- /dev/null +++ b/examples/acceptance_tests/084/aiken.toml @@ -0,0 +1,8 @@ +name = "aiken-lang/acceptance_test_083" +version = "0.0.0" +description = "" + +[[dependencies]] +name = 'aiken-lang/stdlib' +version = 'main' +source = 'github' diff --git a/examples/acceptance_tests/084/lib/tests.ak b/examples/acceptance_tests/084/lib/tests.ak new file mode 100644 index 00000000..962b5a6a --- /dev/null +++ b/examples/acceptance_tests/084/lib/tests.ak @@ -0,0 +1,22 @@ +use aiken/list + +test tuple_when() { + let items = + [(#"", #"", 50), (#"aa", #"bb", 70)] + + let amount = 70 + let policy = #"aa" + + let filtered = + list.filter( + items, + fn(item) { + when item is { + (token_policy, _, token_amount) -> + amount == token_amount && policy == token_policy + _ -> False + } + }, + ) + list.length(filtered) > 0 +}