From 3c02ba11e9df27fbd5918be22ca9b1a8f6b46e87 Mon Sep 17 00:00:00 2001 From: "Brian R. Murphy" <132495859+brmataptos@users.noreply.github.com> Date: Wed, 27 Nov 2024 02:23:28 -0800 Subject: [PATCH] address PR 15365 comments as of 11/26 --- .../src/env_pipeline/lambda_lifter.rs | 8 +- .../inlining/function_name_shadowing.exp | 50 +- .../inlining/function_name_shadowing.move | 19 +- .../tests/lambda/storable/closure_args.exp | 781 +++ .../lambda/storable/closure_args.lambda.exp | 5456 +++++++++++++++++ .../tests/lambda/storable/closure_args.move | 287 + .../lambda/storable/return_func_ok.lambda.exp | 4 +- .../inlining/function_name_shadowing.exp | 28 +- .../inlining/function_name_shadowing.move | 19 +- .../inlining/function_name_shadowing.move | 30 + .../inlining/function_name_shadowing.exp | 4 + .../inlining/function_name_shadowing.move | 30 + 12 files changed, 6684 insertions(+), 32 deletions(-) create mode 100644 third_party/move/move-compiler-v2/tests/lambda/storable/closure_args.exp create mode 100644 third_party/move/move-compiler-v2/tests/lambda/storable/closure_args.lambda.exp create mode 100644 third_party/move/move-compiler-v2/tests/lambda/storable/closure_args.move create mode 100644 third_party/move/move-compiler/tests/move_check/inlining/function_name_shadowing.move create mode 100644 third_party/move/move-compiler/transactional-tests/tests/inlining/function_name_shadowing.exp create mode 100644 third_party/move/move-compiler/transactional-tests/tests/inlining/function_name_shadowing.move diff --git a/third_party/move/move-compiler-v2/src/env_pipeline/lambda_lifter.rs b/third_party/move/move-compiler-v2/src/env_pipeline/lambda_lifter.rs index 84ab3bcf3424a..b7426dc5f20c9 100644 --- a/third_party/move/move-compiler-v2/src/env_pipeline/lambda_lifter.rs +++ b/third_party/move/move-compiler-v2/src/env_pipeline/lambda_lifter.rs @@ -692,11 +692,7 @@ impl<'a> ExpRewriterFunctions for LambdaLifter<'a> { // param_index_mapping = for each free var which is a Parameter from the enclosing function, // a mapping from index there to index in the params list; other free vars are // substituted automatically by using the same symbol for the param - let Some((mut params, mut closure_args, param_index_mapping)) = - self.get_params_for_freevars() - else { - return None; - }; + let (mut params, mut closure_args, param_index_mapping) = self.get_params_for_freevars()?; // Some(ExpData::Invalid(env.clone_node(id)).into_exp()); // Add lambda args. For dealing with patterns in lambdas (`|S{..}|e`) we need @@ -764,7 +760,7 @@ impl<'a> ExpRewriterFunctions for LambdaLifter<'a> { env.error( &loc, // TODO(LAMBDA) - "Lambdas expressions with `store` ability currently may only be a simple call to an existing `public` function. This lambda expression requires defining a `public` helper function, which might affect module upgradeability and is not yet supported." + "The body of a lambdas expression with `store` ability currently must be a simple call to an existing `public` function, with lambda params the same as the *final* arguments to the function call." ); return None; }; diff --git a/third_party/move/move-compiler-v2/tests/checking/inlining/function_name_shadowing.exp b/third_party/move/move-compiler-v2/tests/checking/inlining/function_name_shadowing.exp index c0a5cb1e19658..ff76888fa7377 100644 --- a/third_party/move/move-compiler-v2/tests/checking/inlining/function_name_shadowing.exp +++ b/third_party/move/move-compiler-v2/tests/checking/inlining/function_name_shadowing.exp @@ -1,34 +1,64 @@ Diagnostics: warning: Unused parameter `f`. Consider removing or prefixing with an underscore: `_f` - ┌─ tests/checking/inlining/function_name_shadowing.move:8:28 - │ -8 │ public inline fun quux(f:|u64, u64|u64, a: u64, b: u64): u64 { - │ ^ + ┌─ tests/checking/inlining/function_name_shadowing.move:20:28 + │ +20 │ public inline fun quux(f:|u64, u64|u64, g:|u64|u64, i:|u8|u8, a: u64, b: u64): u64 { + │ ^ + +warning: Unused parameter `g`. Consider removing or prefixing with an underscore: `_g` + ┌─ tests/checking/inlining/function_name_shadowing.move:20:45 + │ +20 │ public inline fun quux(f:|u64, u64|u64, g:|u64|u64, i:|u8|u8, a: u64, b: u64): u64 { + │ ^ + +warning: Unused parameter `i`. Consider removing or prefixing with an underscore: `_i` + ┌─ tests/checking/inlining/function_name_shadowing.move:20:57 + │ +20 │ public inline fun quux(f:|u64, u64|u64, g:|u64|u64, i:|u8|u8, a: u64, b: u64): u64 { + │ ^ // -- Model dump before bytecode pipeline +module 0x42::OtherModule { + public fun g(a: u64,b: u64): u64 { + Add(a, b) + } + public fun h(a: u64,b: u64): u64 { + Add(Mul(2, a), b) + } +} // end 0x42::OtherModule module 0x42::Test { + use 0x42::OtherModule::{g}; // resolved as: 0x42::OtherModule public fun f(a: u64,b: u64): u64 { Mul(a, b) } - public inline fun quux(f: |(u64, u64)|u64,a: u64,b: u64): u64 { - Test::f(a, b) + public inline fun quux(f: |(u64, u64)|u64,g: |u64|u64,i: |u8|u8,a: u64,b: u64): u64 { + Mul(Mul(Test::f(a, b), OtherModule::g(a, b)), OtherModule::h(a, b)) } public fun test_shadowing(): u64 { - Test::f(10, 2) + Mul(Mul(Test::f(10, 2), OtherModule::g(10, 2)), OtherModule::h(10, 2)) } } // end 0x42::Test // -- Sourcified model before bytecode pipeline +module 0x42::OtherModule { + public fun g(a: u64, b: u64): u64 { + a + b + } + public fun h(a: u64, b: u64): u64 { + 2 * a + b + } +} module 0x42::Test { + use 0x42::OtherModule; public fun f(a: u64, b: u64): u64 { a * b } - public inline fun quux(f: |(u64, u64)|u64, a: u64, b: u64): u64 { - f(a, b) + public inline fun quux(f: |(u64, u64)|u64, g: |u64|u64, i: |u8|u8, a: u64, b: u64): u64 { + f(a, b) * OtherModule::g(a, b) * OtherModule::h(a, b) } public fun test_shadowing(): u64 { - f(10, 2) + f(10, 2) * OtherModule::g(10, 2) * OtherModule::h(10, 2) } } diff --git a/third_party/move/move-compiler-v2/tests/checking/inlining/function_name_shadowing.move b/third_party/move/move-compiler-v2/tests/checking/inlining/function_name_shadowing.move index 4867cdfbb3f88..e527c426c7eef 100644 --- a/third_party/move/move-compiler-v2/tests/checking/inlining/function_name_shadowing.move +++ b/third_party/move/move-compiler-v2/tests/checking/inlining/function_name_shadowing.move @@ -1,16 +1,29 @@ +//# publish +module 0x42::OtherModule { + public fun g(a: u64, b: u64): u64 { + a + b + } + + public fun h(a: u64, b: u64): u64 { + 2 * a + b + } +} + //# publish module 0x42::Test { + use 0x42::OtherModule::g; public fun f(a: u64, b: u64): u64 { a * b } - public inline fun quux(f:|u64, u64|u64, a: u64, b: u64): u64 { - f(a, b) + public inline fun quux(f:|u64, u64|u64, g:|u64|u64, i:|u8|u8, a: u64, b: u64): u64 { + use 0x42::OtherModule::h; + f(a, b) * g(a, b) * h(a, b) } public fun test_shadowing(): u64 { - quux(|a, b| a - b, 10, 2) + quux(|a, b| a - b, |a| a + 2, |b| 255u8-b, 10, 2) } } diff --git a/third_party/move/move-compiler-v2/tests/lambda/storable/closure_args.exp b/third_party/move/move-compiler-v2/tests/lambda/storable/closure_args.exp new file mode 100644 index 0000000000000..c3015376ea32d --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/lambda/storable/closure_args.exp @@ -0,0 +1,781 @@ + +Diagnostics: +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:59:17 + │ +59 │ move |x| base_fun(a, x) + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:61:17 + │ +61 │ move |x| base_fun2(x, a) + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:63:17 + │ +63 │ move |x| copy_fun(a_copy, x) + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:65:17 + │ +65 │ move |x| copy_fun2(x, a_copy) + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:67:17 + │ +67 │ move |x| store_fun(a_store, x) + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:69:17 + │ +69 │ move |x| store_fun2(x, a_store) + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:71:17 + │ +71 │ move |x| both_fun(a_both, x) + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:73:17 + │ +73 │ move |x| both_fun2(x, a_both) + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:75:17 + │ +75 │ move |x| x * 2 + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:88:17 + │ +88 │ move |x| base_fun(a, x) + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:90:17 + │ +90 │ move |x| base_fun2(x, a) + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:92:17 + │ +92 │ move |x| copy_fun(a_copy, x) + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:94:17 + │ +94 │ move |x| copy_fun2(x, a_copy) + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:96:17 + │ +96 │ move |x| store_fun(a_store, x) + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:98:17 + │ +98 │ move |x| store_fun2(x, a_store) + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:100:17 + │ +100 │ move |x| both_fun(a_both, x) + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:102:17 + │ +102 │ move |x| both_fun2(x, a_both) + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:104:17 + │ +104 │ move |x| x * 2 with copy + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:104:32 + │ +104 │ move |x| x * 2 with copy + │ ^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:119:17 + │ +119 │ move |x| base_fun(a, x) with copy + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:119:41 + │ +119 │ move |x| base_fun(a, x) with copy + │ ^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:121:17 + │ +121 │ move |x| base_fun2(x, a) with copy + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:121:42 + │ +121 │ move |x| base_fun2(x, a) with copy + │ ^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:123:17 + │ +123 │ move |x| copy_fun(a_copy, x) with copy + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:123:46 + │ +123 │ move |x| copy_fun(a_copy, x) with copy + │ ^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:125:17 + │ +125 │ move |x| copy_fun2(x, a_copy) with copy + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:125:47 + │ +125 │ move |x| copy_fun2(x, a_copy) with copy + │ ^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:127:17 + │ +127 │ move |x| store_fun(a_store, x) with copy + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:127:48 + │ +127 │ move |x| store_fun(a_store, x) with copy + │ ^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:129:17 + │ +129 │ move |x| store_fun2(x, a_store) with copy + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:129:49 + │ +129 │ move |x| store_fun2(x, a_store) with copy + │ ^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:131:17 + │ +131 │ move |x| both_fun(a_both, x) with copy + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:131:46 + │ +131 │ move |x| both_fun(a_both, x) with copy + │ ^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:133:17 + │ +133 │ move |x| both_fun2(x, a_both) with copy + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:133:47 + │ +133 │ move |x| both_fun2(x, a_both) with copy + │ ^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:135:17 + │ +135 │ move |x| x * 2 with copy + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:135:32 + │ +135 │ move |x| x * 2 with copy + │ ^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:140:65 + │ +140 │ public fun return_function_copy(key: u64, x: u64): |u64|u64 with copy { + │ ^^^^^^^^^ Move 2.2 language construct is not enabled: Ability constraints on function types + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:148:17 + │ +148 │ move |x| base_fun(a, x) with copy + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:148:41 + │ +148 │ move |x| base_fun(a, x) with copy + │ ^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:150:17 + │ +150 │ move |x| base_fun2(x, a) with copy + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:150:42 + │ +150 │ move |x| base_fun2(x, a) with copy + │ ^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:152:17 + │ +152 │ move |x| copy_fun(a_copy, x) with copy + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:152:46 + │ +152 │ move |x| copy_fun(a_copy, x) with copy + │ ^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:154:17 + │ +154 │ move |x| copy_fun2(x, a_copy) with copy + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:154:47 + │ +154 │ move |x| copy_fun2(x, a_copy) with copy + │ ^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:156:17 + │ +156 │ move |x| store_fun(a_store, x) with copy + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:156:48 + │ +156 │ move |x| store_fun(a_store, x) with copy + │ ^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:158:17 + │ +158 │ move |x| store_fun2(x, a_store) with copy + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:158:49 + │ +158 │ move |x| store_fun2(x, a_store) with copy + │ ^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:160:17 + │ +160 │ move |x| both_fun(a_both, x) with copy + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:160:46 + │ +160 │ move |x| both_fun(a_both, x) with copy + │ ^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:162:17 + │ +162 │ move |x| both_fun2(x, a_both) with copy + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:162:47 + │ +162 │ move |x| both_fun2(x, a_both) with copy + │ ^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:164:17 + │ +164 │ move |x| x * 2 with copy + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:164:32 + │ +164 │ move |x| x * 2 with copy + │ ^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:178:17 + │ +178 │ move |x| base_fun(a, x) with store + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:178:41 + │ +178 │ move |x| base_fun(a, x) with store + │ ^^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:180:17 + │ +180 │ move |x| base_fun2(x, a) with store + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:180:42 + │ +180 │ move |x| base_fun2(x, a) with store + │ ^^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:182:17 + │ +182 │ move |x| copy_fun(a_copy, x) with store + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:182:46 + │ +182 │ move |x| copy_fun(a_copy, x) with store + │ ^^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:184:17 + │ +184 │ move |x| copy_fun2(x, a_copy) with store + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:184:47 + │ +184 │ move |x| copy_fun2(x, a_copy) with store + │ ^^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:186:17 + │ +186 │ move |x| store_fun(a_store, x) with store + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:186:48 + │ +186 │ move |x| store_fun(a_store, x) with store + │ ^^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:188:17 + │ +188 │ move |x| store_fun2(x, a_store) with store + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:188:49 + │ +188 │ move |x| store_fun2(x, a_store) with store + │ ^^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:190:17 + │ +190 │ move |x| both_fun(a_both, x) with store + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:190:46 + │ +190 │ move |x| both_fun(a_both, x) with store + │ ^^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:192:17 + │ +192 │ move |x| both_fun2(x, a_both) with store + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:192:47 + │ +192 │ move |x| both_fun2(x, a_both) with store + │ ^^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:194:17 + │ +194 │ move |x| x * 2 with store + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:194:32 + │ +194 │ move |x| x * 2 with store + │ ^^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:199:66 + │ +199 │ public fun return_function_store(key: u64, x: u64): |u64|u64 with store { + │ ^^^^^^^^^^ Move 2.2 language construct is not enabled: Ability constraints on function types + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:207:17 + │ +207 │ move |x| base_fun(a, x) with store + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:207:41 + │ +207 │ move |x| base_fun(a, x) with store + │ ^^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:209:17 + │ +209 │ move |x| base_fun2(x, a) with store + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:209:42 + │ +209 │ move |x| base_fun2(x, a) with store + │ ^^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:211:17 + │ +211 │ move |x| copy_fun(a_copy, x) with store + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:211:46 + │ +211 │ move |x| copy_fun(a_copy, x) with store + │ ^^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:213:17 + │ +213 │ move |x| copy_fun2(x, a_copy) with store + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:213:47 + │ +213 │ move |x| copy_fun2(x, a_copy) with store + │ ^^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:215:17 + │ +215 │ move |x| store_fun(a_store, x) with store + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:215:48 + │ +215 │ move |x| store_fun(a_store, x) with store + │ ^^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:217:17 + │ +217 │ move |x| store_fun2(x, a_store) with store + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:217:49 + │ +217 │ move |x| store_fun2(x, a_store) with store + │ ^^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:219:17 + │ +219 │ move |x| both_fun(a_both, x) with store + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:219:46 + │ +219 │ move |x| both_fun(a_both, x) with store + │ ^^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:221:17 + │ +221 │ move |x| both_fun2(x, a_both) with store + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:221:47 + │ +221 │ move |x| both_fun2(x, a_both) with store + │ ^^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:223:17 + │ +223 │ move |x| x * 2 with store + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:223:32 + │ +223 │ move |x| x * 2 with store + │ ^^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:238:17 + │ +238 │ move |x| base_fun(a, x) with store+copy + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:238:41 + │ +238 │ move |x| base_fun(a, x) with store+copy + │ ^^^^^^^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:240:17 + │ +240 │ move |x| base_fun2(x, a) with store+copy + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:240:42 + │ +240 │ move |x| base_fun2(x, a) with store+copy + │ ^^^^^^^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:242:17 + │ +242 │ move |x| copy_fun(a_copy, x) with store+copy + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:242:46 + │ +242 │ move |x| copy_fun(a_copy, x) with store+copy + │ ^^^^^^^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:244:17 + │ +244 │ move |x| copy_fun2(x, a_copy) with store+copy + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:244:47 + │ +244 │ move |x| copy_fun2(x, a_copy) with store+copy + │ ^^^^^^^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:246:17 + │ +246 │ move |x| store_fun(a_store, x) with store+copy + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:246:48 + │ +246 │ move |x| store_fun(a_store, x) with store+copy + │ ^^^^^^^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:248:17 + │ +248 │ move |x| store_fun2(x, a_store) with store+copy + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:248:49 + │ +248 │ move |x| store_fun2(x, a_store) with store+copy + │ ^^^^^^^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:250:17 + │ +250 │ move |x| both_fun(a_both, x) with store+copy + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:250:46 + │ +250 │ move |x| both_fun(a_both, x) with store+copy + │ ^^^^^^^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:252:17 + │ +252 │ move |x| both_fun2(x, a_both) with store+copy + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:252:47 + │ +252 │ move |x| both_fun2(x, a_both) with store+copy + │ ^^^^^^^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:254:17 + │ +254 │ move |x| x * 2 with store+copy + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:254:32 + │ +254 │ move |x| x * 2 with store+copy + │ ^^^^^^^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:259:65 + │ +259 │ public fun return_function_both(key: u64, x: u64): |u64|u64 with store+copy { + │ ^^^^^^^^^^^^^^^ Move 2.2 language construct is not enabled: Ability constraints on function types + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:267:17 + │ +267 │ move |x| base_fun(a, x) with store+copy + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:267:41 + │ +267 │ move |x| base_fun(a, x) with store+copy + │ ^^^^^^^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:269:17 + │ +269 │ move |x| base_fun2(x, a) with store+copy + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:269:42 + │ +269 │ move |x| base_fun2(x, a) with store+copy + │ ^^^^^^^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:271:17 + │ +271 │ move |x| copy_fun(a_copy, x) with store+copy + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:271:46 + │ +271 │ move |x| copy_fun(a_copy, x) with store+copy + │ ^^^^^^^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:273:17 + │ +273 │ move |x| copy_fun2(x, a_copy) with store+copy + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:273:47 + │ +273 │ move |x| copy_fun2(x, a_copy) with store+copy + │ ^^^^^^^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:275:17 + │ +275 │ move |x| store_fun(a_store, x) with store+copy + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:275:48 + │ +275 │ move |x| store_fun(a_store, x) with store+copy + │ ^^^^^^^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:277:17 + │ +277 │ move |x| store_fun2(x, a_store) with store+copy + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:277:49 + │ +277 │ move |x| store_fun2(x, a_store) with store+copy + │ ^^^^^^^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:279:17 + │ +279 │ move |x| both_fun(a_both, x) with store+copy + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:279:46 + │ +279 │ move |x| both_fun(a_both, x) with store+copy + │ ^^^^^^^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:281:17 + │ +281 │ move |x| both_fun2(x, a_both) with store+copy + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:281:47 + │ +281 │ move |x| both_fun2(x, a_both) with store+copy + │ ^^^^^^^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:283:17 + │ +283 │ move |x| x * 2 with store+copy + │ ^^^^ Move 2.2 language construct is not enabled: Modifier on lambda expression + +error: unsupported language construct + ┌─ tests/lambda/storable/closure_args.move:283:32 + │ +283 │ move |x| x * 2 with store+copy + │ ^^^^^^^^^^^^^^^ Move 2.2 language construct is not enabled: Abilities on function expressions diff --git a/third_party/move/move-compiler-v2/tests/lambda/storable/closure_args.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/storable/closure_args.lambda.exp new file mode 100644 index 0000000000000..4eb52de9bb606 --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/lambda/storable/closure_args.lambda.exp @@ -0,0 +1,5456 @@ +// -- Model dump before env processor pipeline: +module 0x42::mod1 { + struct S { + x: u64, + } + struct Sboth { + x: u64, + } + struct Scopy { + x: u64, + } + struct Sstore { + x: u64, + } + public fun base_fun(a: S,b: u64): u64 { + Mul(select mod1::S.x(a), b) + } + public fun base_fun2(a: u64,b: S): u64 { + Mul(a, select mod1::S.x(b)) + } + public fun both_fun(a: Sboth,b: u64): u64 { + Mul(select mod1::Sboth.x(a), b) + } + public fun both_fun2(a: u64,b: Sboth): u64 { + Mul(a, select mod1::Sboth.x(b)) + } + public fun copy_fun(a: Scopy,b: u64): u64 { + Mul(select mod1::Scopy.x(a), b) + } + public fun copy_fun2(a: u64,b: Scopy): u64 { + Mul(a, select mod1::Scopy.x(b)) + } + public fun return_function_base(key: u64,x: u64): |u64|u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) + } else { + move|x: u64| Mul(x, 2) with copy, drop + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun return_function_both(key: u64,x: u64): |u64|u64 with copy+drop+store { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop, store + } else { + move|x: u64| Mul(x, 2) with copy, drop, store + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun return_function_copy(key: u64,x: u64): |u64|u64 with copy+drop { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop + } else { + move|x: u64| Mul(x, 2) with copy, drop + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun return_function_store(key: u64,x: u64): |u64|u64 with drop+store { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with drop, store + } else { + move|x: u64| Mul(x, 2) with drop, store + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun store_fun(a: Sstore,b: u64): u64 { + Mul(select mod1::Sstore.x(a), b) + } + public fun store_fun2(a: u64,b: Sstore): u64 { + Mul(a, select mod1::Sstore.x(b)) + } + public fun use_function_base(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) + } else { + move|x: u64| Mul(x, 2) + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } + public fun use_function_both(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop, store + } else { + move|x: u64| Mul(x, 2) with copy, drop, store + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } + public fun use_function_copy(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop + } else { + move|x: u64| Mul(x, 2) with copy, drop + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } + public fun use_function_store(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with drop, store + } else { + move|x: u64| Mul(x, 2) with drop, store + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } +} // end 0x42::mod1 + + +// -- Model dump after env processor unused checks: +module 0x42::mod1 { + struct S { + x: u64, + } + struct Sboth { + x: u64, + } + struct Scopy { + x: u64, + } + struct Sstore { + x: u64, + } + public fun base_fun(a: S,b: u64): u64 { + Mul(select mod1::S.x(a), b) + } + public fun base_fun2(a: u64,b: S): u64 { + Mul(a, select mod1::S.x(b)) + } + public fun both_fun(a: Sboth,b: u64): u64 { + Mul(select mod1::Sboth.x(a), b) + } + public fun both_fun2(a: u64,b: Sboth): u64 { + Mul(a, select mod1::Sboth.x(b)) + } + public fun copy_fun(a: Scopy,b: u64): u64 { + Mul(select mod1::Scopy.x(a), b) + } + public fun copy_fun2(a: u64,b: Scopy): u64 { + Mul(a, select mod1::Scopy.x(b)) + } + public fun return_function_base(key: u64,x: u64): |u64|u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) + } else { + move|x: u64| Mul(x, 2) with copy, drop + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun return_function_both(key: u64,x: u64): |u64|u64 with copy+drop+store { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop, store + } else { + move|x: u64| Mul(x, 2) with copy, drop, store + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun return_function_copy(key: u64,x: u64): |u64|u64 with copy+drop { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop + } else { + move|x: u64| Mul(x, 2) with copy, drop + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun return_function_store(key: u64,x: u64): |u64|u64 with drop+store { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with drop, store + } else { + move|x: u64| Mul(x, 2) with drop, store + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun store_fun(a: Sstore,b: u64): u64 { + Mul(select mod1::Sstore.x(a), b) + } + public fun store_fun2(a: u64,b: Sstore): u64 { + Mul(a, select mod1::Sstore.x(b)) + } + public fun use_function_base(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) + } else { + move|x: u64| Mul(x, 2) + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } + public fun use_function_both(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop, store + } else { + move|x: u64| Mul(x, 2) with copy, drop, store + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } + public fun use_function_copy(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop + } else { + move|x: u64| Mul(x, 2) with copy, drop + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } + public fun use_function_store(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with drop, store + } else { + move|x: u64| Mul(x, 2) with drop, store + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } +} // end 0x42::mod1 + + +// -- Model dump after env processor type parameter check: +module 0x42::mod1 { + struct S { + x: u64, + } + struct Sboth { + x: u64, + } + struct Scopy { + x: u64, + } + struct Sstore { + x: u64, + } + public fun base_fun(a: S,b: u64): u64 { + Mul(select mod1::S.x(a), b) + } + public fun base_fun2(a: u64,b: S): u64 { + Mul(a, select mod1::S.x(b)) + } + public fun both_fun(a: Sboth,b: u64): u64 { + Mul(select mod1::Sboth.x(a), b) + } + public fun both_fun2(a: u64,b: Sboth): u64 { + Mul(a, select mod1::Sboth.x(b)) + } + public fun copy_fun(a: Scopy,b: u64): u64 { + Mul(select mod1::Scopy.x(a), b) + } + public fun copy_fun2(a: u64,b: Scopy): u64 { + Mul(a, select mod1::Scopy.x(b)) + } + public fun return_function_base(key: u64,x: u64): |u64|u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) + } else { + move|x: u64| Mul(x, 2) with copy, drop + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun return_function_both(key: u64,x: u64): |u64|u64 with copy+drop+store { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop, store + } else { + move|x: u64| Mul(x, 2) with copy, drop, store + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun return_function_copy(key: u64,x: u64): |u64|u64 with copy+drop { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop + } else { + move|x: u64| Mul(x, 2) with copy, drop + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun return_function_store(key: u64,x: u64): |u64|u64 with drop+store { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with drop, store + } else { + move|x: u64| Mul(x, 2) with drop, store + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun store_fun(a: Sstore,b: u64): u64 { + Mul(select mod1::Sstore.x(a), b) + } + public fun store_fun2(a: u64,b: Sstore): u64 { + Mul(a, select mod1::Sstore.x(b)) + } + public fun use_function_base(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) + } else { + move|x: u64| Mul(x, 2) + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } + public fun use_function_both(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop, store + } else { + move|x: u64| Mul(x, 2) with copy, drop, store + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } + public fun use_function_copy(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop + } else { + move|x: u64| Mul(x, 2) with copy, drop + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } + public fun use_function_store(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with drop, store + } else { + move|x: u64| Mul(x, 2) with drop, store + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } +} // end 0x42::mod1 + + +// -- Model dump after env processor check recursive struct definition: +module 0x42::mod1 { + struct S { + x: u64, + } + struct Sboth { + x: u64, + } + struct Scopy { + x: u64, + } + struct Sstore { + x: u64, + } + public fun base_fun(a: S,b: u64): u64 { + Mul(select mod1::S.x(a), b) + } + public fun base_fun2(a: u64,b: S): u64 { + Mul(a, select mod1::S.x(b)) + } + public fun both_fun(a: Sboth,b: u64): u64 { + Mul(select mod1::Sboth.x(a), b) + } + public fun both_fun2(a: u64,b: Sboth): u64 { + Mul(a, select mod1::Sboth.x(b)) + } + public fun copy_fun(a: Scopy,b: u64): u64 { + Mul(select mod1::Scopy.x(a), b) + } + public fun copy_fun2(a: u64,b: Scopy): u64 { + Mul(a, select mod1::Scopy.x(b)) + } + public fun return_function_base(key: u64,x: u64): |u64|u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) + } else { + move|x: u64| Mul(x, 2) with copy, drop + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun return_function_both(key: u64,x: u64): |u64|u64 with copy+drop+store { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop, store + } else { + move|x: u64| Mul(x, 2) with copy, drop, store + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun return_function_copy(key: u64,x: u64): |u64|u64 with copy+drop { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop + } else { + move|x: u64| Mul(x, 2) with copy, drop + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun return_function_store(key: u64,x: u64): |u64|u64 with drop+store { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with drop, store + } else { + move|x: u64| Mul(x, 2) with drop, store + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun store_fun(a: Sstore,b: u64): u64 { + Mul(select mod1::Sstore.x(a), b) + } + public fun store_fun2(a: u64,b: Sstore): u64 { + Mul(a, select mod1::Sstore.x(b)) + } + public fun use_function_base(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) + } else { + move|x: u64| Mul(x, 2) + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } + public fun use_function_both(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop, store + } else { + move|x: u64| Mul(x, 2) with copy, drop, store + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } + public fun use_function_copy(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop + } else { + move|x: u64| Mul(x, 2) with copy, drop + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } + public fun use_function_store(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with drop, store + } else { + move|x: u64| Mul(x, 2) with drop, store + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } +} // end 0x42::mod1 + + +// -- Model dump after env processor check cyclic type instantiation: +module 0x42::mod1 { + struct S { + x: u64, + } + struct Sboth { + x: u64, + } + struct Scopy { + x: u64, + } + struct Sstore { + x: u64, + } + public fun base_fun(a: S,b: u64): u64 { + Mul(select mod1::S.x(a), b) + } + public fun base_fun2(a: u64,b: S): u64 { + Mul(a, select mod1::S.x(b)) + } + public fun both_fun(a: Sboth,b: u64): u64 { + Mul(select mod1::Sboth.x(a), b) + } + public fun both_fun2(a: u64,b: Sboth): u64 { + Mul(a, select mod1::Sboth.x(b)) + } + public fun copy_fun(a: Scopy,b: u64): u64 { + Mul(select mod1::Scopy.x(a), b) + } + public fun copy_fun2(a: u64,b: Scopy): u64 { + Mul(a, select mod1::Scopy.x(b)) + } + public fun return_function_base(key: u64,x: u64): |u64|u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) + } else { + move|x: u64| Mul(x, 2) with copy, drop + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun return_function_both(key: u64,x: u64): |u64|u64 with copy+drop+store { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop, store + } else { + move|x: u64| Mul(x, 2) with copy, drop, store + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun return_function_copy(key: u64,x: u64): |u64|u64 with copy+drop { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop + } else { + move|x: u64| Mul(x, 2) with copy, drop + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun return_function_store(key: u64,x: u64): |u64|u64 with drop+store { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with drop, store + } else { + move|x: u64| Mul(x, 2) with drop, store + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun store_fun(a: Sstore,b: u64): u64 { + Mul(select mod1::Sstore.x(a), b) + } + public fun store_fun2(a: u64,b: Sstore): u64 { + Mul(a, select mod1::Sstore.x(b)) + } + public fun use_function_base(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) + } else { + move|x: u64| Mul(x, 2) + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } + public fun use_function_both(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop, store + } else { + move|x: u64| Mul(x, 2) with copy, drop, store + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } + public fun use_function_copy(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop + } else { + move|x: u64| Mul(x, 2) with copy, drop + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } + public fun use_function_store(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with drop, store + } else { + move|x: u64| Mul(x, 2) with drop, store + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } +} // end 0x42::mod1 + + +// -- Model dump after env processor unused struct params check: +module 0x42::mod1 { + struct S { + x: u64, + } + struct Sboth { + x: u64, + } + struct Scopy { + x: u64, + } + struct Sstore { + x: u64, + } + public fun base_fun(a: S,b: u64): u64 { + Mul(select mod1::S.x(a), b) + } + public fun base_fun2(a: u64,b: S): u64 { + Mul(a, select mod1::S.x(b)) + } + public fun both_fun(a: Sboth,b: u64): u64 { + Mul(select mod1::Sboth.x(a), b) + } + public fun both_fun2(a: u64,b: Sboth): u64 { + Mul(a, select mod1::Sboth.x(b)) + } + public fun copy_fun(a: Scopy,b: u64): u64 { + Mul(select mod1::Scopy.x(a), b) + } + public fun copy_fun2(a: u64,b: Scopy): u64 { + Mul(a, select mod1::Scopy.x(b)) + } + public fun return_function_base(key: u64,x: u64): |u64|u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) + } else { + move|x: u64| Mul(x, 2) with copy, drop + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun return_function_both(key: u64,x: u64): |u64|u64 with copy+drop+store { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop, store + } else { + move|x: u64| Mul(x, 2) with copy, drop, store + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun return_function_copy(key: u64,x: u64): |u64|u64 with copy+drop { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop + } else { + move|x: u64| Mul(x, 2) with copy, drop + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun return_function_store(key: u64,x: u64): |u64|u64 with drop+store { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with drop, store + } else { + move|x: u64| Mul(x, 2) with drop, store + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun store_fun(a: Sstore,b: u64): u64 { + Mul(select mod1::Sstore.x(a), b) + } + public fun store_fun2(a: u64,b: Sstore): u64 { + Mul(a, select mod1::Sstore.x(b)) + } + public fun use_function_base(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) + } else { + move|x: u64| Mul(x, 2) + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } + public fun use_function_both(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop, store + } else { + move|x: u64| Mul(x, 2) with copy, drop, store + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } + public fun use_function_copy(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop + } else { + move|x: u64| Mul(x, 2) with copy, drop + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } + public fun use_function_store(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with drop, store + } else { + move|x: u64| Mul(x, 2) with drop, store + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } +} // end 0x42::mod1 + + +// -- Model dump after env processor access and use check before inlining: +module 0x42::mod1 { + struct S { + x: u64, + } + struct Sboth { + x: u64, + } + struct Scopy { + x: u64, + } + struct Sstore { + x: u64, + } + public fun base_fun(a: S,b: u64): u64 { + Mul(select mod1::S.x(a), b) + } + public fun base_fun2(a: u64,b: S): u64 { + Mul(a, select mod1::S.x(b)) + } + public fun both_fun(a: Sboth,b: u64): u64 { + Mul(select mod1::Sboth.x(a), b) + } + public fun both_fun2(a: u64,b: Sboth): u64 { + Mul(a, select mod1::Sboth.x(b)) + } + public fun copy_fun(a: Scopy,b: u64): u64 { + Mul(select mod1::Scopy.x(a), b) + } + public fun copy_fun2(a: u64,b: Scopy): u64 { + Mul(a, select mod1::Scopy.x(b)) + } + public fun return_function_base(key: u64,x: u64): |u64|u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) + } else { + move|x: u64| Mul(x, 2) with copy, drop + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun return_function_both(key: u64,x: u64): |u64|u64 with copy+drop+store { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop, store + } else { + move|x: u64| Mul(x, 2) with copy, drop, store + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun return_function_copy(key: u64,x: u64): |u64|u64 with copy+drop { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop + } else { + move|x: u64| Mul(x, 2) with copy, drop + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun return_function_store(key: u64,x: u64): |u64|u64 with drop+store { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with drop, store + } else { + move|x: u64| Mul(x, 2) with drop, store + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun store_fun(a: Sstore,b: u64): u64 { + Mul(select mod1::Sstore.x(a), b) + } + public fun store_fun2(a: u64,b: Sstore): u64 { + Mul(a, select mod1::Sstore.x(b)) + } + public fun use_function_base(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) + } else { + move|x: u64| Mul(x, 2) + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } + public fun use_function_both(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop, store + } else { + move|x: u64| Mul(x, 2) with copy, drop, store + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } + public fun use_function_copy(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop + } else { + move|x: u64| Mul(x, 2) with copy, drop + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } + public fun use_function_store(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with drop, store + } else { + move|x: u64| Mul(x, 2) with drop, store + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } +} // end 0x42::mod1 + + +// -- Model dump after env processor inlining: +module 0x42::mod1 { + struct S { + x: u64, + } + struct Sboth { + x: u64, + } + struct Scopy { + x: u64, + } + struct Sstore { + x: u64, + } + public fun base_fun(a: S,b: u64): u64 { + Mul(select mod1::S.x(a), b) + } + public fun base_fun2(a: u64,b: S): u64 { + Mul(a, select mod1::S.x(b)) + } + public fun both_fun(a: Sboth,b: u64): u64 { + Mul(select mod1::Sboth.x(a), b) + } + public fun both_fun2(a: u64,b: Sboth): u64 { + Mul(a, select mod1::Sboth.x(b)) + } + public fun copy_fun(a: Scopy,b: u64): u64 { + Mul(select mod1::Scopy.x(a), b) + } + public fun copy_fun2(a: u64,b: Scopy): u64 { + Mul(a, select mod1::Scopy.x(b)) + } + public fun return_function_base(key: u64,x: u64): |u64|u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) + } else { + move|x: u64| Mul(x, 2) with copy, drop + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun return_function_both(key: u64,x: u64): |u64|u64 with copy+drop+store { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop, store + } else { + move|x: u64| Mul(x, 2) with copy, drop, store + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun return_function_copy(key: u64,x: u64): |u64|u64 with copy+drop { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop + } else { + move|x: u64| Mul(x, 2) with copy, drop + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun return_function_store(key: u64,x: u64): |u64|u64 with drop+store { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with drop, store + } else { + move|x: u64| Mul(x, 2) with drop, store + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun store_fun(a: Sstore,b: u64): u64 { + Mul(select mod1::Sstore.x(a), b) + } + public fun store_fun2(a: u64,b: Sstore): u64 { + Mul(a, select mod1::Sstore.x(b)) + } + public fun use_function_base(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) + } else { + move|x: u64| Mul(x, 2) + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } + public fun use_function_both(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop, store + } else { + move|x: u64| Mul(x, 2) with copy, drop, store + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } + public fun use_function_copy(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop + } else { + move|x: u64| Mul(x, 2) with copy, drop + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } + public fun use_function_store(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with drop, store + } else { + move|x: u64| Mul(x, 2) with drop, store + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } +} // end 0x42::mod1 + + +// -- Model dump after env processor access and use check after inlining: +module 0x42::mod1 { + struct S { + x: u64, + } + struct Sboth { + x: u64, + } + struct Scopy { + x: u64, + } + struct Sstore { + x: u64, + } + public fun base_fun(a: S,b: u64): u64 { + Mul(select mod1::S.x(a), b) + } + public fun base_fun2(a: u64,b: S): u64 { + Mul(a, select mod1::S.x(b)) + } + public fun both_fun(a: Sboth,b: u64): u64 { + Mul(select mod1::Sboth.x(a), b) + } + public fun both_fun2(a: u64,b: Sboth): u64 { + Mul(a, select mod1::Sboth.x(b)) + } + public fun copy_fun(a: Scopy,b: u64): u64 { + Mul(select mod1::Scopy.x(a), b) + } + public fun copy_fun2(a: u64,b: Scopy): u64 { + Mul(a, select mod1::Scopy.x(b)) + } + public fun return_function_base(key: u64,x: u64): |u64|u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) + } else { + move|x: u64| Mul(x, 2) with copy, drop + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun return_function_both(key: u64,x: u64): |u64|u64 with copy+drop+store { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop, store + } else { + move|x: u64| Mul(x, 2) with copy, drop, store + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun return_function_copy(key: u64,x: u64): |u64|u64 with copy+drop { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop + } else { + move|x: u64| Mul(x, 2) with copy, drop + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun return_function_store(key: u64,x: u64): |u64|u64 with drop+store { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with drop, store + } else { + move|x: u64| Mul(x, 2) with drop, store + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun store_fun(a: Sstore,b: u64): u64 { + Mul(select mod1::Sstore.x(a), b) + } + public fun store_fun2(a: u64,b: Sstore): u64 { + Mul(a, select mod1::Sstore.x(b)) + } + public fun use_function_base(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) + } else { + move|x: u64| Mul(x, 2) + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } + public fun use_function_both(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop, store + } else { + move|x: u64| Mul(x, 2) with copy, drop, store + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } + public fun use_function_copy(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop + } else { + move|x: u64| Mul(x, 2) with copy, drop + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } + public fun use_function_store(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with drop, store + } else { + move|x: u64| Mul(x, 2) with drop, store + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } +} // end 0x42::mod1 + + +// -- Model dump after env processor acquires check: +module 0x42::mod1 { + struct S { + x: u64, + } + struct Sboth { + x: u64, + } + struct Scopy { + x: u64, + } + struct Sstore { + x: u64, + } + public fun base_fun(a: S,b: u64): u64 { + Mul(select mod1::S.x(a), b) + } + public fun base_fun2(a: u64,b: S): u64 { + Mul(a, select mod1::S.x(b)) + } + public fun both_fun(a: Sboth,b: u64): u64 { + Mul(select mod1::Sboth.x(a), b) + } + public fun both_fun2(a: u64,b: Sboth): u64 { + Mul(a, select mod1::Sboth.x(b)) + } + public fun copy_fun(a: Scopy,b: u64): u64 { + Mul(select mod1::Scopy.x(a), b) + } + public fun copy_fun2(a: u64,b: Scopy): u64 { + Mul(a, select mod1::Scopy.x(b)) + } + public fun return_function_base(key: u64,x: u64): |u64|u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) + } else { + move|x: u64| Mul(x, 2) with copy, drop + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun return_function_both(key: u64,x: u64): |u64|u64 with copy+drop+store { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop, store + } else { + move|x: u64| Mul(x, 2) with copy, drop, store + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun return_function_copy(key: u64,x: u64): |u64|u64 with copy+drop { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop + } else { + move|x: u64| Mul(x, 2) with copy, drop + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun return_function_store(key: u64,x: u64): |u64|u64 with drop+store { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with drop, store + } else { + move|x: u64| Mul(x, 2) with drop, store + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun store_fun(a: Sstore,b: u64): u64 { + Mul(select mod1::Sstore.x(a), b) + } + public fun store_fun2(a: u64,b: Sstore): u64 { + Mul(a, select mod1::Sstore.x(b)) + } + public fun use_function_base(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) + } else { + move|x: u64| Mul(x, 2) + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } + public fun use_function_both(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop, store + } else { + move|x: u64| Mul(x, 2) with copy, drop, store + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } + public fun use_function_copy(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with copy, drop + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop + } else { + move|x: u64| Mul(x, 2) with copy, drop + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } + public fun use_function_store(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + { + let x: u64 = 3; + move|x: u64| mod1::base_fun(a, x) with drop, store + } + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with drop, store + } else { + move|x: u64| Mul(x, 2) with drop, store + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } +} // end 0x42::mod1 + + +// -- Model dump after env processor simplifier: +module 0x42::mod1 { + struct S { + x: u64, + } + struct Sboth { + x: u64, + } + struct Scopy { + x: u64, + } + struct Sstore { + x: u64, + } + public fun base_fun(a: S,b: u64): u64 { + Mul(select mod1::S.x(a), b) + } + public fun base_fun2(a: u64,b: S): u64 { + Mul(a, select mod1::S.x(b)) + } + public fun both_fun(a: Sboth,b: u64): u64 { + Mul(select mod1::Sboth.x(a), b) + } + public fun both_fun2(a: u64,b: Sboth): u64 { + Mul(a, select mod1::Sboth.x(b)) + } + public fun copy_fun(a: Scopy,b: u64): u64 { + Mul(select mod1::Scopy.x(a), b) + } + public fun copy_fun2(a: u64,b: Scopy): u64 { + Mul(a, select mod1::Scopy.x(b)) + } + public fun return_function_base(key: u64,x: u64): |u64|u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + move|x: u64| mod1::base_fun(a, x) + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) + } else { + move|x: u64| Mul(x, 2) with copy, drop + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun return_function_both(key: u64,x: u64): |u64|u64 with copy+drop+store { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + move|x: u64| mod1::base_fun(a, x) with copy, drop, store + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop, store + } else { + move|x: u64| Mul(x, 2) with copy, drop, store + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun return_function_copy(key: u64,x: u64): |u64|u64 with copy+drop { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + move|x: u64| mod1::base_fun(a, x) with copy, drop + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop + } else { + move|x: u64| Mul(x, 2) with copy, drop + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun return_function_store(key: u64,x: u64): |u64|u64 with drop+store { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + move|x: u64| mod1::base_fun(a, x) with drop, store + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with drop, store + } else { + move|x: u64| Mul(x, 2) with drop, store + } + } + } + } + } + } + } + }; + f + } + } + } + } + } + } + public fun store_fun(a: Sstore,b: u64): u64 { + Mul(select mod1::Sstore.x(a), b) + } + public fun store_fun2(a: u64,b: Sstore): u64 { + Mul(a, select mod1::Sstore.x(b)) + } + public fun use_function_base(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + move|x: u64| mod1::base_fun(a, x) + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) + } else { + move|x: u64| Mul(x, 2) + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } + public fun use_function_both(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + move|x: u64| mod1::base_fun(a, x) with copy, drop, store + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop, store + } else { + move|x: u64| Mul(x, 2) with copy, drop, store + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } + public fun use_function_copy(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + move|x: u64| mod1::base_fun(a, x) with copy, drop + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with copy, drop + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with copy, drop + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with copy, drop + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with copy, drop + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with copy, drop + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with copy, drop + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with copy, drop + } else { + move|x: u64| Mul(x, 2) with copy, drop + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } + public fun use_function_store(key: u64,x: u64): u64 { + { + let a: S = pack mod1::S(2); + { + let a_copy: Scopy = pack mod1::Scopy(2); + { + let a_store: Sstore = pack mod1::Sstore(2); + { + let a_both: Sboth = pack mod1::Sboth(2); + { + let f: |u64|u64 with copy+drop+store = if Eq(key, 0) { + move|x: u64| mod1::base_fun(a, x) with drop, store + } else { + if Eq(key, 1) { + move|x: u64| mod1::base_fun2(x, a) with drop, store + } else { + if Eq(key, 2) { + move|x: u64| mod1::copy_fun(a_copy, x) with drop, store + } else { + if Eq(key, 3) { + move|x: u64| mod1::copy_fun2(x, a_copy) with drop, store + } else { + if Eq(key, 4) { + move|x: u64| mod1::store_fun(a_store, x) with drop, store + } else { + if Eq(key, 5) { + move|x: u64| mod1::store_fun2(x, a_store) with drop, store + } else { + if Eq(key, 6) { + move|x: u64| mod1::both_fun(a_both, x) with drop, store + } else { + if Eq(key, 7) { + move|x: u64| mod1::both_fun2(x, a_both) with drop, store + } else { + move|x: u64| Mul(x, 2) with drop, store + } + } + } + } + } + } + } + }; + (f)(x) + } + } + } + } + } + } +} // end 0x42::mod1 + + + +Diagnostics: +warning: Unused local variable `x`. Consider removing or prefixing with an underscore: `_x` + ┌─ tests/lambda/storable/closure_args.move:58:21 + │ +58 │ let x = 3; + │ ^ + +warning: Unused parameter `x`. Consider removing or prefixing with an underscore: `_x` + ┌─ tests/lambda/storable/closure_args.move:80:47 + │ +80 │ public fun return_function_base(key: u64, x: u64): |u64|u64 { + │ ^ + +warning: Unused local variable `x`. Consider removing or prefixing with an underscore: `_x` + ┌─ tests/lambda/storable/closure_args.move:87:21 + │ +87 │ let x = 3; + │ ^ + +warning: Unused local variable `x`. Consider removing or prefixing with an underscore: `_x` + ┌─ tests/lambda/storable/closure_args.move:118:21 + │ +118 │ let x = 3; + │ ^ + +error: Lambda captures free variables with types that do not have some declared abilities: copy + ┌─ tests/lambda/storable/closure_args.move:119:17 + │ +119 │ move |x| base_fun(a, x) with copy + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ │ + │ Captured free value is missing abilities: copy + +error: Lambda captures free variables with types that do not have some declared abilities: copy + ┌─ tests/lambda/storable/closure_args.move:127:17 + │ +127 │ move |x| store_fun(a_store, x) with copy + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ │ + │ Captured free value is missing abilities: copy + +warning: Unused parameter `x`. Consider removing or prefixing with an underscore: `_x` + ┌─ tests/lambda/storable/closure_args.move:140:47 + │ +140 │ public fun return_function_copy(key: u64, x: u64): |u64|u64 with copy { + │ ^ + +warning: Unused local variable `x`. Consider removing or prefixing with an underscore: `_x` + ┌─ tests/lambda/storable/closure_args.move:147:21 + │ +147 │ let x = 3; + │ ^ + +error: Lambda captures free variables with types that do not have some declared abilities: copy + ┌─ tests/lambda/storable/closure_args.move:148:17 + │ +148 │ move |x| base_fun(a, x) with copy + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ │ + │ Captured free value is missing abilities: copy + +error: Lambda captures free variables with types that do not have some declared abilities: copy + ┌─ tests/lambda/storable/closure_args.move:156:17 + │ +156 │ move |x| store_fun(a_store, x) with copy + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ │ + │ Captured free value is missing abilities: copy + +warning: Unused local variable `x`. Consider removing or prefixing with an underscore: `_x` + ┌─ tests/lambda/storable/closure_args.move:177:21 + │ +177 │ let x = 3; + │ ^ + +error: Lambda captures free variables with types that do not have some declared abilities: store + ┌─ tests/lambda/storable/closure_args.move:178:17 + │ +178 │ move |x| base_fun(a, x) with store + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ │ + │ Captured free value is missing abilities: store + +error: The body of a lambdas expression with `store` ability currently must be a simple call to an existing `public` function, with lambda params the same as the *final* arguments to the function call. + ┌─ tests/lambda/storable/closure_args.move:178:17 + │ +178 │ move |x| base_fun(a, x) with store + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: The body of a lambdas expression with `store` ability currently must be a simple call to an existing `public` function, with lambda params the same as the *final* arguments to the function call. + ┌─ tests/lambda/storable/closure_args.move:180:17 + │ +180 │ move |x| base_fun2(x, a) with store + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: Lambda captures free variables with types that do not have some declared abilities: store + ┌─ tests/lambda/storable/closure_args.move:182:17 + │ +182 │ move |x| copy_fun(a_copy, x) with store + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ │ + │ Captured free value is missing abilities: store + +error: The body of a lambdas expression with `store` ability currently must be a simple call to an existing `public` function, with lambda params the same as the *final* arguments to the function call. + ┌─ tests/lambda/storable/closure_args.move:182:17 + │ +182 │ move |x| copy_fun(a_copy, x) with store + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: The body of a lambdas expression with `store` ability currently must be a simple call to an existing `public` function, with lambda params the same as the *final* arguments to the function call. + ┌─ tests/lambda/storable/closure_args.move:184:17 + │ +184 │ move |x| copy_fun2(x, a_copy) with store + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: The body of a lambdas expression with `store` ability currently must be a simple call to an existing `public` function, with lambda params the same as the *final* arguments to the function call. + ┌─ tests/lambda/storable/closure_args.move:188:17 + │ +188 │ move |x| store_fun2(x, a_store) with store + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: The body of a lambdas expression with `store` ability currently must be a simple call to an existing `public` function, with lambda params the same as the *final* arguments to the function call. + ┌─ tests/lambda/storable/closure_args.move:192:17 + │ +192 │ move |x| both_fun2(x, a_both) with store + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: The body of a lambdas expression with `store` ability currently must be a simple call to an existing `public` function, with lambda params the same as the *final* arguments to the function call. + ┌─ tests/lambda/storable/closure_args.move:194:17 + │ +194 │ move |x| x * 2 with store + │ ^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: Unused parameter `x`. Consider removing or prefixing with an underscore: `_x` + ┌─ tests/lambda/storable/closure_args.move:199:48 + │ +199 │ public fun return_function_store(key: u64, x: u64): |u64|u64 with store { + │ ^ + +warning: Unused local variable `x`. Consider removing or prefixing with an underscore: `_x` + ┌─ tests/lambda/storable/closure_args.move:206:21 + │ +206 │ let x = 3; + │ ^ + +error: Lambda captures free variables with types that do not have some declared abilities: store + ┌─ tests/lambda/storable/closure_args.move:207:17 + │ +207 │ move |x| base_fun(a, x) with store + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ │ + │ Captured free value is missing abilities: store + +error: The body of a lambdas expression with `store` ability currently must be a simple call to an existing `public` function, with lambda params the same as the *final* arguments to the function call. + ┌─ tests/lambda/storable/closure_args.move:207:17 + │ +207 │ move |x| base_fun(a, x) with store + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: The body of a lambdas expression with `store` ability currently must be a simple call to an existing `public` function, with lambda params the same as the *final* arguments to the function call. + ┌─ tests/lambda/storable/closure_args.move:209:17 + │ +209 │ move |x| base_fun2(x, a) with store + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: Lambda captures free variables with types that do not have some declared abilities: store + ┌─ tests/lambda/storable/closure_args.move:211:17 + │ +211 │ move |x| copy_fun(a_copy, x) with store + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ │ + │ Captured free value is missing abilities: store + +error: The body of a lambdas expression with `store` ability currently must be a simple call to an existing `public` function, with lambda params the same as the *final* arguments to the function call. + ┌─ tests/lambda/storable/closure_args.move:211:17 + │ +211 │ move |x| copy_fun(a_copy, x) with store + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: The body of a lambdas expression with `store` ability currently must be a simple call to an existing `public` function, with lambda params the same as the *final* arguments to the function call. + ┌─ tests/lambda/storable/closure_args.move:213:17 + │ +213 │ move |x| copy_fun2(x, a_copy) with store + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: The body of a lambdas expression with `store` ability currently must be a simple call to an existing `public` function, with lambda params the same as the *final* arguments to the function call. + ┌─ tests/lambda/storable/closure_args.move:217:17 + │ +217 │ move |x| store_fun2(x, a_store) with store + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: The body of a lambdas expression with `store` ability currently must be a simple call to an existing `public` function, with lambda params the same as the *final* arguments to the function call. + ┌─ tests/lambda/storable/closure_args.move:221:17 + │ +221 │ move |x| both_fun2(x, a_both) with store + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: The body of a lambdas expression with `store` ability currently must be a simple call to an existing `public` function, with lambda params the same as the *final* arguments to the function call. + ┌─ tests/lambda/storable/closure_args.move:223:17 + │ +223 │ move |x| x * 2 with store + │ ^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: Unused local variable `x`. Consider removing or prefixing with an underscore: `_x` + ┌─ tests/lambda/storable/closure_args.move:237:21 + │ +237 │ let x = 3; + │ ^ + +error: Lambda captures free variables with types that do not have some declared abilities: copy + store + ┌─ tests/lambda/storable/closure_args.move:238:17 + │ +238 │ move |x| base_fun(a, x) with store+copy + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ │ + │ Captured free value is missing abilities: copy + store + +error: The body of a lambdas expression with `store` ability currently must be a simple call to an existing `public` function, with lambda params the same as the *final* arguments to the function call. + ┌─ tests/lambda/storable/closure_args.move:238:17 + │ +238 │ move |x| base_fun(a, x) with store+copy + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: The body of a lambdas expression with `store` ability currently must be a simple call to an existing `public` function, with lambda params the same as the *final* arguments to the function call. + ┌─ tests/lambda/storable/closure_args.move:240:17 + │ +240 │ move |x| base_fun2(x, a) with store+copy + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: Lambda captures free variables with types that do not have some declared abilities: store + ┌─ tests/lambda/storable/closure_args.move:242:17 + │ +242 │ move |x| copy_fun(a_copy, x) with store+copy + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ │ + │ Captured free value is missing abilities: store + +error: The body of a lambdas expression with `store` ability currently must be a simple call to an existing `public` function, with lambda params the same as the *final* arguments to the function call. + ┌─ tests/lambda/storable/closure_args.move:242:17 + │ +242 │ move |x| copy_fun(a_copy, x) with store+copy + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: The body of a lambdas expression with `store` ability currently must be a simple call to an existing `public` function, with lambda params the same as the *final* arguments to the function call. + ┌─ tests/lambda/storable/closure_args.move:244:17 + │ +244 │ move |x| copy_fun2(x, a_copy) with store+copy + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: Lambda captures free variables with types that do not have some declared abilities: copy + ┌─ tests/lambda/storable/closure_args.move:246:17 + │ +246 │ move |x| store_fun(a_store, x) with store+copy + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ │ + │ Captured free value is missing abilities: copy + +error: The body of a lambdas expression with `store` ability currently must be a simple call to an existing `public` function, with lambda params the same as the *final* arguments to the function call. + ┌─ tests/lambda/storable/closure_args.move:246:17 + │ +246 │ move |x| store_fun(a_store, x) with store+copy + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: The body of a lambdas expression with `store` ability currently must be a simple call to an existing `public` function, with lambda params the same as the *final* arguments to the function call. + ┌─ tests/lambda/storable/closure_args.move:248:17 + │ +248 │ move |x| store_fun2(x, a_store) with store+copy + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: The body of a lambdas expression with `store` ability currently must be a simple call to an existing `public` function, with lambda params the same as the *final* arguments to the function call. + ┌─ tests/lambda/storable/closure_args.move:252:17 + │ +252 │ move |x| both_fun2(x, a_both) with store+copy + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: The body of a lambdas expression with `store` ability currently must be a simple call to an existing `public` function, with lambda params the same as the *final* arguments to the function call. + ┌─ tests/lambda/storable/closure_args.move:254:17 + │ +254 │ move |x| x * 2 with store+copy + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: Unused parameter `x`. Consider removing or prefixing with an underscore: `_x` + ┌─ tests/lambda/storable/closure_args.move:259:47 + │ +259 │ public fun return_function_both(key: u64, x: u64): |u64|u64 with store+copy { + │ ^ + +warning: Unused local variable `x`. Consider removing or prefixing with an underscore: `_x` + ┌─ tests/lambda/storable/closure_args.move:266:21 + │ +266 │ let x = 3; + │ ^ + +error: Lambda captures free variables with types that do not have some declared abilities: copy + store + ┌─ tests/lambda/storable/closure_args.move:267:17 + │ +267 │ move |x| base_fun(a, x) with store+copy + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ │ + │ Captured free value is missing abilities: copy + store + +error: The body of a lambdas expression with `store` ability currently must be a simple call to an existing `public` function, with lambda params the same as the *final* arguments to the function call. + ┌─ tests/lambda/storable/closure_args.move:267:17 + │ +267 │ move |x| base_fun(a, x) with store+copy + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: The body of a lambdas expression with `store` ability currently must be a simple call to an existing `public` function, with lambda params the same as the *final* arguments to the function call. + ┌─ tests/lambda/storable/closure_args.move:269:17 + │ +269 │ move |x| base_fun2(x, a) with store+copy + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: Lambda captures free variables with types that do not have some declared abilities: store + ┌─ tests/lambda/storable/closure_args.move:271:17 + │ +271 │ move |x| copy_fun(a_copy, x) with store+copy + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ │ + │ Captured free value is missing abilities: store + +error: The body of a lambdas expression with `store` ability currently must be a simple call to an existing `public` function, with lambda params the same as the *final* arguments to the function call. + ┌─ tests/lambda/storable/closure_args.move:271:17 + │ +271 │ move |x| copy_fun(a_copy, x) with store+copy + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: The body of a lambdas expression with `store` ability currently must be a simple call to an existing `public` function, with lambda params the same as the *final* arguments to the function call. + ┌─ tests/lambda/storable/closure_args.move:273:17 + │ +273 │ move |x| copy_fun2(x, a_copy) with store+copy + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: Lambda captures free variables with types that do not have some declared abilities: copy + ┌─ tests/lambda/storable/closure_args.move:275:17 + │ +275 │ move |x| store_fun(a_store, x) with store+copy + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ │ + │ Captured free value is missing abilities: copy + +error: The body of a lambdas expression with `store` ability currently must be a simple call to an existing `public` function, with lambda params the same as the *final* arguments to the function call. + ┌─ tests/lambda/storable/closure_args.move:275:17 + │ +275 │ move |x| store_fun(a_store, x) with store+copy + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: The body of a lambdas expression with `store` ability currently must be a simple call to an existing `public` function, with lambda params the same as the *final* arguments to the function call. + ┌─ tests/lambda/storable/closure_args.move:277:17 + │ +277 │ move |x| store_fun2(x, a_store) with store+copy + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: The body of a lambdas expression with `store` ability currently must be a simple call to an existing `public` function, with lambda params the same as the *final* arguments to the function call. + ┌─ tests/lambda/storable/closure_args.move:281:17 + │ +281 │ move |x| both_fun2(x, a_both) with store+copy + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: The body of a lambdas expression with `store` ability currently must be a simple call to an existing `public` function, with lambda params the same as the *final* arguments to the function call. + ┌─ tests/lambda/storable/closure_args.move:283:17 + │ +283 │ move |x| x * 2 with store+copy + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/third_party/move/move-compiler-v2/tests/lambda/storable/closure_args.move b/third_party/move/move-compiler-v2/tests/lambda/storable/closure_args.move new file mode 100644 index 0000000000000..375f07e6700cb --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/lambda/storable/closure_args.move @@ -0,0 +1,287 @@ +module 0x42::mod1 { + struct S has drop { + x: u64 + } + + struct Scopy has copy, drop { + x: u64 + } + + struct Sstore has store, drop { + x: u64 + } + + struct Sboth has store, copy, drop { + x: u64 + } + + public fun base_fun(a: S, b: u64) : u64 { + a.x * b + } + + public fun base_fun2(a: u64, b: S) : u64 { + a * b.x + } + + public fun copy_fun(a: Scopy, b: u64) : u64 { + a.x * b + } + + public fun copy_fun2(a: u64, b: Scopy) : u64 { + a * b.x + } + + public fun store_fun(a: Sstore, b: u64) : u64 { + a.x * b + } + + public fun store_fun2(a: u64, b: Sstore) : u64 { + a * b.x + } + + public fun both_fun(a: Sboth, b: u64) : u64 { + a.x * b + } + + public fun both_fun2(a: u64, b: Sboth) : u64 { + a * b.x + } + + // just drop + public fun use_function_base(key: u64, x: u64): u64 { + let a = S { x: 2 }; + let a_copy = Scopy { x: 2 }; + let a_store = Sstore { x: 2 }; + let a_both = Sboth { x: 2 }; + let f = + if (key == 0) { + let x = 3; + move |x| base_fun(a, x) + } else if (key == 1) { + move |x| base_fun2(x, a) + } else if (key == 2) { + move |x| copy_fun(a_copy, x) + } else if (key == 3) { + move |x| copy_fun2(x, a_copy) + } else if (key == 4) { + move |x| store_fun(a_store, x) + } else if (key == 5) { + move |x| store_fun2(x, a_store) + } else if (key == 6) { + move |x| both_fun(a_both, x) + } else if (key == 7) { + move |x| both_fun2(x, a_both) + } else { + move |x| x * 2 + }; + f(x) + } + + public fun return_function_base(key: u64, x: u64): |u64|u64 { + let a = S { x: 2 }; + let a_copy = Scopy { x: 2 }; + let a_store = Sstore { x: 2 }; + let a_both = Sboth { x: 2 }; + let f = + if (key == 0) { + let x = 3; + move |x| base_fun(a, x) + } else if (key == 1) { + move |x| base_fun2(x, a) + } else if (key == 2) { + move |x| copy_fun(a_copy, x) + } else if (key == 3) { + move |x| copy_fun2(x, a_copy) + } else if (key == 4) { + move |x| store_fun(a_store, x) + } else if (key == 5) { + move |x| store_fun2(x, a_store) + } else if (key == 6) { + move |x| both_fun(a_both, x) + } else if (key == 7) { + move |x| both_fun2(x, a_both) + } else { + move |x| x * 2 with copy + }; + f + } + + + // copy + public fun use_function_copy(key: u64, x: u64): u64 { + let a = S { x: 2 }; + let a_copy = Scopy { x: 2 }; + let a_store = Sstore { x: 2 }; + let a_both = Sboth { x: 2 }; + let f = + if (key == 0) { + let x = 3; + move |x| base_fun(a, x) with copy + } else if (key == 1) { + move |x| base_fun2(x, a) with copy + } else if (key == 2) { + move |x| copy_fun(a_copy, x) with copy + } else if (key == 3) { + move |x| copy_fun2(x, a_copy) with copy + } else if (key == 4) { + move |x| store_fun(a_store, x) with copy + } else if (key == 5) { + move |x| store_fun2(x, a_store) with copy + } else if (key == 6) { + move |x| both_fun(a_both, x) with copy + } else if (key == 7) { + move |x| both_fun2(x, a_both) with copy + } else { + move |x| x * 2 with copy + }; + f(x) + } + + public fun return_function_copy(key: u64, x: u64): |u64|u64 with copy { + let a = S { x: 2 }; + let a_copy = Scopy { x: 2 }; + let a_store = Sstore { x: 2 }; + let a_both = Sboth { x: 2 }; + let f = + if (key == 0) { + let x = 3; + move |x| base_fun(a, x) with copy + } else if (key == 1) { + move |x| base_fun2(x, a) with copy + } else if (key == 2) { + move |x| copy_fun(a_copy, x) with copy + } else if (key == 3) { + move |x| copy_fun2(x, a_copy) with copy + } else if (key == 4) { + move |x| store_fun(a_store, x) with copy + } else if (key == 5) { + move |x| store_fun2(x, a_store) with copy + } else if (key == 6) { + move |x| both_fun(a_both, x) with copy + } else if (key == 7) { + move |x| both_fun2(x, a_both) with copy + } else { + move |x| x * 2 with copy + }; + f + } + + // store + public fun use_function_store(key: u64, x: u64): u64 { + let a = S { x: 2 }; + let a_copy = Scopy { x: 2 }; + let a_store = Sstore { x: 2 }; + let a_both = Sboth { x: 2 }; + let f = + if (key == 0) { + let x = 3; + move |x| base_fun(a, x) with store + } else if (key == 1) { + move |x| base_fun2(x, a) with store + } else if (key == 2) { + move |x| copy_fun(a_copy, x) with store + } else if (key == 3) { + move |x| copy_fun2(x, a_copy) with store + } else if (key == 4) { + move |x| store_fun(a_store, x) with store + } else if (key == 5) { + move |x| store_fun2(x, a_store) with store + } else if (key == 6) { + move |x| both_fun(a_both, x) with store + } else if (key == 7) { + move |x| both_fun2(x, a_both) with store + } else { + move |x| x * 2 with store + }; + f(x) + } + + public fun return_function_store(key: u64, x: u64): |u64|u64 with store { + let a = S { x: 2 }; + let a_copy = Scopy { x: 2 }; + let a_store = Sstore { x: 2 }; + let a_both = Sboth { x: 2 }; + let f = + if (key == 0) { + let x = 3; + move |x| base_fun(a, x) with store + } else if (key == 1) { + move |x| base_fun2(x, a) with store + } else if (key == 2) { + move |x| copy_fun(a_copy, x) with store + } else if (key == 3) { + move |x| copy_fun2(x, a_copy) with store + } else if (key == 4) { + move |x| store_fun(a_store, x) with store + } else if (key == 5) { + move |x| store_fun2(x, a_store) with store + } else if (key == 6) { + move |x| both_fun(a_both, x) with store + } else if (key == 7) { + move |x| both_fun2(x, a_both) with store + } else { + move |x| x * 2 with store + }; + f + } + + + // both = store+copy + public fun use_function_both(key: u64, x: u64): u64 { + let a = S { x: 2 }; + let a_copy = Scopy { x: 2 }; + let a_store = Sstore { x: 2 }; + let a_both = Sboth { x: 2 }; + let f = + if (key == 0) { + let x = 3; + move |x| base_fun(a, x) with store+copy + } else if (key == 1) { + move |x| base_fun2(x, a) with store+copy + } else if (key == 2) { + move |x| copy_fun(a_copy, x) with store+copy + } else if (key == 3) { + move |x| copy_fun2(x, a_copy) with store+copy + } else if (key == 4) { + move |x| store_fun(a_store, x) with store+copy + } else if (key == 5) { + move |x| store_fun2(x, a_store) with store+copy + } else if (key == 6) { + move |x| both_fun(a_both, x) with store+copy + } else if (key == 7) { + move |x| both_fun2(x, a_both) with store+copy + } else { + move |x| x * 2 with store+copy + }; + f(x) + } + + public fun return_function_both(key: u64, x: u64): |u64|u64 with store+copy { + let a = S { x: 2 }; + let a_copy = Scopy { x: 2 }; + let a_store = Sstore { x: 2 }; + let a_both = Sboth { x: 2 }; + let f = + if (key == 0) { + let x = 3; + move |x| base_fun(a, x) with store+copy + } else if (key == 1) { + move |x| base_fun2(x, a) with store+copy + } else if (key == 2) { + move |x| copy_fun(a_copy, x) with store+copy + } else if (key == 3) { + move |x| copy_fun2(x, a_copy) with store+copy + } else if (key == 4) { + move |x| store_fun(a_store, x) with store+copy + } else if (key == 5) { + move |x| store_fun2(x, a_store) with store+copy + } else if (key == 6) { + move |x| both_fun(a_both, x) with store+copy + } else if (key == 7) { + move |x| both_fun2(x, a_both) with store+copy + } else { + move |x| x * 2 with store+copy + }; + f + } +} diff --git a/third_party/move/move-compiler-v2/tests/lambda/storable/return_func_ok.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/storable/return_func_ok.lambda.exp index 9759d77733510..b37236d35a6fc 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/storable/return_func_ok.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/storable/return_func_ok.lambda.exp @@ -1559,13 +1559,13 @@ module 0x42::test { Diagnostics: -error: Lambdas expressions with `store` ability currently may only be a simple call to an existing `public` function. This lambda expression requires defining a `public` helper function, which might affect module upgradeability and is not yet supported. +error: The body of a lambdas expression with `store` ability currently must be a simple call to an existing `public` function, with lambda params the same as the *final* arguments to the function call. ┌─ tests/lambda/storable/return_func_ok.move:49:13 │ 49 │ move |y| multiply(y, 7) with store │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: Lambdas expressions with `store` ability currently may only be a simple call to an existing `public` function. This lambda expression requires defining a `public` helper function, which might affect module upgradeability and is not yet supported. +error: The body of a lambdas expression with `store` ability currently must be a simple call to an existing `public` function, with lambda params the same as the *final* arguments to the function call. ┌─ tests/lambda/storable/return_func_ok.move:57:13 │ 57 │ move |y| multiply3(y, 3, 4) with store diff --git a/third_party/move/move-compiler-v2/transactional-tests/tests/inlining/function_name_shadowing.exp b/third_party/move/move-compiler-v2/transactional-tests/tests/inlining/function_name_shadowing.exp index 09aafe1f066eb..e2453ef24dad5 100644 --- a/third_party/move/move-compiler-v2/transactional-tests/tests/inlining/function_name_shadowing.exp +++ b/third_party/move/move-compiler-v2/transactional-tests/tests/inlining/function_name_shadowing.exp @@ -1,15 +1,27 @@ comparison between v1 and v2 failed: -= processed 2 tasks += processed 3 tasks = -+ task 0 'publish'. lines 1-15: ++ task 1 'publish'. lines 12-28: + warning: Unused parameter `f`. Consider removing or prefixing with an underscore: `_f` -+ ┌─ TEMPFILE:6:28 -+ │ -+ 6 │ public inline fun quux(f:|u64, u64|u64, a: u64, b: u64): u64 { -+ │ ^ ++ ┌─ TEMPFILE1:18:28 ++ │ ++ 18 │ public inline fun quux(f:|u64, u64|u64, g:|u64|u64, i:|u8|u8, a: u64, b: u64): u64 { ++ │ ^ + ++ warning: Unused parameter `g`. Consider removing or prefixing with an underscore: `_g` ++ ┌─ TEMPFILE1:18:45 ++ │ ++ 18 │ public inline fun quux(f:|u64, u64|u64, g:|u64|u64, i:|u8|u8, a: u64, b: u64): u64 { ++ │ ^ + ++ warning: Unused parameter `i`. Consider removing or prefixing with an underscore: `_i` ++ ┌─ TEMPFILE1:18:57 ++ │ ++ 18 │ public inline fun quux(f:|u64, u64|u64, g:|u64|u64, i:|u8|u8, a: u64, b: u64): u64 { ++ │ ^ + -= task 1 'run'. lines 17-17: -= return values: 20 ++ ++ += task 2 'run'. lines 30-30: += return values: 5280 = diff --git a/third_party/move/move-compiler-v2/transactional-tests/tests/inlining/function_name_shadowing.move b/third_party/move/move-compiler-v2/transactional-tests/tests/inlining/function_name_shadowing.move index 4867cdfbb3f88..e527c426c7eef 100644 --- a/third_party/move/move-compiler-v2/transactional-tests/tests/inlining/function_name_shadowing.move +++ b/third_party/move/move-compiler-v2/transactional-tests/tests/inlining/function_name_shadowing.move @@ -1,16 +1,29 @@ +//# publish +module 0x42::OtherModule { + public fun g(a: u64, b: u64): u64 { + a + b + } + + public fun h(a: u64, b: u64): u64 { + 2 * a + b + } +} + //# publish module 0x42::Test { + use 0x42::OtherModule::g; public fun f(a: u64, b: u64): u64 { a * b } - public inline fun quux(f:|u64, u64|u64, a: u64, b: u64): u64 { - f(a, b) + public inline fun quux(f:|u64, u64|u64, g:|u64|u64, i:|u8|u8, a: u64, b: u64): u64 { + use 0x42::OtherModule::h; + f(a, b) * g(a, b) * h(a, b) } public fun test_shadowing(): u64 { - quux(|a, b| a - b, 10, 2) + quux(|a, b| a - b, |a| a + 2, |b| 255u8-b, 10, 2) } } diff --git a/third_party/move/move-compiler/tests/move_check/inlining/function_name_shadowing.move b/third_party/move/move-compiler/tests/move_check/inlining/function_name_shadowing.move new file mode 100644 index 0000000000000..e527c426c7eef --- /dev/null +++ b/third_party/move/move-compiler/tests/move_check/inlining/function_name_shadowing.move @@ -0,0 +1,30 @@ +//# publish +module 0x42::OtherModule { + public fun g(a: u64, b: u64): u64 { + a + b + } + + public fun h(a: u64, b: u64): u64 { + 2 * a + b + } +} + +//# publish +module 0x42::Test { + use 0x42::OtherModule::g; + + public fun f(a: u64, b: u64): u64 { + a * b + } + + public inline fun quux(f:|u64, u64|u64, g:|u64|u64, i:|u8|u8, a: u64, b: u64): u64 { + use 0x42::OtherModule::h; + f(a, b) * g(a, b) * h(a, b) + } + + public fun test_shadowing(): u64 { + quux(|a, b| a - b, |a| a + 2, |b| 255u8-b, 10, 2) + } +} + +//# run 0x42::Test::test_shadowing diff --git a/third_party/move/move-compiler/transactional-tests/tests/inlining/function_name_shadowing.exp b/third_party/move/move-compiler/transactional-tests/tests/inlining/function_name_shadowing.exp new file mode 100644 index 0000000000000..2463a580a0079 --- /dev/null +++ b/third_party/move/move-compiler/transactional-tests/tests/inlining/function_name_shadowing.exp @@ -0,0 +1,4 @@ +processed 3 tasks + +task 2 'run'. lines 30-30: +return values: 5280 diff --git a/third_party/move/move-compiler/transactional-tests/tests/inlining/function_name_shadowing.move b/third_party/move/move-compiler/transactional-tests/tests/inlining/function_name_shadowing.move new file mode 100644 index 0000000000000..e527c426c7eef --- /dev/null +++ b/third_party/move/move-compiler/transactional-tests/tests/inlining/function_name_shadowing.move @@ -0,0 +1,30 @@ +//# publish +module 0x42::OtherModule { + public fun g(a: u64, b: u64): u64 { + a + b + } + + public fun h(a: u64, b: u64): u64 { + 2 * a + b + } +} + +//# publish +module 0x42::Test { + use 0x42::OtherModule::g; + + public fun f(a: u64, b: u64): u64 { + a * b + } + + public inline fun quux(f:|u64, u64|u64, g:|u64|u64, i:|u8|u8, a: u64, b: u64): u64 { + use 0x42::OtherModule::h; + f(a, b) * g(a, b) * h(a, b) + } + + public fun test_shadowing(): u64 { + quux(|a, b| a - b, |a| a + 2, |b| 255u8-b, 10, 2) + } +} + +//# run 0x42::Test::test_shadowing