Inline now handles (if cond then body else error) patterns.
This allows conditions like ```expect x == 1``` to match performance with ```x == 1 && ...``` Also change builtins forcing to accommodate the new case-constr apply optimization
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
---
|
||||
source: crates/aiken-project/src/export.rs
|
||||
description: "Code:\n\npub type Foo<a> {\n Empty\n Bar(a, Foo<a>)\n}\n\npub fn add(a: Foo<Int>, b: Foo<Int>) -> Int {\n when (a, b) is {\n (Empty, Empty) -> 0\n (Bar(x, y), Bar(c, d)) -> x + c + add(y, d)\n (Empty, Bar(c, d)) -> c + add(Empty, d)\n (Bar(x, y), Empty) -> x + add(y, Empty)\n }\n}\n"
|
||||
snapshot_kind: text
|
||||
---
|
||||
{
|
||||
"name": "test_module.add",
|
||||
@@ -25,8 +24,8 @@ snapshot_kind: text
|
||||
"$ref": "#/definitions/Int"
|
||||
}
|
||||
},
|
||||
"compiledCode": "59017d0101003232323232322232323232325333008300430093754002264a666012600a60146ea800452000132337006eb4c038004cc011300103d8798000300e300f001300b37540026018601a00a264a66601266e1d2002300a37540022646466e00cdc01bad300f002375a601e0026600a601e6020004601e602000260186ea8008c02cdd500109919b80375a601c00266008601c601e002980103d8798000300b37540046018601a00a601600860020024446464a666014600c60166ea80044c94ccc02cc01cc030dd50008a400026466e00dd69808000999803803a60103d879800030103011001300d3754002601c601e004264a66601666e1d2002300c37540022646466e00cdc01bad3011002375a60220026660100106022602400460226024002601c6ea8008c034dd500109919b80375a602000266600e00e60206022002980103d8798000300d3754004601c601e004601a002660160046601600297ae0370e90001980300119803000a5eb815cd2ab9d5573cae815d0aba201",
|
||||
"hash": "c6af3f04e300cb8c1d0429cc0d8e56a0413eef9fcb338f72076b426c",
|
||||
"compiledCode": "59017d0101003333332222222232323232325333008300430093754002264a666012600a60146ea800452000132337006eb4c038004cc011300103d8798000300e300f001300b37540026018601a00a264a66601266e1d2002300a37540022646466e00cdc01bad300f002375a601e0026600a601e6020004601e602000260186ea8008c02cdd500109919b80375a601c00266008601c601e002980103d8798000300b37540046018601a00a601600860020024446464a666014600c60166ea80044c94ccc02cc01cc030dd50008a400026466e00dd69808000999803803a60103d879800030103011001300d3754002601c601e004264a66601666e1d2002300c37540022646466e00cdc01bad3011002375a60220026660100106022602400460226024002601c6ea8008c034dd500109919b80375a602000266600e00e60206022002980103d8798000300d3754004601c601e004601a002660160046601600297ae0370e90001980300119803000a5eb815d12ba15740aae7955ceab9a01",
|
||||
"hash": "1f7ba1be8ac6bba7b61d818e0f274b1feae61d24737dd9e833d59430",
|
||||
"definitions": {
|
||||
"Int": {
|
||||
"dataType": "integer"
|
||||
|
||||
@@ -64,6 +64,7 @@ fn assert_uplc(source_code: &str, expected: Term<Name>, should_fail: bool, verbo
|
||||
version: (1, 1, 0),
|
||||
term: expected,
|
||||
};
|
||||
println!("BEFORE OPT IS {}", expected.to_pretty());
|
||||
|
||||
let expected = optimize::aiken_optimize_and_intern(expected);
|
||||
|
||||
@@ -3603,7 +3604,7 @@ fn when_bool_is_true() {
|
||||
assert_uplc(
|
||||
src,
|
||||
Term::var("subject")
|
||||
.delayed_if_then_else(Term::bool(true), Term::Error)
|
||||
.delayed_if_then_else(Term::bool(true), Term::Error.delay().force())
|
||||
.lambda("subject")
|
||||
.apply(Term::bool(true)),
|
||||
false,
|
||||
@@ -3627,7 +3628,7 @@ fn when_bool_is_true_switched_cases() {
|
||||
assert_uplc(
|
||||
src,
|
||||
Term::var("subject")
|
||||
.delayed_if_then_else(Term::bool(true), Term::Error)
|
||||
.delayed_if_then_else(Term::bool(true), Term::Error.delay().force())
|
||||
.lambda("subject")
|
||||
.apply(Term::bool(true)),
|
||||
false,
|
||||
@@ -3651,7 +3652,7 @@ fn when_bool_is_false() {
|
||||
assert_uplc(
|
||||
src,
|
||||
Term::var("subject")
|
||||
.delayed_if_then_else(Term::bool(true), Term::Error)
|
||||
.delayed_if_then_else(Term::bool(true), Term::Error.delay().force())
|
||||
.lambda("subject")
|
||||
.apply(Term::bool(false)),
|
||||
true,
|
||||
@@ -4088,16 +4089,16 @@ fn generic_validator_type_test() {
|
||||
Term::tail_list()
|
||||
.apply(Term::Var(tail_id_5.clone()))
|
||||
.as_var("tail_id_6", |tail_id_6| {
|
||||
Term::head_list()
|
||||
Term::tail_list()
|
||||
.apply(Term::Var(tail_id_6.clone()))
|
||||
.as_var("__val", |val| {
|
||||
Term::tail_list()
|
||||
.delayed_choose_list(
|
||||
Term::head_list()
|
||||
.apply(Term::Var(tail_id_6))
|
||||
.delayed_choose_list(
|
||||
expect_b(val, Term::Var(then_delayed), trace),
|
||||
Term::Error,
|
||||
)
|
||||
})
|
||||
.as_var("__val", |val| {
|
||||
expect_b(val, Term::Var(then_delayed), trace)
|
||||
}),
|
||||
Term::Error,
|
||||
)
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user