diff --git a/Cargo.lock b/Cargo.lock index d5056dbfcc27d..15b90de62a766 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11320,6 +11320,7 @@ dependencies = [ "codespan", "codespan-reporting", "datatest-stable", + "either", "internment", "itertools 0.13.0", "log", diff --git a/third_party/move/evm/move-to-yul/src/context.rs b/third_party/move/evm/move-to-yul/src/context.rs index ef8e251ee89e8..a8e9b29deef17 100644 --- a/third_party/move/evm/move-to-yul/src/context.rs +++ b/third_party/move/evm/move-to-yul/src/context.rs @@ -784,7 +784,7 @@ impl<'a> Context<'a> { Tuple(_) | TypeParameter(_) | Reference(_, _) - | Fun(_, _) + | Fun(..) | TypeDomain(_) | ResourceDomain(_, _, _) | Error diff --git a/third_party/move/evm/move-to-yul/src/solidity_ty.rs b/third_party/move/evm/move-to-yul/src/solidity_ty.rs index b47d59e5dfa48..7f44b34c35e4e 100644 --- a/third_party/move/evm/move-to-yul/src/solidity_ty.rs +++ b/third_party/move/evm/move-to-yul/src/solidity_ty.rs @@ -368,7 +368,7 @@ impl SolidityType { }, TypeParameter(_) | Reference(_, _) - | Fun(_, _) + | Fun(..) | TypeDomain(_) | ResourceDomain(_, _, _) | Error diff --git a/third_party/move/move-compiler-v2/src/bytecode_generator.rs b/third_party/move/move-compiler-v2/src/bytecode_generator.rs index 9cb45341d9743..b4c99ac5e7681 100644 --- a/third_party/move/move-compiler-v2/src/bytecode_generator.rs +++ b/third_party/move/move-compiler-v2/src/bytecode_generator.rs @@ -480,13 +480,23 @@ impl<'env> Generator<'env> { self.emit_with(*id, |attr| Bytecode::SpecBlock(attr, spec)); }, // TODO(LAMBDA) - ExpData::Lambda(id, _, _) => self.error( + ExpData::Lambda(id, _, _, _, _) => self.error( *id, "Function-typed values not yet supported except as parameters to calls to inline functions", ), // TODO(LAMBDA) - ExpData::Invoke(_, exp, _) => self.error( - exp.as_ref().node_id(), + ExpData::MoveFunctionExp(id, _mid, _fid) => self.error( + *id, + "Function-typed values not yet supported except as parameters to calls to inline functions", + ), + // TODO(LAMBDA) + ExpData::Curry(id, _mask, _fnexp, _args) => self.error( + *id, + "Function-typed values not yet supported except as parameters to calls to inline functions", + ), + // TODO(LAMBDA) + ExpData::Invoke(id, _exp, _) => self.error( + *id, "Calls to function values other than inline function parameters not yet supported", ), ExpData::Quant(id, _, _, _, _, _) => { @@ -813,12 +823,6 @@ impl<'env> Generator<'env> { Operation::NoOp => {}, // do nothing - // TODO(LAMBDA) - Operation::Closure(..) => self.error( - id, - "Function-typed values not yet supported except as parameters to calls to inline functions", - ), - // Non-supported specification related operations Operation::Exists(Some(_)) | Operation::SpecFunction(_, _, _) diff --git a/third_party/move/move-compiler-v2/src/env_pipeline/ast_simplifier.rs b/third_party/move/move-compiler-v2/src/env_pipeline/ast_simplifier.rs index f60012a917544..b24120ab8a14c 100644 --- a/third_party/move/move-compiler-v2/src/env_pipeline/ast_simplifier.rs +++ b/third_party/move/move-compiler-v2/src/env_pipeline/ast_simplifier.rs @@ -214,7 +214,7 @@ fn find_possibly_modified_vars( exp.visit_positions(&mut |pos, e| { use ExpData::*; match e { - Invalid(_) | Value(..) | LoopCont(..) => { + Invalid(_) | Value(..) | LoopCont(..) | MoveFunctionExp(..) => { // Nothing happens inside these expressions, so don't bother `modifying` state. }, LocalVar(id, sym) => { @@ -359,7 +359,7 @@ fn find_possibly_modified_vars( _ => {}, } }, - Lambda(node_id, pat, _) => { + Lambda(node_id, pat, _, _, _) => { // Define a new scope for bound vars, and turn off `modifying` within. match pos { VisitorPosition::Pre => { @@ -380,6 +380,19 @@ fn find_possibly_modified_vars( _ => {}, }; }, + Curry(_, _mask, _fnexp, _explist) => { + // Turn off `modifying` inside. + match pos { + VisitorPosition::Pre => { + modifying_stack.push(modifying); + modifying = false; + }, + VisitorPosition::Post => { + modifying = modifying_stack.pop().expect("unbalanced visit 10"); + }, + _ => {}, + } + }, Block(node_id, pat, _, _) => { // Define a new scope for bound vars, and turn off `modifying` within. match pos { @@ -978,7 +991,8 @@ impl<'env> ExpRewriterFunctions for SimplifierRewriter<'env> { let ability_set = self .env() .type_abilities(&ty, self.func_env.get_type_parameters_ref()); - ability_set.has_ability(Ability::Drop) + // Don't drop a function-valued expression so we don't lose errors. + !ty.has_function() && ability_set.has_ability(Ability::Drop) } else { // We're missing type info, be conservative false diff --git a/third_party/move/move-compiler-v2/src/env_pipeline/flow_insensitive_checkers.rs b/third_party/move/move-compiler-v2/src/env_pipeline/flow_insensitive_checkers.rs index dd6dabec91723..72bbd295d5853 100644 --- a/third_party/move/move-compiler-v2/src/env_pipeline/flow_insensitive_checkers.rs +++ b/third_party/move/move-compiler-v2/src/env_pipeline/flow_insensitive_checkers.rs @@ -147,7 +147,7 @@ impl<'env, 'params> SymbolVisitor<'env, 'params> { Pre | Post | BeforeBody | MidMutate | BeforeThen | BeforeElse | PreSequenceValue => {}, }, - Lambda(_, pat, _) => { + Lambda(_, pat, _, _, _) => { match position { Pre => self.seen_uses.enter_scope(), Post => { diff --git a/third_party/move/move-compiler-v2/src/env_pipeline/function_checker.rs b/third_party/move/move-compiler-v2/src/env_pipeline/function_checker.rs index d7dbcc3cfce2b..57f4b71f0d64d 100644 --- a/third_party/move/move-compiler-v2/src/env_pipeline/function_checker.rs +++ b/third_party/move/move-compiler-v2/src/env_pipeline/function_checker.rs @@ -20,8 +20,8 @@ fn identify_function_types_with_functions_in_args(func_types: Vec) -> Vec< func_types .into_iter() .filter_map(|ty| { - if let Type::Fun(argt, _) = &ty { - if argt.deref().has_function() { + if let Type::Fun(args, _, _) = &ty { + if args.deref().has_function() { Some(ty) } else { None @@ -41,8 +41,8 @@ fn identify_function_typed_params_with_functions_in_rets( func_types .iter() .filter_map(|param| { - if let Type::Fun(_argt, rest) = ¶m.1 { - let rest_unboxed = rest.deref(); + if let Type::Fun(_args, result, _) = ¶m.1 { + let rest_unboxed = result.deref(); if rest_unboxed.has_function() { Some((*param, rest_unboxed)) } else { @@ -270,7 +270,7 @@ fn check_privileged_operations_on_structs(env: &GlobalEnv, fun_env: &FunctionEnv }, ExpData::Assign(_, pat, _) | ExpData::Block(_, pat, _, _) - | ExpData::Lambda(_, pat, _) => { + | ExpData::Lambda(_, pat, _, _, _) => { pat.visit_pre_post(&mut |_, pat| { if let Pattern::Struct(id, str, _, _) = pat { let module_id = str.module_id; @@ -344,7 +344,7 @@ pub fn check_access_and_use(env: &mut GlobalEnv, before_inlining: bool) { // Check that functions being called are accessible. if let Some(def) = caller_func.get_def() { - let callees_with_sites = def.called_funs_with_callsites(); + let callees_with_sites = def.used_funs_with_uses(); for (callee, sites) in &callees_with_sites { let callee_func = env.get_function(*callee); // Check visibility. diff --git a/third_party/move/move-compiler-v2/src/env_pipeline/inliner.rs b/third_party/move/move-compiler-v2/src/env_pipeline/inliner.rs index 5502f1d9694f4..295484a6307d0 100644 --- a/third_party/move/move-compiler-v2/src/env_pipeline/inliner.rs +++ b/third_party/move/move-compiler-v2/src/env_pipeline/inliner.rs @@ -90,7 +90,7 @@ pub fn run_inlining(env: &mut GlobalEnv, scope: RewritingScope, keep_inline_func let mut visited_targets = BTreeSet::new(); while let Some(target) = todo.pop_first() { if visited_targets.insert(target.clone()) { - let callees_with_sites = target.called_funs_with_call_sites(env); + let callees_with_sites = target.used_funs_with_uses(env); for (callee, sites) in callees_with_sites { todo.insert(RewriteTarget::MoveFun(callee)); targets.entry(RewriteTarget::MoveFun(callee)); @@ -1161,7 +1161,7 @@ impl<'env, 'rewriter> ExpRewriterFunctions for InlinedRewriter<'env, 'rewriter> }; let call_loc = self.env.get_node_loc(id); if let Some(lambda_target) = optional_lambda_target { - if let ExpData::Lambda(_, pat, body) = lambda_target.as_ref() { + if let ExpData::Lambda(_, pat, body, _, _) = lambda_target.as_ref() { let args_vec: Vec = args.to_vec(); Some(InlinedRewriter::construct_inlined_call_expression( self.env, 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 8326c3e8af618..00e7d94afa68d 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 @@ -40,11 +40,11 @@ //! ``` use itertools::Itertools; -use move_binary_format::file_format::Visibility; +use move_binary_format::file_format::{Ability, AbilitySet, Visibility}; use move_model::{ - ast::{Exp, ExpData, Operation, Pattern, TempIndex}, + ast::{Exp, ExpData, LambdaCaptureKind, Operation, Pattern, TempIndex}, exp_rewriter::{ExpRewriter, ExpRewriterFunctions, RewriteTarget}, - model::{FunId, FunctionEnv, GlobalEnv, Loc, NodeId, Parameter, TypeParameter}, + model::{FunId, FunctionEnv, GlobalEnv, Loc, ModuleId, NodeId, Parameter, TypeParameter}, symbol::Symbol, ty::{ReferenceKind, Type}, }; @@ -192,6 +192,256 @@ impl<'a> LambdaLifter<'a> { exp } } + + // For the current state, calculate: (params, closure_args, param_index_mapping), where + // params = new Parameter for each free var to represent it in the lifted function + // closure_args = corresponding expressions to provide as actual arg for each param + // 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 + fn get_params_for_freevars(&mut self) -> (Vec, Vec, BTreeMap) { + let env = self.fun_env.module_env.env; + let mut closure_args = vec![]; + + // Add captured parameters. We also need to record a mapping of + // parameter indices in the lambda context to indices in the lifted + // functions (courtesy of #12317) + let mut param_index_mapping = BTreeMap::new(); + let mut params = vec![]; + for (used_param_count, (param, var_info)) in + mem::take(&mut self.free_params).into_iter().enumerate() + { + let name = self.fun_env.get_local_name(param); + let ty = env.get_node_type(var_info.node_id); + let loc = env.get_node_loc(var_info.node_id); + if var_info.modified { + env.error( + &loc, + &format!( + "captured variable `{}` cannot be modified inside of a lambda", // TODO(LAMBDA) + name.display(env.symbol_pool()) + ), + ); + } + params.push(Parameter(name, ty.clone(), loc.clone())); + let new_id = env.new_node(loc, ty); + closure_args.push(ExpData::Temporary(new_id, param).into_exp()); + param_index_mapping.insert(param, used_param_count); + } + + // Add captured LocalVar parameters + for (name, var_info) in mem::take(&mut self.free_locals) { + let ty = env.get_node_type(var_info.node_id); + let loc = env.get_node_loc(var_info.node_id); + if var_info.modified { + env.error( + &loc, + &format!( + "captured variable `{}` cannot be modified inside of a lambda", // TODO(LAMBDA) + name.display(env.symbol_pool()) + ), + ); + } + params.push(Parameter(name, ty.clone(), loc.clone())); + let new_id = env.new_node(loc, ty); + closure_args.push(ExpData::LocalVar(new_id, name).into_exp()) + } + + (params, closure_args, param_index_mapping) + } + + fn get_arg_if_simple(arg: &Exp) -> Option<&Exp> { + use ExpData::*; + match &arg.as_ref() { + Value(..) | LocalVar(..) | Temporary(..) | MoveFunctionExp(..) => Some(arg), + Sequence(_, exp_vec) => { + if let [exp] = &exp_vec[..] { + Self::get_arg_if_simple(&exp) + } else { + None + } + }, + Invalid(..) | Call(..) | Invoke(..) | Lambda(..) | Curry(..) | Quant(..) + | Block(..) | IfElse(..) | Match(..) | Return(..) | Loop(..) | LoopCont(..) + | Assign(..) | Mutate(..) | SpecBlock(..) => None, + } + } + + fn get_args_if_simple(args: &[Exp]) -> Option> { + let result: Vec<&Exp> = args + .iter() + .filter_map(|exp| Self::get_arg_if_simple(exp)) + .collect(); + if result.len() == args.len() { + Some(result) + } else { + None + } + } + + fn get_fun_if_simple(fn_exp: &Exp) -> Option { + use ExpData::*; + match fn_exp.as_ref() { + MoveFunctionExp(..) => Some(fn_exp.clone()), + Curry(id, mask, fn_exp, args) => Self::get_fun_if_simple(fn_exp).and_then(|fn_exp| { + Self::get_args_if_simple(args).and_then(|args| { + let args = args.iter().map(|expref| (*expref).clone()).collect(); + Some(ExpData::Curry(*id, *mask, fn_exp, args).into_exp()) + }) + }), + Sequence(_, exp_vec) => { + if let [exp] = &exp_vec[..] { + Self::get_fun_if_simple(&exp) + } else { + None + } + }, + Lambda(_, _pat, _body, _capture_kind, _abilities) => { + // maybe could test lambda_is_direct_curry(pat, body) + // and do something with it, but it is nontrivial. + None + }, + Value(..) | LocalVar(..) | Temporary(..) | Invalid(..) | Call(..) | Invoke(..) + | Quant(..) | Block(..) | IfElse(..) | Match(..) | Return(..) | Loop(..) + | LoopCont(..) | Assign(..) | Mutate(..) | SpecBlock(..) => None, + } + } + + fn make_move_fn_exp( + &mut self, + loc: Loc, + fn_type: Type, + module_id: ModuleId, + fun_id: FunId, + ) -> Exp { + let env = self.fun_env.module_env.env; + let id = env.new_node(loc, fn_type); + let fn_exp = ExpData::MoveFunctionExp(id, module_id, fun_id); + fn_exp.into_exp() + } + + fn get_move_fn_type(&mut self, expr_id: NodeId, module_id: ModuleId, fun_id: FunId) -> Type { + let env = self.fun_env.module_env.env; + let fn_env = env.get_function(module_id.qualified(fun_id)); + let params = fn_env.get_parameters_ref(); + let param_types = params.iter().map(|param| param.get_type()).collect(); + let node_instantiation = env.get_node_instantiation(expr_id); + let result_type = fn_env.get_result_type(); + let visibility = fn_env.visibility(); + let abilities = AbilitySet::FUNCTIONS + | match visibility { + Visibility::Public => { + AbilitySet::singleton(Ability::Store) | AbilitySet::singleton(Ability::Copy) + }, + Visibility::Private | Visibility::Friend => AbilitySet::singleton(Ability::Copy), + }; + Type::Fun( + Box::new(Type::Tuple(param_types)), + Box::new(result_type), + abilities, + ) + .instantiate(&node_instantiation) + } + + // If body is a function call expression with the function value and each parameter a + // simple expression (constant, var, or Move function name) then returns expressions for + // the function and the arguments. Otherwise, returns `None`. + fn lambda_reduces_to_curry<'b>(&mut self, body: &'b Exp) -> Option<(Exp, Vec<&'b Exp>)> { + use ExpData::*; + let env = self.fun_env.module_env.env; + match body.as_ref() { + Call(id, oper, args) => { + if let Operation::MoveFunction(mid, fid) = oper { + Self::get_args_if_simple(args).map(|args| { + let fn_type = self.get_move_fn_type(*id, *mid, *fid); + let loc = env.get_node_loc(*id); + let fn_exp = self.make_move_fn_exp(loc, fn_type, *mid, *fid); + (fn_exp, args) + }) + } else { + None + } + }, + Invoke(_id, fn_exp, args) => Self::get_args_if_simple(args) + .and_then(|args| Self::get_fun_if_simple(fn_exp).map(|exp| (exp, args))), + Curry(_id, _mask, _fn_exp, _args) => None, + MoveFunctionExp(_id, _mid, _fid) => None, + ExpData::Sequence(_id, exp_vec) => { + if let [exp] = &exp_vec[..] { + self.lambda_reduces_to_curry(exp) + } else { + None + } + }, + _ => None, + } + } + + // We can rewrite a lambda directly into a curry expression if: + // - lambda parameters are a simple variable tuple (v1, v2, ...) === (bindings.is_empty()) + // Caller should already check that, and place the tuple of variables in parameter list lambda_params. + // + // Then, we can reduce to curry if: + // - lambda body is a function call with + // - each lambda parameter used exactly once as a call argument, in order (possibly with gaps) + // - every other argument is a simple expression containing only constants and free variables + // Arguments here are + // - id: original lambda expr NodeId + // - body: body of lambda + // - lambda_params: a Parameter corresponding to each lambda param + fn try_to_reduce_lambda_to_curry( + &mut self, + id: NodeId, + body: &Exp, + lambda_params: Vec, + ) -> Option { + if let Some((fn_exp, args)) = self.lambda_reduces_to_curry(body) { + // lambda has form |lambda_params| fn_exp(args) + // where each arg is a constant or simple variable + let mut new_args = vec![]; + let mut mask: u128 = 0; // has a 1 bit for the position of each lambda parameter in call + let mut param_cursor = 0; // tracks which lambda param we are expecting + let mut has_mismatch = false; + let param_syms: BTreeSet = + lambda_params.iter().map(|param| param.get_name()).collect(); + let mut mask_cursor = 1u128; // = 1u128<<(loop index) + for arg in args.iter() { + let this_arg_is_lambda_param = if let ExpData::LocalVar(_id, name) = arg.as_ref() { + if param_syms.contains(name) { + if let Some(param) = lambda_params.get(param_cursor) { + if param.get_name() == *name { + param_cursor += 1; + true + } else { + has_mismatch = true; + break; + } + } else { + has_mismatch = true; + break; + } + } else { + false + } + } else { + false + }; + if !this_arg_is_lambda_param { + // this arg is a free var and is provided as an arg to curry + new_args.push((*arg).clone()); + } else { + // this arg is a lambda parameter + mask |= mask_cursor; + } + mask_cursor <<= 1; + } + if !has_mismatch { + let env = self.fun_env.module_env.env; + let id = env.clone_node(id); + return Some(ExpData::Curry(id, mask, fn_exp, new_args).into_exp()); + }; + }; + None + } } impl<'a> ExpRewriterFunctions for LambdaLifter<'a> { @@ -288,79 +538,84 @@ impl<'a> ExpRewriterFunctions for LambdaLifter<'a> { None } - fn rewrite_lambda(&mut self, id: NodeId, pat: &Pattern, body: &Exp) -> Option { + fn rewrite_lambda( + &mut self, + id: NodeId, + pat: &Pattern, + body: &Exp, + capture_kind: LambdaCaptureKind, + abilities: AbilitySet, // TODO(LAMBDA): do something with this + ) -> Option { if self.exempted_lambdas.contains(&id) { return None; } let env = self.fun_env.module_env.env; - let mut params = vec![]; - let mut closure_args = vec![]; - // Add captured parameters. We also need to record a mapping of - // parameter indices in the lambda context to indices in the lifted - // functions (courtesy of #12317) - let mut param_index_mapping = BTreeMap::new(); - for (used_param_count, (param, var_info)) in - mem::take(&mut self.free_params).into_iter().enumerate() - { - let name = self.fun_env.get_local_name(param); - let ty = env.get_node_type(var_info.node_id); - let loc = env.get_node_loc(var_info.node_id); - if var_info.modified { - env.error( - &loc, - &format!( - "captured variable `{}` cannot be modified inside of a lambda", // TODO(LAMBDA) - name.display(env.symbol_pool()) - ), - ); - } - params.push(Parameter(name, ty.clone(), loc.clone())); - let new_id = env.new_node(loc, ty); - closure_args.push(ExpData::Temporary(new_id, param).into_exp()); - param_index_mapping.insert(param, used_param_count); - } - // Add captured locals - for (name, var_info) in mem::take(&mut self.free_locals) { - let ty = env.get_node_type(var_info.node_id); - let loc = env.get_node_loc(var_info.node_id); - if var_info.modified { + let module_id = self.fun_env.module_env.get_id(); + + match capture_kind { + LambdaCaptureKind::Move => { + // OK. + }, + LambdaCaptureKind::Default | LambdaCaptureKind::Copy | LambdaCaptureKind::Borrow => { + let loc = env.get_node_loc(id); env.error( &loc, - &format!( - "captured variable `{}` cannot be modified inside of a lambda", // TODO(LAMBDA) - name.display(env.symbol_pool()) - ), + // TODO(LAMBDA) + "Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall." ); - } - params.push(Parameter(name, ty.clone(), loc.clone())); - let new_id = env.new_node(loc, ty); - closure_args.push(ExpData::LocalVar(new_id, name).into_exp()) - } + return None; + }, + }; + + // params = new Parameter for each free var to represent it in the lifted function + // closure_args = corresponding expressions to provide as actual arg for each param + // 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 (params, 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 // to collect a list of bindings. let mut bindings = vec![]; + let mut lambda_params = vec![]; for (i, arg) in pat.clone().flatten().into_iter().enumerate() { let id = arg.node_id(); let ty = env.get_node_type(id); let loc = env.get_node_loc(id); if let Pattern::Var(_, name) = arg { - params.push(Parameter(name, ty, loc)) + lambda_params.push(Parameter(name, ty, loc)); } else { let name = self.gen_parameter_name(i); - params.push(Parameter(name, ty.clone(), loc.clone())); + lambda_params.push(Parameter(name, ty.clone(), loc.clone())); let new_id = env.new_node(loc, ty); bindings.push((arg.clone(), ExpData::LocalVar(new_id, name).into_exp())) } } + + // We can rewrite a lambda directly into a curry expression if: + // - lambda parameters are a simple variable tuple (v1, v2, ...) === (bindings.is_empty()) + // + // - lambda body is a function call with + // - each lambda parameter used exactly once as a call argument, in order (possibly with gaps) + // - every other argument is a simple expression containing only constants and free variables + if bindings.is_empty() { + let possible_curry_exp = self.try_to_reduce_lambda_to_curry(id, body, lambda_params); + if possible_curry_exp.is_some() { + return possible_curry_exp; + } + } + // Add new closure function let fun_name = self.gen_closure_function_name(); let lambda_loc = env.get_node_loc(id).clone(); let lambda_type = env.get_node_type(id); - let result_type = if let Type::Fun(_, result_type) = &lambda_type { + let result_type = if let Type::Fun(_, result_type, _) = &lambda_type { *result_type.clone() } else { Type::Error // type error reported }; + // Rewrite references to Temporary in the new functions body (#12317) let mut replacer = |id: NodeId, target: RewriteTarget| { if let RewriteTarget::Temporary(temp) = target { @@ -370,23 +625,37 @@ impl<'a> ExpRewriterFunctions for LambdaLifter<'a> { None }; let body = ExpRewriter::new(env, &mut replacer).rewrite_exp(body.clone()); + let fun_id = FunId::new(fun_name); + let params_types = params.iter().map(|param| param.get_type()).collect(); self.lifted.push(ClosureFunction { loc: lambda_loc.clone(), - fun_id: FunId::new(fun_name), + fun_id: fun_id.clone(), type_params: self.fun_env.get_type_parameters(), params, - result_type, + result_type: result_type.clone(), def: self.bind(bindings, body), }); - // Return closure expression - let id = env.new_node(lambda_loc, lambda_type); - Some( - ExpData::Call( - id, - Operation::Closure(self.fun_env.module_env.get_id(), FunId::new(fun_name)), - closure_args, - ) - .into_exp(), - ) + + // Create an expression for the function reference + let fn_type = Type::Fun( + Box::new(Type::Tuple(params_types)), + Box::new(result_type), + abilities, + ); + let id = env.new_node(lambda_loc.clone(), fn_type); + let fn_exp = ExpData::MoveFunctionExp(id, module_id, fun_id).into_exp(); + + let bound_param_count = closure_args.len(); + if bound_param_count == 0 { + // No free variables, just return the function reference + Some(fn_exp) + } else { + // Create a bitmask for the early-bound parameters. + let bitmask: u128 = (1u128 << bound_param_count) - 1; + + // Create and return closure expression + let id = env.new_node(lambda_loc, lambda_type); + Some(ExpData::Curry(id, bitmask, fn_exp, closure_args).into_exp()) + } } } diff --git a/third_party/move/move-compiler-v2/src/env_pipeline/rewrite_target.rs b/third_party/move/move-compiler-v2/src/env_pipeline/rewrite_target.rs index 2851f5c2b79c3..9e7adfe62d3b1 100644 --- a/third_party/move/move-compiler-v2/src/env_pipeline/rewrite_target.rs +++ b/third_party/move/move-compiler-v2/src/env_pipeline/rewrite_target.rs @@ -159,8 +159,8 @@ impl RewriteTargets { } impl RewriteTarget { - /// Gets the call sites for the target. - pub fn called_funs_with_call_sites( + /// Gets the functions called or referenced in the target. + pub fn used_funs_with_uses( &self, env: &GlobalEnv, ) -> BTreeMap, BTreeSet> { @@ -179,7 +179,7 @@ impl RewriteTarget { .unwrap_or_default(), SpecBlock(target) => { let spec = env.get_spec_block(target); - spec.called_funs_with_callsites() + spec.used_funs_with_uses() }, } } diff --git a/third_party/move/move-compiler-v2/src/env_pipeline/spec_rewriter.rs b/third_party/move/move-compiler-v2/src/env_pipeline/spec_rewriter.rs index dd9fd65ae1402..1251e40f021ee 100644 --- a/third_party/move/move-compiler-v2/src/env_pipeline/spec_rewriter.rs +++ b/third_party/move/move-compiler-v2/src/env_pipeline/spec_rewriter.rs @@ -70,7 +70,7 @@ pub fn run_spec_rewriter(env: &mut GlobalEnv) { if let RewriteState::Def(def) = target.get_env_state(env) { let mut spec_callees = BTreeSet::new(); def.visit_inline_specs(&mut |spec| { - spec_callees.extend(spec.called_funs_with_callsites().into_keys()); + spec_callees.extend(spec.used_funs_with_uses().into_keys()); true // keep going }); spec_callees @@ -78,10 +78,9 @@ pub fn run_spec_rewriter(env: &mut GlobalEnv) { BTreeSet::new() } }, - RewriteTarget::SpecFun(_) | RewriteTarget::SpecBlock(_) => target - .called_funs_with_call_sites(env) - .into_keys() - .collect(), + RewriteTarget::SpecFun(_) | RewriteTarget::SpecBlock(_) => { + target.used_funs_with_uses(env).into_keys().collect() + }, }; for callee in callees { called_funs.insert(callee); diff --git a/third_party/move/move-compiler-v2/src/env_pipeline/unused_params_checker.rs b/third_party/move/move-compiler-v2/src/env_pipeline/unused_params_checker.rs index e9da0d5cbb053..a7a22a0186aca 100644 --- a/third_party/move/move-compiler-v2/src/env_pipeline/unused_params_checker.rs +++ b/third_party/move/move-compiler-v2/src/env_pipeline/unused_params_checker.rs @@ -60,7 +60,7 @@ fn used_type_parameters_in_ty(ty: &Type) -> BTreeSet { }, Type::TypeParameter(i) => BTreeSet::from([*i]), Type::Vector(ty) => used_type_parameters_in_ty(ty), - Type::Fun(t1, t2) => [t1, t2] + Type::Fun(t1, t2, _) => [t1, t2] .iter() .flat_map(|t| used_type_parameters_in_ty(t)) .collect(), diff --git a/third_party/move/move-compiler-v2/src/file_format_generator/module_generator.rs b/third_party/move/move-compiler-v2/src/file_format_generator/module_generator.rs index 483020e61a99e..f054bf5a76dce 100644 --- a/third_party/move/move-compiler-v2/src/file_format_generator/module_generator.rs +++ b/third_party/move/move-compiler-v2/src/file_format_generator/module_generator.rs @@ -365,7 +365,7 @@ impl ModuleGenerator { ReferenceKind::Mutable => FF::SignatureToken::MutableReference(target_ty), } }, - Fun(_param_ty, _result_ty) => { + Fun(_param_ty, _result_ty, _abilities) => { // TODO(LAMBDA) ctx.error( loc, @@ -1075,7 +1075,7 @@ impl<'env> ModuleContext<'env> { if fun.is_inline() { continue; } - if let Some(callees) = fun.get_called_functions() { + if let Some(callees) = fun.get_used_functions() { let mut usage = usage_map[&fun.get_id()].clone(); let count = usage.len(); // Extend usage by that of callees from the same module. Acquires is only diff --git a/third_party/move/move-compiler-v2/tests/lambda-lifting/basic.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda-lifting/basic.lambda.exp index aecce2d0e9059..00d71301d2cd7 100644 --- a/third_party/move/move-compiler-v2/tests/lambda-lifting/basic.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda-lifting/basic.lambda.exp @@ -1,331 +1,18 @@ -// -- Model dump before env processor pipeline: -module 0xcafe::m { - private fun map(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun no_name_clash(x: u64,c: u64): u64 { - m::map(x, |y: u64| Add(y, c)) - } - private fun with_name_clash1(x: u64,c: u64): u64 { - m::map(x, |x: u64| Add(x, c)) - } - private fun with_name_clash2(x: u64,c: u64): u64 { - m::map(x, |x: u64| Add({ - let x: u64 = Add(c, 1); - x - }, x)) - } -} // end 0xcafe::m - - -// -- Model dump after env processor unused checks: -module 0xcafe::m { - private fun map(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun no_name_clash(x: u64,c: u64): u64 { - m::map(x, |y: u64| Add(y, c)) - } - private fun with_name_clash1(x: u64,c: u64): u64 { - m::map(x, |x: u64| Add(x, c)) - } - private fun with_name_clash2(x: u64,c: u64): u64 { - m::map(x, |x: u64| Add({ - let x: u64 = Add(c, 1); - x - }, x)) - } -} // end 0xcafe::m - - -// -- Model dump after env processor type parameter check: -module 0xcafe::m { - private fun map(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun no_name_clash(x: u64,c: u64): u64 { - m::map(x, |y: u64| Add(y, c)) - } - private fun with_name_clash1(x: u64,c: u64): u64 { - m::map(x, |x: u64| Add(x, c)) - } - private fun with_name_clash2(x: u64,c: u64): u64 { - m::map(x, |x: u64| Add({ - let x: u64 = Add(c, 1); - x - }, x)) - } -} // end 0xcafe::m - - -// -- Model dump after env processor check recursive struct definition: -module 0xcafe::m { - private fun map(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun no_name_clash(x: u64,c: u64): u64 { - m::map(x, |y: u64| Add(y, c)) - } - private fun with_name_clash1(x: u64,c: u64): u64 { - m::map(x, |x: u64| Add(x, c)) - } - private fun with_name_clash2(x: u64,c: u64): u64 { - m::map(x, |x: u64| Add({ - let x: u64 = Add(c, 1); - x - }, x)) - } -} // end 0xcafe::m - - -// -- Model dump after env processor check cyclic type instantiation: -module 0xcafe::m { - private fun map(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun no_name_clash(x: u64,c: u64): u64 { - m::map(x, |y: u64| Add(y, c)) - } - private fun with_name_clash1(x: u64,c: u64): u64 { - m::map(x, |x: u64| Add(x, c)) - } - private fun with_name_clash2(x: u64,c: u64): u64 { - m::map(x, |x: u64| Add({ - let x: u64 = Add(c, 1); - x - }, x)) - } -} // end 0xcafe::m - - -// -- Model dump after env processor unused struct params check: -module 0xcafe::m { - private fun map(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun no_name_clash(x: u64,c: u64): u64 { - m::map(x, |y: u64| Add(y, c)) - } - private fun with_name_clash1(x: u64,c: u64): u64 { - m::map(x, |x: u64| Add(x, c)) - } - private fun with_name_clash2(x: u64,c: u64): u64 { - m::map(x, |x: u64| Add({ - let x: u64 = Add(c, 1); - x - }, x)) - } -} // end 0xcafe::m - - -// -- Model dump after env processor access and use check before inlining: -module 0xcafe::m { - private fun map(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun no_name_clash(x: u64,c: u64): u64 { - m::map(x, |y: u64| Add(y, c)) - } - private fun with_name_clash1(x: u64,c: u64): u64 { - m::map(x, |x: u64| Add(x, c)) - } - private fun with_name_clash2(x: u64,c: u64): u64 { - m::map(x, |x: u64| Add({ - let x: u64 = Add(c, 1); - x - }, x)) - } -} // end 0xcafe::m - - -// -- Model dump after env processor inlining: -module 0xcafe::m { - private fun map(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun no_name_clash(x: u64,c: u64): u64 { - m::map(x, |y: u64| Add(y, c)) - } - private fun with_name_clash1(x: u64,c: u64): u64 { - m::map(x, |x: u64| Add(x, c)) - } - private fun with_name_clash2(x: u64,c: u64): u64 { - m::map(x, |x: u64| Add({ - let x: u64 = Add(c, 1); - x - }, x)) - } -} // end 0xcafe::m - - -// -- Model dump after env processor access and use check after inlining: -module 0xcafe::m { - private fun map(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun no_name_clash(x: u64,c: u64): u64 { - m::map(x, |y: u64| Add(y, c)) - } - private fun with_name_clash1(x: u64,c: u64): u64 { - m::map(x, |x: u64| Add(x, c)) - } - private fun with_name_clash2(x: u64,c: u64): u64 { - m::map(x, |x: u64| Add({ - let x: u64 = Add(c, 1); - x - }, x)) - } -} // end 0xcafe::m - - -// -- Model dump after env processor acquires check: -module 0xcafe::m { - private fun map(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun no_name_clash(x: u64,c: u64): u64 { - m::map(x, |y: u64| Add(y, c)) - } - private fun with_name_clash1(x: u64,c: u64): u64 { - m::map(x, |x: u64| Add(x, c)) - } - private fun with_name_clash2(x: u64,c: u64): u64 { - m::map(x, |x: u64| Add({ - let x: u64 = Add(c, 1); - x - }, x)) - } -} // end 0xcafe::m - - -// -- Model dump after env processor simplifier: -module 0xcafe::m { - private fun map(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun no_name_clash(x: u64,c: u64): u64 { - m::map(x, |y: u64| Add(y, c)) - } - private fun with_name_clash1(x: u64,c: u64): u64 { - m::map(x, |x: u64| Add(x, c)) - } - private fun with_name_clash2(x: u64,c: u64): u64 { - m::map(x, |x: u64| Add({ - let x: u64 = Add(c, 1); - x - }, x)) - } -} // end 0xcafe::m - - -// -- Model dump after env processor lambda-lifting: -module 0xcafe::m { - private fun map(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun no_name_clash(x: u64,c: u64): u64 { - m::map(x, closure m::no_name_clash$lambda$1(c)) - } - private fun with_name_clash1(x: u64,c: u64): u64 { - m::map(x, closure m::with_name_clash1$lambda$1(c)) - } - private fun with_name_clash2(x: u64,c: u64): u64 { - m::map(x, closure m::with_name_clash2$lambda$1(c)) - } - private fun no_name_clash$lambda$1(c: u64,y: u64): u64 { - Add(y, c) - } - private fun with_name_clash1$lambda$1(c: u64,x: u64): u64 { - Add(x, c) - } - private fun with_name_clash2$lambda$1(c: u64,x: u64): u64 { - Add({ - let x: u64 = Add(c, 1); - x - }, x) - } -} // end 0xcafe::m - - -// -- Model dump after env processor specification checker: -module 0xcafe::m { - private fun map(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun no_name_clash(x: u64,c: u64): u64 { - m::map(x, closure m::no_name_clash$lambda$1(c)) - } - private fun with_name_clash1(x: u64,c: u64): u64 { - m::map(x, closure m::with_name_clash1$lambda$1(c)) - } - private fun with_name_clash2(x: u64,c: u64): u64 { - m::map(x, closure m::with_name_clash2$lambda$1(c)) - } - private fun no_name_clash$lambda$1(c: u64,y: u64): u64 { - Add(y, c) - } - private fun with_name_clash1$lambda$1(c: u64,x: u64): u64 { - Add(x, c) - } - private fun with_name_clash2$lambda$1(c: u64,x: u64): u64 { - Add({ - let x: u64 = Add(c, 1); - x - }, x) - } -} // end 0xcafe::m - - -// -- Model dump after env processor specification rewriter: -module 0xcafe::m { - private fun map(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun no_name_clash(x: u64,c: u64): u64 { - m::map(x, closure m::no_name_clash$lambda$1(c)) - } - private fun with_name_clash1(x: u64,c: u64): u64 { - m::map(x, closure m::with_name_clash1$lambda$1(c)) - } - private fun with_name_clash2(x: u64,c: u64): u64 { - m::map(x, closure m::with_name_clash2$lambda$1(c)) - } - private fun no_name_clash$lambda$1(c: u64,y: u64): u64 { - Add(y, c) - } - private fun with_name_clash1$lambda$1(c: u64,x: u64): u64 { - Add(x, c) - } - private fun with_name_clash2$lambda$1(c: u64,x: u64): u64 { - Add({ - let x: u64 = Add(c, 1); - x - }, x) - } -} // end 0xcafe::m - - Diagnostics: -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda-lifting/basic.move:5:9 - │ -5 │ f(x) - │ ^ - -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda-lifting/basic.move:10:16 │ 10 │ map(x, |y| y + c) │ ^^^^^^^^^ -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda-lifting/basic.move:15:16 │ 15 │ map(x, |x| x + c) │ ^^^^^^^^^ -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda-lifting/basic.move:20:16 │ 20 │ map(x, |x| { diff --git a/third_party/move/move-compiler-v2/tests/lambda-lifting/modify.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda-lifting/modify.lambda.exp index 3664bd2e163bb..3066df6a61bae 100644 --- a/third_party/move/move-compiler-v2/tests/lambda-lifting/modify.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda-lifting/modify.lambda.exp @@ -1,528 +1,51 @@ -// -- Model dump before env processor pipeline: -module 0xcafe::m { - struct S { - x: u64, - } - private fun map(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun assigns_local(x: u64,c: u64): u64 { - { - let z: u64 = 1; - m::map(x, |y: u64| z: u64 = 2; - Add(y, c)) - } - } - private fun assigns_param(x: u64,c: u64): u64 { - m::map(x, |y: u64| x: u64 = 2; - Add(y, c)) - } - private fun borrows_local(x: u64): u64 { - { - let z: u64 = 1; - m::map(x, |y: u64| { - let r: &mut u64 = Borrow(Mutable)(z); - Add(y, Deref(r)) - }) - } - } - private fun borrows_param(x: u64,c: u64): u64 { - m::map(x, |y: u64| { - let r: &mut u64 = Borrow(Mutable)(c); - Add(y, Deref(r)) - }) - } - private fun immutable_borrow_ok(x: u64): u64 { - { - let z: u64 = 1; - m::map(x, |y: u64| { - let r: &u64 = Borrow(Immutable)(z); - Add(y, Deref(r)) - }) - } - } -} // end 0xcafe::m - - -// -- Model dump after env processor unused checks: -module 0xcafe::m { - struct S { - x: u64, - } - private fun map(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun assigns_local(x: u64,c: u64): u64 { - { - let z: u64 = 1; - m::map(x, |y: u64| z: u64 = 2; - Add(y, c)) - } - } - private fun assigns_param(x: u64,c: u64): u64 { - m::map(x, |y: u64| x: u64 = 2; - Add(y, c)) - } - private fun borrows_local(x: u64): u64 { - { - let z: u64 = 1; - m::map(x, |y: u64| { - let r: &mut u64 = Borrow(Mutable)(z); - Add(y, Deref(r)) - }) - } - } - private fun borrows_param(x: u64,c: u64): u64 { - m::map(x, |y: u64| { - let r: &mut u64 = Borrow(Mutable)(c); - Add(y, Deref(r)) - }) - } - private fun immutable_borrow_ok(x: u64): u64 { - { - let z: u64 = 1; - m::map(x, |y: u64| { - let r: &u64 = Borrow(Immutable)(z); - Add(y, Deref(r)) - }) - } - } -} // end 0xcafe::m - - -// -- Model dump after env processor type parameter check: -module 0xcafe::m { - struct S { - x: u64, - } - private fun map(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun assigns_local(x: u64,c: u64): u64 { - { - let z: u64 = 1; - m::map(x, |y: u64| z: u64 = 2; - Add(y, c)) - } - } - private fun assigns_param(x: u64,c: u64): u64 { - m::map(x, |y: u64| x: u64 = 2; - Add(y, c)) - } - private fun borrows_local(x: u64): u64 { - { - let z: u64 = 1; - m::map(x, |y: u64| { - let r: &mut u64 = Borrow(Mutable)(z); - Add(y, Deref(r)) - }) - } - } - private fun borrows_param(x: u64,c: u64): u64 { - m::map(x, |y: u64| { - let r: &mut u64 = Borrow(Mutable)(c); - Add(y, Deref(r)) - }) - } - private fun immutable_borrow_ok(x: u64): u64 { - { - let z: u64 = 1; - m::map(x, |y: u64| { - let r: &u64 = Borrow(Immutable)(z); - Add(y, Deref(r)) - }) - } - } -} // end 0xcafe::m - - -// -- Model dump after env processor check recursive struct definition: -module 0xcafe::m { - struct S { - x: u64, - } - private fun map(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun assigns_local(x: u64,c: u64): u64 { - { - let z: u64 = 1; - m::map(x, |y: u64| z: u64 = 2; - Add(y, c)) - } - } - private fun assigns_param(x: u64,c: u64): u64 { - m::map(x, |y: u64| x: u64 = 2; - Add(y, c)) - } - private fun borrows_local(x: u64): u64 { - { - let z: u64 = 1; - m::map(x, |y: u64| { - let r: &mut u64 = Borrow(Mutable)(z); - Add(y, Deref(r)) - }) - } - } - private fun borrows_param(x: u64,c: u64): u64 { - m::map(x, |y: u64| { - let r: &mut u64 = Borrow(Mutable)(c); - Add(y, Deref(r)) - }) - } - private fun immutable_borrow_ok(x: u64): u64 { - { - let z: u64 = 1; - m::map(x, |y: u64| { - let r: &u64 = Borrow(Immutable)(z); - Add(y, Deref(r)) - }) - } - } -} // end 0xcafe::m - - -// -- Model dump after env processor check cyclic type instantiation: -module 0xcafe::m { - struct S { - x: u64, - } - private fun map(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun assigns_local(x: u64,c: u64): u64 { - { - let z: u64 = 1; - m::map(x, |y: u64| z: u64 = 2; - Add(y, c)) - } - } - private fun assigns_param(x: u64,c: u64): u64 { - m::map(x, |y: u64| x: u64 = 2; - Add(y, c)) - } - private fun borrows_local(x: u64): u64 { - { - let z: u64 = 1; - m::map(x, |y: u64| { - let r: &mut u64 = Borrow(Mutable)(z); - Add(y, Deref(r)) - }) - } - } - private fun borrows_param(x: u64,c: u64): u64 { - m::map(x, |y: u64| { - let r: &mut u64 = Borrow(Mutable)(c); - Add(y, Deref(r)) - }) - } - private fun immutable_borrow_ok(x: u64): u64 { - { - let z: u64 = 1; - m::map(x, |y: u64| { - let r: &u64 = Borrow(Immutable)(z); - Add(y, Deref(r)) - }) - } - } -} // end 0xcafe::m - - -// -- Model dump after env processor unused struct params check: -module 0xcafe::m { - struct S { - x: u64, - } - private fun map(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun assigns_local(x: u64,c: u64): u64 { - { - let z: u64 = 1; - m::map(x, |y: u64| z: u64 = 2; - Add(y, c)) - } - } - private fun assigns_param(x: u64,c: u64): u64 { - m::map(x, |y: u64| x: u64 = 2; - Add(y, c)) - } - private fun borrows_local(x: u64): u64 { - { - let z: u64 = 1; - m::map(x, |y: u64| { - let r: &mut u64 = Borrow(Mutable)(z); - Add(y, Deref(r)) - }) - } - } - private fun borrows_param(x: u64,c: u64): u64 { - m::map(x, |y: u64| { - let r: &mut u64 = Borrow(Mutable)(c); - Add(y, Deref(r)) - }) - } - private fun immutable_borrow_ok(x: u64): u64 { - { - let z: u64 = 1; - m::map(x, |y: u64| { - let r: &u64 = Borrow(Immutable)(z); - Add(y, Deref(r)) - }) - } - } -} // end 0xcafe::m - - -// -- Model dump after env processor access and use check before inlining: -module 0xcafe::m { - struct S { - x: u64, - } - private fun map(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun assigns_local(x: u64,c: u64): u64 { - { - let z: u64 = 1; - m::map(x, |y: u64| z: u64 = 2; - Add(y, c)) - } - } - private fun assigns_param(x: u64,c: u64): u64 { - m::map(x, |y: u64| x: u64 = 2; - Add(y, c)) - } - private fun borrows_local(x: u64): u64 { - { - let z: u64 = 1; - m::map(x, |y: u64| { - let r: &mut u64 = Borrow(Mutable)(z); - Add(y, Deref(r)) - }) - } - } - private fun borrows_param(x: u64,c: u64): u64 { - m::map(x, |y: u64| { - let r: &mut u64 = Borrow(Mutable)(c); - Add(y, Deref(r)) - }) - } - private fun immutable_borrow_ok(x: u64): u64 { - { - let z: u64 = 1; - m::map(x, |y: u64| { - let r: &u64 = Borrow(Immutable)(z); - Add(y, Deref(r)) - }) - } - } -} // end 0xcafe::m - - -// -- Model dump after env processor inlining: -module 0xcafe::m { - struct S { - x: u64, - } - private fun map(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun assigns_local(x: u64,c: u64): u64 { - { - let z: u64 = 1; - m::map(x, |y: u64| z: u64 = 2; - Add(y, c)) - } - } - private fun assigns_param(x: u64,c: u64): u64 { - m::map(x, |y: u64| x: u64 = 2; - Add(y, c)) - } - private fun borrows_local(x: u64): u64 { - { - let z: u64 = 1; - m::map(x, |y: u64| { - let r: &mut u64 = Borrow(Mutable)(z); - Add(y, Deref(r)) - }) - } - } - private fun borrows_param(x: u64,c: u64): u64 { - m::map(x, |y: u64| { - let r: &mut u64 = Borrow(Mutable)(c); - Add(y, Deref(r)) - }) - } - private fun immutable_borrow_ok(x: u64): u64 { - { - let z: u64 = 1; - m::map(x, |y: u64| { - let r: &u64 = Borrow(Immutable)(z); - Add(y, Deref(r)) - }) - } - } -} // end 0xcafe::m - - -// -- Model dump after env processor access and use check after inlining: -module 0xcafe::m { - struct S { - x: u64, - } - private fun map(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun assigns_local(x: u64,c: u64): u64 { - { - let z: u64 = 1; - m::map(x, |y: u64| z: u64 = 2; - Add(y, c)) - } - } - private fun assigns_param(x: u64,c: u64): u64 { - m::map(x, |y: u64| x: u64 = 2; - Add(y, c)) - } - private fun borrows_local(x: u64): u64 { - { - let z: u64 = 1; - m::map(x, |y: u64| { - let r: &mut u64 = Borrow(Mutable)(z); - Add(y, Deref(r)) - }) - } - } - private fun borrows_param(x: u64,c: u64): u64 { - m::map(x, |y: u64| { - let r: &mut u64 = Borrow(Mutable)(c); - Add(y, Deref(r)) - }) - } - private fun immutable_borrow_ok(x: u64): u64 { - { - let z: u64 = 1; - m::map(x, |y: u64| { - let r: &u64 = Borrow(Immutable)(z); - Add(y, Deref(r)) - }) - } - } -} // end 0xcafe::m - - -// -- Model dump after env processor acquires check: -module 0xcafe::m { - struct S { - x: u64, - } - private fun map(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun assigns_local(x: u64,c: u64): u64 { - { - let z: u64 = 1; - m::map(x, |y: u64| z: u64 = 2; - Add(y, c)) - } - } - private fun assigns_param(x: u64,c: u64): u64 { - m::map(x, |y: u64| x: u64 = 2; - Add(y, c)) - } - private fun borrows_local(x: u64): u64 { - { - let z: u64 = 1; - m::map(x, |y: u64| { - let r: &mut u64 = Borrow(Mutable)(z); - Add(y, Deref(r)) - }) - } - } - private fun borrows_param(x: u64,c: u64): u64 { - m::map(x, |y: u64| { - let r: &mut u64 = Borrow(Mutable)(c); - Add(y, Deref(r)) - }) - } - private fun immutable_borrow_ok(x: u64): u64 { - { - let z: u64 = 1; - m::map(x, |y: u64| { - let r: &u64 = Borrow(Immutable)(z); - Add(y, Deref(r)) - }) - } - } -} // end 0xcafe::m - - -// -- Model dump after env processor simplifier: -module 0xcafe::m { - struct S { - x: u64, - } - private fun map(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun assigns_local(x: u64,c: u64): u64 { - { - let z: u64 = 1; - m::map(x, |y: u64| z: u64 = 2; - Add(y, c)) - } - } - private fun assigns_param(x: u64,c: u64): u64 { - m::map(x, |y: u64| x: u64 = 2; - Add(y, c)) - } - private fun borrows_local(x: u64): u64 { - { - let z: u64 = 1; - m::map(x, |y: u64| { - let r: &mut u64 = Borrow(Mutable)(z); - Add(y, Deref(r)) - }) - } - } - private fun borrows_param(x: u64,c: u64): u64 { - m::map(x, |y: u64| { - let r: &mut u64 = Borrow(Mutable)(c); - Add(y, Deref(r)) - }) - } - private fun immutable_borrow_ok(x: u64): u64 { - m::map(x, |y: u64| { - let r: &u64 = Borrow(Immutable)(1); - Add(y, Deref(r)) - }) - } -} // end 0xcafe::m - - Diagnostics: -error: captured variable `x` cannot be modified inside of a lambda - ┌─ tests/lambda-lifting/modify.move:14:13 +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. + ┌─ tests/lambda-lifting/modify.move:13:16 │ -14 │ x = 2; - │ ^ - -error: captured variable `c` cannot be modified inside of a lambda - ┌─ tests/lambda-lifting/modify.move:21:26 +13 │ map(x, |y| { + │ ╭────────────────^ +14 │ │ x = 2; +15 │ │ y + c +16 │ │ }) + │ ╰─────────^ + +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. + ┌─ tests/lambda-lifting/modify.move:20:16 │ -21 │ let r = &mut c; - │ ^ - -error: captured variable `z` cannot be modified inside of a lambda - ┌─ tests/lambda-lifting/modify.move:29:13 +20 │ map(x, |y| { + │ ╭────────────────^ +21 │ │ let r = &mut c; +22 │ │ y + *r +23 │ │ }) + │ ╰─────────^ + +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. + ┌─ tests/lambda-lifting/modify.move:28:16 │ -29 │ z = 2; - │ ^ - -error: captured variable `z` cannot be modified inside of a lambda - ┌─ tests/lambda-lifting/modify.move:37:26 +28 │ map(x, |y| { + │ ╭────────────────^ +29 │ │ z = 2; +30 │ │ y + c +31 │ │ }) + │ ╰─────────^ + +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. + ┌─ tests/lambda-lifting/modify.move:36:16 + │ +36 │ map(x, |y| { + │ ╭────────────────^ +37 │ │ let r = &mut z; +38 │ │ y + *r +39 │ │ }) + │ ╰─────────^ + +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. + ┌─ tests/lambda-lifting/modify.move:44:16 │ -37 │ let r = &mut z; - │ ^ +44 │ map(x, |y| { + │ ╭────────────────^ +45 │ │ let r = &z; +46 │ │ y + *r +47 │ │ }) + │ ╰─────────^ diff --git a/third_party/move/move-compiler-v2/tests/lambda-lifting/nested.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda-lifting/nested.lambda.exp index cb00e1c4256e8..98bda8b573922 100644 --- a/third_party/move/move-compiler-v2/tests/lambda-lifting/nested.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda-lifting/nested.lambda.exp @@ -1,238 +1,12 @@ -// -- Model dump before env processor pipeline: -module 0xcafe::m { - private fun map1(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun map2(x: u8,f: |u8|u8): u8 { - (f)(x) - } - private fun nested(x: u64,c: u64): u64 { - m::map1(x, |y: u64| Cast(m::map2(Cast(Sub(y, c)), |y: u8| Add(y, Cast(c))))) - } -} // end 0xcafe::m - - -// -- Model dump after env processor unused checks: -module 0xcafe::m { - private fun map1(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun map2(x: u8,f: |u8|u8): u8 { - (f)(x) - } - private fun nested(x: u64,c: u64): u64 { - m::map1(x, |y: u64| Cast(m::map2(Cast(Sub(y, c)), |y: u8| Add(y, Cast(c))))) - } -} // end 0xcafe::m - - -// -- Model dump after env processor type parameter check: -module 0xcafe::m { - private fun map1(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun map2(x: u8,f: |u8|u8): u8 { - (f)(x) - } - private fun nested(x: u64,c: u64): u64 { - m::map1(x, |y: u64| Cast(m::map2(Cast(Sub(y, c)), |y: u8| Add(y, Cast(c))))) - } -} // end 0xcafe::m - - -// -- Model dump after env processor check recursive struct definition: -module 0xcafe::m { - private fun map1(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun map2(x: u8,f: |u8|u8): u8 { - (f)(x) - } - private fun nested(x: u64,c: u64): u64 { - m::map1(x, |y: u64| Cast(m::map2(Cast(Sub(y, c)), |y: u8| Add(y, Cast(c))))) - } -} // end 0xcafe::m - - -// -- Model dump after env processor check cyclic type instantiation: -module 0xcafe::m { - private fun map1(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun map2(x: u8,f: |u8|u8): u8 { - (f)(x) - } - private fun nested(x: u64,c: u64): u64 { - m::map1(x, |y: u64| Cast(m::map2(Cast(Sub(y, c)), |y: u8| Add(y, Cast(c))))) - } -} // end 0xcafe::m - - -// -- Model dump after env processor unused struct params check: -module 0xcafe::m { - private fun map1(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun map2(x: u8,f: |u8|u8): u8 { - (f)(x) - } - private fun nested(x: u64,c: u64): u64 { - m::map1(x, |y: u64| Cast(m::map2(Cast(Sub(y, c)), |y: u8| Add(y, Cast(c))))) - } -} // end 0xcafe::m - - -// -- Model dump after env processor access and use check before inlining: -module 0xcafe::m { - private fun map1(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun map2(x: u8,f: |u8|u8): u8 { - (f)(x) - } - private fun nested(x: u64,c: u64): u64 { - m::map1(x, |y: u64| Cast(m::map2(Cast(Sub(y, c)), |y: u8| Add(y, Cast(c))))) - } -} // end 0xcafe::m - - -// -- Model dump after env processor inlining: -module 0xcafe::m { - private fun map1(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun map2(x: u8,f: |u8|u8): u8 { - (f)(x) - } - private fun nested(x: u64,c: u64): u64 { - m::map1(x, |y: u64| Cast(m::map2(Cast(Sub(y, c)), |y: u8| Add(y, Cast(c))))) - } -} // end 0xcafe::m - - -// -- Model dump after env processor access and use check after inlining: -module 0xcafe::m { - private fun map1(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun map2(x: u8,f: |u8|u8): u8 { - (f)(x) - } - private fun nested(x: u64,c: u64): u64 { - m::map1(x, |y: u64| Cast(m::map2(Cast(Sub(y, c)), |y: u8| Add(y, Cast(c))))) - } -} // end 0xcafe::m - - -// -- Model dump after env processor acquires check: -module 0xcafe::m { - private fun map1(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun map2(x: u8,f: |u8|u8): u8 { - (f)(x) - } - private fun nested(x: u64,c: u64): u64 { - m::map1(x, |y: u64| Cast(m::map2(Cast(Sub(y, c)), |y: u8| Add(y, Cast(c))))) - } -} // end 0xcafe::m - - -// -- Model dump after env processor simplifier: -module 0xcafe::m { - private fun map1(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun map2(x: u8,f: |u8|u8): u8 { - (f)(x) - } - private fun nested(x: u64,c: u64): u64 { - m::map1(x, |y: u64| Cast(m::map2(Cast(Sub(y, c)), |y: u8| Add(y, Cast(c))))) - } -} // end 0xcafe::m - - -// -- Model dump after env processor lambda-lifting: -module 0xcafe::m { - private fun map1(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun map2(x: u8,f: |u8|u8): u8 { - (f)(x) - } - private fun nested(x: u64,c: u64): u64 { - m::map1(x, closure m::nested$lambda$2(c)) - } - private fun nested$lambda$1(c: u64,y: u8): u8 { - Add(y, Cast(c)) - } - private fun nested$lambda$2(c: u64,y: u64): u64 { - Cast(m::map2(Cast(Sub(y, c)), closure m::nested$lambda$1(c))) - } -} // end 0xcafe::m - - -// -- Model dump after env processor specification checker: -module 0xcafe::m { - private fun map1(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun map2(x: u8,f: |u8|u8): u8 { - (f)(x) - } - private fun nested(x: u64,c: u64): u64 { - m::map1(x, closure m::nested$lambda$2(c)) - } - private fun nested$lambda$1(c: u64,y: u8): u8 { - Add(y, Cast(c)) - } - private fun nested$lambda$2(c: u64,y: u64): u64 { - Cast(m::map2(Cast(Sub(y, c)), closure m::nested$lambda$1(c))) - } -} // end 0xcafe::m - - -// -- Model dump after env processor specification rewriter: -module 0xcafe::m { - private fun map1(x: u64,f: |u64|u64): u64 { - (f)(x) - } - private fun map2(x: u8,f: |u8|u8): u8 { - (f)(x) - } - private fun nested(x: u64,c: u64): u64 { - m::map1(x, closure m::nested$lambda$2(c)) - } - private fun nested$lambda$1(c: u64,y: u8): u8 { - Add(y, Cast(c)) - } - private fun nested$lambda$2(c: u64,y: u64): u64 { - Cast(m::map2(Cast(Sub(y, c)), closure m::nested$lambda$1(c))) - } -} // end 0xcafe::m - - Diagnostics: -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda-lifting/nested.move:5:9 - │ -5 │ f(x) - │ ^ - -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda-lifting/nested.move:10:9 - │ -10 │ f(x) - │ ^ - -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda-lifting/nested.move:15:42 │ 15 │ map1(x, |y| (map2((y - c as u8), |y| y + (c as u8)) as u64)) │ ^^^^^^^^^^^^^^^^^ -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda-lifting/nested.move:15:17 │ 15 │ map1(x, |y| (map2((y - c as u8), |y| y + (c as u8)) as u64)) diff --git a/third_party/move/move-compiler-v2/tests/lambda-lifting/pattern.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda-lifting/pattern.lambda.exp index 6a897fa9ce92d..a048883254f58 100644 --- a/third_party/move/move-compiler-v2/tests/lambda-lifting/pattern.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda-lifting/pattern.lambda.exp @@ -1,268 +1,6 @@ -// -- Model dump before env processor pipeline: -module 0xcafe::m { - struct S { - x: T, - } - private fun consume(s: S,x: T,f: |(S, T)|T): T { - (f)(s, x) - } - private fun pattern(s: S,x: u64): u64 { - m::consume(s, x, |(m::S{ x }, _y: u64): (S, u64)| { - let y: u64 = x; - Add(x, y) - }) - } -} // end 0xcafe::m - - -// -- Model dump after env processor unused checks: -module 0xcafe::m { - struct S { - x: T, - } - private fun consume(s: S,x: T,f: |(S, T)|T): T { - (f)(s, x) - } - private fun pattern(s: S,x: u64): u64 { - m::consume(s, x, |(m::S{ x }, _y: u64): (S, u64)| { - let y: u64 = x; - Add(x, y) - }) - } -} // end 0xcafe::m - - -// -- Model dump after env processor type parameter check: -module 0xcafe::m { - struct S { - x: T, - } - private fun consume(s: S,x: T,f: |(S, T)|T): T { - (f)(s, x) - } - private fun pattern(s: S,x: u64): u64 { - m::consume(s, x, |(m::S{ x }, _y: u64): (S, u64)| { - let y: u64 = x; - Add(x, y) - }) - } -} // end 0xcafe::m - - -// -- Model dump after env processor check recursive struct definition: -module 0xcafe::m { - struct S { - x: T, - } - private fun consume(s: S,x: T,f: |(S, T)|T): T { - (f)(s, x) - } - private fun pattern(s: S,x: u64): u64 { - m::consume(s, x, |(m::S{ x }, _y: u64): (S, u64)| { - let y: u64 = x; - Add(x, y) - }) - } -} // end 0xcafe::m - - -// -- Model dump after env processor check cyclic type instantiation: -module 0xcafe::m { - struct S { - x: T, - } - private fun consume(s: S,x: T,f: |(S, T)|T): T { - (f)(s, x) - } - private fun pattern(s: S,x: u64): u64 { - m::consume(s, x, |(m::S{ x }, _y: u64): (S, u64)| { - let y: u64 = x; - Add(x, y) - }) - } -} // end 0xcafe::m - - -// -- Model dump after env processor unused struct params check: -module 0xcafe::m { - struct S { - x: T, - } - private fun consume(s: S,x: T,f: |(S, T)|T): T { - (f)(s, x) - } - private fun pattern(s: S,x: u64): u64 { - m::consume(s, x, |(m::S{ x }, _y: u64): (S, u64)| { - let y: u64 = x; - Add(x, y) - }) - } -} // end 0xcafe::m - - -// -- Model dump after env processor access and use check before inlining: -module 0xcafe::m { - struct S { - x: T, - } - private fun consume(s: S,x: T,f: |(S, T)|T): T { - (f)(s, x) - } - private fun pattern(s: S,x: u64): u64 { - m::consume(s, x, |(m::S{ x }, _y: u64): (S, u64)| { - let y: u64 = x; - Add(x, y) - }) - } -} // end 0xcafe::m - - -// -- Model dump after env processor inlining: -module 0xcafe::m { - struct S { - x: T, - } - private fun consume(s: S,x: T,f: |(S, T)|T): T { - (f)(s, x) - } - private fun pattern(s: S,x: u64): u64 { - m::consume(s, x, |(m::S{ x }, _y: u64): (S, u64)| { - let y: u64 = x; - Add(x, y) - }) - } -} // end 0xcafe::m - - -// -- Model dump after env processor access and use check after inlining: -module 0xcafe::m { - struct S { - x: T, - } - private fun consume(s: S,x: T,f: |(S, T)|T): T { - (f)(s, x) - } - private fun pattern(s: S,x: u64): u64 { - m::consume(s, x, |(m::S{ x }, _y: u64): (S, u64)| { - let y: u64 = x; - Add(x, y) - }) - } -} // end 0xcafe::m - - -// -- Model dump after env processor acquires check: -module 0xcafe::m { - struct S { - x: T, - } - private fun consume(s: S,x: T,f: |(S, T)|T): T { - (f)(s, x) - } - private fun pattern(s: S,x: u64): u64 { - m::consume(s, x, |(m::S{ x }, _y: u64): (S, u64)| { - let y: u64 = x; - Add(x, y) - }) - } -} // end 0xcafe::m - - -// -- Model dump after env processor simplifier: -module 0xcafe::m { - struct S { - x: T, - } - private fun consume(s: S,x: T,f: |(S, T)|T): T { - (f)(s, x) - } - private fun pattern(s: S,x: u64): u64 { - m::consume(s, x, |(m::S{ x }, _y: u64): (S, u64)| { - let y: u64 = x; - Add(x, y) - }) - } -} // end 0xcafe::m - - -// -- Model dump after env processor lambda-lifting: -module 0xcafe::m { - struct S { - x: T, - } - private fun consume(s: S,x: T,f: |(S, T)|T): T { - (f)(s, x) - } - private fun pattern(s: S,x: u64): u64 { - m::consume(s, x, closure m::pattern$lambda$1()) - } - private fun pattern$lambda$1(param$0: S,_y: u64): u64 { - { - let m::S{ x } = param$0; - { - let y: u64 = x; - Add(x, y) - } - } - } -} // end 0xcafe::m - - -// -- Model dump after env processor specification checker: -module 0xcafe::m { - struct S { - x: T, - } - private fun consume(s: S,x: T,f: |(S, T)|T): T { - (f)(s, x) - } - private fun pattern(s: S,x: u64): u64 { - m::consume(s, x, closure m::pattern$lambda$1()) - } - private fun pattern$lambda$1(param$0: S,_y: u64): u64 { - { - let m::S{ x } = param$0; - { - let y: u64 = x; - Add(x, y) - } - } - } -} // end 0xcafe::m - - -// -- Model dump after env processor specification rewriter: -module 0xcafe::m { - struct S { - x: T, - } - private fun consume(s: S,x: T,f: |(S, T)|T): T { - (f)(s, x) - } - private fun pattern(s: S,x: u64): u64 { - m::consume(s, x, closure m::pattern$lambda$1()) - } - private fun pattern$lambda$1(param$0: S,_y: u64): u64 { - { - let m::S{ x } = param$0; - { - let y: u64 = x; - Add(x, y) - } - } - } -} // end 0xcafe::m - - Diagnostics: -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda-lifting/pattern.move:10:9 - │ -10 │ f(s, x) - │ ^ - -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda-lifting/pattern.move:15:23 │ 15 │ consume(s, x, |S{x}, _y| { let y = x; x + y}) diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/break_continue_in_lambda.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/break_continue_in_lambda.lambda.exp index 356f716bf1076..e22d9464ef4e6 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/break_continue_in_lambda.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/break_continue_in_lambda.lambda.exp @@ -1,1406 +1,19 @@ -// -- Model dump before env processor pipeline: -module 0xc0ffee::m { - public fun bar(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk2(|(): ()| break); - m::brk2(|(): ()| loop { - if true { - break - } else { - break - } - }); - m::brk2(|(): ()| loop { - if true { - continue - } else { - break - } - }); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } - private fun brk() { - break; - Tuple() - } - private fun brk2(f: |()|) { - (f)(); - Tuple() - } - private fun brk3() { - loop { - if true { - break; - Tuple() - } else { - break - } - } - } - private fun brk4() { - loop { - if true { - continue; - Tuple() - } else { - break - } - } - } - private fun broken() { - break; - Tuple() - } - private fun continued() { - continue; - Tuple() - } - public fun foo(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk(); - m::brk3(); - m::brk4(); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor unused checks: -module 0xc0ffee::m { - public fun bar(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk2(|(): ()| break); - m::brk2(|(): ()| loop { - if true { - break - } else { - break - } - }); - m::brk2(|(): ()| loop { - if true { - continue - } else { - break - } - }); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } - private fun brk() { - break; - Tuple() - } - private fun brk2(f: |()|) { - (f)(); - Tuple() - } - private fun brk3() { - loop { - if true { - break; - Tuple() - } else { - break - } - } - } - private fun brk4() { - loop { - if true { - continue; - Tuple() - } else { - break - } - } - } - private fun broken() { - break; - Tuple() - } - private fun continued() { - continue; - Tuple() - } - public fun foo(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk(); - m::brk3(); - m::brk4(); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor type parameter check: -module 0xc0ffee::m { - public fun bar(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk2(|(): ()| break); - m::brk2(|(): ()| loop { - if true { - break - } else { - break - } - }); - m::brk2(|(): ()| loop { - if true { - continue - } else { - break - } - }); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } - private fun brk() { - break; - Tuple() - } - private fun brk2(f: |()|) { - (f)(); - Tuple() - } - private fun brk3() { - loop { - if true { - break; - Tuple() - } else { - break - } - } - } - private fun brk4() { - loop { - if true { - continue; - Tuple() - } else { - break - } - } - } - private fun broken() { - break; - Tuple() - } - private fun continued() { - continue; - Tuple() - } - public fun foo(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk(); - m::brk3(); - m::brk4(); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor check recursive struct definition: -module 0xc0ffee::m { - public fun bar(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk2(|(): ()| break); - m::brk2(|(): ()| loop { - if true { - break - } else { - break - } - }); - m::brk2(|(): ()| loop { - if true { - continue - } else { - break - } - }); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } - private fun brk() { - break; - Tuple() - } - private fun brk2(f: |()|) { - (f)(); - Tuple() - } - private fun brk3() { - loop { - if true { - break; - Tuple() - } else { - break - } - } - } - private fun brk4() { - loop { - if true { - continue; - Tuple() - } else { - break - } - } - } - private fun broken() { - break; - Tuple() - } - private fun continued() { - continue; - Tuple() - } - public fun foo(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk(); - m::brk3(); - m::brk4(); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor check cyclic type instantiation: -module 0xc0ffee::m { - public fun bar(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk2(|(): ()| break); - m::brk2(|(): ()| loop { - if true { - break - } else { - break - } - }); - m::brk2(|(): ()| loop { - if true { - continue - } else { - break - } - }); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } - private fun brk() { - break; - Tuple() - } - private fun brk2(f: |()|) { - (f)(); - Tuple() - } - private fun brk3() { - loop { - if true { - break; - Tuple() - } else { - break - } - } - } - private fun brk4() { - loop { - if true { - continue; - Tuple() - } else { - break - } - } - } - private fun broken() { - break; - Tuple() - } - private fun continued() { - continue; - Tuple() - } - public fun foo(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk(); - m::brk3(); - m::brk4(); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor unused struct params check: -module 0xc0ffee::m { - public fun bar(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk2(|(): ()| break); - m::brk2(|(): ()| loop { - if true { - break - } else { - break - } - }); - m::brk2(|(): ()| loop { - if true { - continue - } else { - break - } - }); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } - private fun brk() { - break; - Tuple() - } - private fun brk2(f: |()|) { - (f)(); - Tuple() - } - private fun brk3() { - loop { - if true { - break; - Tuple() - } else { - break - } - } - } - private fun brk4() { - loop { - if true { - continue; - Tuple() - } else { - break - } - } - } - private fun broken() { - break; - Tuple() - } - private fun continued() { - continue; - Tuple() - } - public fun foo(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk(); - m::brk3(); - m::brk4(); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor access and use check before inlining: -module 0xc0ffee::m { - public fun bar(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk2(|(): ()| break); - m::brk2(|(): ()| loop { - if true { - break - } else { - break - } - }); - m::brk2(|(): ()| loop { - if true { - continue - } else { - break - } - }); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } - private fun brk() { - break; - Tuple() - } - private fun brk2(f: |()|) { - (f)(); - Tuple() - } - private fun brk3() { - loop { - if true { - break; - Tuple() - } else { - break - } - } - } - private fun brk4() { - loop { - if true { - continue; - Tuple() - } else { - break - } - } - } - private fun broken() { - break; - Tuple() - } - private fun continued() { - continue; - Tuple() - } - public fun foo(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk(); - m::brk3(); - m::brk4(); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor inlining: -module 0xc0ffee::m { - public fun bar(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk2(|(): ()| break); - m::brk2(|(): ()| loop { - if true { - break - } else { - break - } - }); - m::brk2(|(): ()| loop { - if true { - continue - } else { - break - } - }); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } - private fun brk() { - break; - Tuple() - } - private fun brk2(f: |()|) { - (f)(); - Tuple() - } - private fun brk3() { - loop { - if true { - break; - Tuple() - } else { - break - } - } - } - private fun brk4() { - loop { - if true { - continue; - Tuple() - } else { - break - } - } - } - private fun broken() { - break; - Tuple() - } - private fun continued() { - continue; - Tuple() - } - public fun foo(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk(); - m::brk3(); - m::brk4(); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor access and use check after inlining: -module 0xc0ffee::m { - public fun bar(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk2(|(): ()| break); - m::brk2(|(): ()| loop { - if true { - break - } else { - break - } - }); - m::brk2(|(): ()| loop { - if true { - continue - } else { - break - } - }); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } - private fun brk() { - break; - Tuple() - } - private fun brk2(f: |()|) { - (f)(); - Tuple() - } - private fun brk3() { - loop { - if true { - break; - Tuple() - } else { - break - } - } - } - private fun brk4() { - loop { - if true { - continue; - Tuple() - } else { - break - } - } - } - private fun broken() { - break; - Tuple() - } - private fun continued() { - continue; - Tuple() - } - public fun foo(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk(); - m::brk3(); - m::brk4(); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor acquires check: -module 0xc0ffee::m { - public fun bar(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk2(|(): ()| break); - m::brk2(|(): ()| loop { - if true { - break - } else { - break - } - }); - m::brk2(|(): ()| loop { - if true { - continue - } else { - break - } - }); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } - private fun brk() { - break; - Tuple() - } - private fun brk2(f: |()|) { - (f)(); - Tuple() - } - private fun brk3() { - loop { - if true { - break; - Tuple() - } else { - break - } - } - } - private fun brk4() { - loop { - if true { - continue; - Tuple() - } else { - break - } - } - } - private fun broken() { - break; - Tuple() - } - private fun continued() { - continue; - Tuple() - } - public fun foo(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk(); - m::brk3(); - m::brk4(); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor simplifier: -module 0xc0ffee::m { - public fun bar(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk2(|(): ()| break); - m::brk2(|(): ()| loop { - if true { - break - } else { - break - } - }); - m::brk2(|(): ()| loop { - if true { - continue - } else { - break - } - }); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } - private fun brk() { - break; - Tuple() - } - private fun brk2(f: |()|) { - (f)(); - Tuple() - } - private fun brk3() { - loop { - if true { - break; - Tuple() - } else { - break - } - } - } - private fun brk4() { - loop { - if true { - continue; - Tuple() - } else { - break - } - } - } - private fun broken() { - break; - Tuple() - } - private fun continued() { - continue; - Tuple() - } - public fun foo(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk(); - m::brk3(); - m::brk4(); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor lambda-lifting: -module 0xc0ffee::m { - public fun bar(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk2(closure m::bar$lambda$1()); - m::brk2(closure m::bar$lambda$2()); - m::brk2(closure m::bar$lambda$3()); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } - private fun brk() { - break; - Tuple() - } - private fun brk2(f: |()|) { - (f)(); - Tuple() - } - private fun brk3() { - loop { - if true { - break; - Tuple() - } else { - break - } - } - } - private fun brk4() { - loop { - if true { - continue; - Tuple() - } else { - break - } - } - } - private fun broken() { - break; - Tuple() - } - private fun continued() { - continue; - Tuple() - } - public fun foo(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk(); - m::brk3(); - m::brk4(); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } - private fun bar$lambda$1() { - break - } - private fun bar$lambda$2() { - loop { - if true { - break - } else { - break - } - } - } - private fun bar$lambda$3() { - loop { - if true { - continue - } else { - break - } - } - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor specification checker: -module 0xc0ffee::m { - public fun bar(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk2(closure m::bar$lambda$1()); - m::brk2(closure m::bar$lambda$2()); - m::brk2(closure m::bar$lambda$3()); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } - private fun brk() { - break; - Tuple() - } - private fun brk2(f: |()|) { - (f)(); - Tuple() - } - private fun brk3() { - loop { - if true { - break; - Tuple() - } else { - break - } - } - } - private fun brk4() { - loop { - if true { - continue; - Tuple() - } else { - break - } - } - } - private fun broken() { - break; - Tuple() - } - private fun continued() { - continue; - Tuple() - } - public fun foo(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk(); - m::brk3(); - m::brk4(); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } - private fun bar$lambda$1() { - break - } - private fun bar$lambda$2() { - loop { - if true { - break - } else { - break - } - } - } - private fun bar$lambda$3() { - loop { - if true { - continue - } else { - break - } - } - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor specification rewriter: -module 0xc0ffee::m { - public fun bar(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk2(closure m::bar$lambda$1()); - m::brk2(closure m::bar$lambda$2()); - m::brk2(closure m::bar$lambda$3()); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } - private fun brk() { - break; - Tuple() - } - private fun brk2(f: |()|) { - (f)(); - Tuple() - } - private fun brk3() { - loop { - if true { - break; - Tuple() - } else { - break - } - } - } - private fun brk4() { - loop { - if true { - continue; - Tuple() - } else { - break - } - } - } - private fun broken() { - break; - Tuple() - } - private fun continued() { - continue; - Tuple() - } - public fun foo(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk(); - m::brk3(); - m::brk4(); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } - private fun bar$lambda$1() { - break - } - private fun bar$lambda$2() { - loop { - if true { - break - } else { - break - } - } - } - private fun bar$lambda$3() { - loop { - if true { - continue - } else { - break - } - } - } -} // end 0xc0ffee::m - - Diagnostics: -error: missing enclosing loop statement - ┌─ tests/lambda/inline-parity/break_continue_in_lambda.move:3:9 - │ -3 │ break; - │ ^^^^^ - -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda/inline-parity/break_continue_in_lambda.move:7:9 - │ -7 │ f(); - │ ^ - -error: missing enclosing loop statement - ┌─ tests/lambda/inline-parity/break_continue_in_lambda.move:40:26 - │ -40 │ brk2(| | break); - │ ^^^^^ - -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/break_continue_in_lambda.move:40:22 │ 40 │ brk2(| | break); │ ^^^^^^^^^ -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/break_continue_in_lambda.move:41:8 │ 41 │ brk2(| | while (true) { break }); │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/break_continue_in_lambda.move:42:8 │ 42 │ brk2(| | while (true) { continue }); │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: missing enclosing loop statement - ┌─ tests/lambda/inline-parity/break_continue_in_lambda.move:49:2 - │ -49 │ break; - │ ^^^^^ - -error: missing enclosing loop statement - ┌─ tests/lambda/inline-parity/break_continue_in_lambda.move:53:2 - │ -53 │ continue; - │ ^^^^^^^^ diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/break_continue_in_lambda_typed.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/break_continue_in_lambda_typed.lambda.exp index 84ae1f814873f..586b4d1ad9d4a 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/break_continue_in_lambda_typed.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/break_continue_in_lambda_typed.lambda.exp @@ -1,668 +1,3 @@ -// -- Model dump before env processor pipeline: -module 0xc0ffee::m { - public fun bar(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk2(|_x: u64| break); - m::brk2(|_x: u64| loop { - if true { - break - } else { - break - } - }); - m::brk2(|_x: u64| loop { - if true { - continue - } else { - break - } - }); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } - private inline fun brk() { - break; - Tuple() - } - private inline fun brk2(f: |u64|) { - (f)(2); - Tuple() - } - private inline fun brk3() { - loop { - if true { - break; - Tuple() - } else { - break - } - } - } - private inline fun brk4() { - loop { - if true { - continue; - Tuple() - } else { - break - } - } - } - private fun broken() { - break; - Tuple() - } - private fun continued() { - continue; - Tuple() - } - public fun foo(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk(); - m::brk3(); - m::brk4(); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor unused checks: -module 0xc0ffee::m { - public fun bar(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk2(|_x: u64| break); - m::brk2(|_x: u64| loop { - if true { - break - } else { - break - } - }); - m::brk2(|_x: u64| loop { - if true { - continue - } else { - break - } - }); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } - private inline fun brk() { - break; - Tuple() - } - private inline fun brk2(f: |u64|) { - (f)(2); - Tuple() - } - private inline fun brk3() { - loop { - if true { - break; - Tuple() - } else { - break - } - } - } - private inline fun brk4() { - loop { - if true { - continue; - Tuple() - } else { - break - } - } - } - private fun broken() { - break; - Tuple() - } - private fun continued() { - continue; - Tuple() - } - public fun foo(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk(); - m::brk3(); - m::brk4(); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor type parameter check: -module 0xc0ffee::m { - public fun bar(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk2(|_x: u64| break); - m::brk2(|_x: u64| loop { - if true { - break - } else { - break - } - }); - m::brk2(|_x: u64| loop { - if true { - continue - } else { - break - } - }); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } - private inline fun brk() { - break; - Tuple() - } - private inline fun brk2(f: |u64|) { - (f)(2); - Tuple() - } - private inline fun brk3() { - loop { - if true { - break; - Tuple() - } else { - break - } - } - } - private inline fun brk4() { - loop { - if true { - continue; - Tuple() - } else { - break - } - } - } - private fun broken() { - break; - Tuple() - } - private fun continued() { - continue; - Tuple() - } - public fun foo(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk(); - m::brk3(); - m::brk4(); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor check recursive struct definition: -module 0xc0ffee::m { - public fun bar(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk2(|_x: u64| break); - m::brk2(|_x: u64| loop { - if true { - break - } else { - break - } - }); - m::brk2(|_x: u64| loop { - if true { - continue - } else { - break - } - }); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } - private inline fun brk() { - break; - Tuple() - } - private inline fun brk2(f: |u64|) { - (f)(2); - Tuple() - } - private inline fun brk3() { - loop { - if true { - break; - Tuple() - } else { - break - } - } - } - private inline fun brk4() { - loop { - if true { - continue; - Tuple() - } else { - break - } - } - } - private fun broken() { - break; - Tuple() - } - private fun continued() { - continue; - Tuple() - } - public fun foo(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk(); - m::brk3(); - m::brk4(); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor check cyclic type instantiation: -module 0xc0ffee::m { - public fun bar(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk2(|_x: u64| break); - m::brk2(|_x: u64| loop { - if true { - break - } else { - break - } - }); - m::brk2(|_x: u64| loop { - if true { - continue - } else { - break - } - }); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } - private inline fun brk() { - break; - Tuple() - } - private inline fun brk2(f: |u64|) { - (f)(2); - Tuple() - } - private inline fun brk3() { - loop { - if true { - break; - Tuple() - } else { - break - } - } - } - private inline fun brk4() { - loop { - if true { - continue; - Tuple() - } else { - break - } - } - } - private fun broken() { - break; - Tuple() - } - private fun continued() { - continue; - Tuple() - } - public fun foo(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk(); - m::brk3(); - m::brk4(); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor unused struct params check: -module 0xc0ffee::m { - public fun bar(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk2(|_x: u64| break); - m::brk2(|_x: u64| loop { - if true { - break - } else { - break - } - }); - m::brk2(|_x: u64| loop { - if true { - continue - } else { - break - } - }); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } - private inline fun brk() { - break; - Tuple() - } - private inline fun brk2(f: |u64|) { - (f)(2); - Tuple() - } - private inline fun brk3() { - loop { - if true { - break; - Tuple() - } else { - break - } - } - } - private inline fun brk4() { - loop { - if true { - continue; - Tuple() - } else { - break - } - } - } - private fun broken() { - break; - Tuple() - } - private fun continued() { - continue; - Tuple() - } - public fun foo(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk(); - m::brk3(); - m::brk4(); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor access and use check before inlining: -module 0xc0ffee::m { - public fun bar(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk2(|_x: u64| break); - m::brk2(|_x: u64| loop { - if true { - break - } else { - break - } - }); - m::brk2(|_x: u64| loop { - if true { - continue - } else { - break - } - }); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } - private inline fun brk() { - break; - Tuple() - } - private inline fun brk2(f: |u64|) { - (f)(2); - Tuple() - } - private inline fun brk3() { - loop { - if true { - break; - Tuple() - } else { - break - } - } - } - private inline fun brk4() { - loop { - if true { - continue; - Tuple() - } else { - break - } - } - } - private fun broken() { - break; - Tuple() - } - private fun continued() { - continue; - Tuple() - } - public fun foo(): u64 { - { - let i: u64 = 0; - loop { - if Lt(i, 10) { - i: u64 = Add(i, 1); - if Eq(i, 5) { - m::brk(); - m::brk3(); - m::brk4(); - Tuple() - } else { - Tuple() - } - } else { - break - } - }; - i - } - } -} // end 0xc0ffee::m - - Diagnostics: error: Break outside of a loop not currently supported in inline functions diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/bug_10991.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/bug_10991.lambda.exp index fea2410cdc948..010846a686292 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/bug_10991.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/bug_10991.lambda.exp @@ -1,284 +1,12 @@ -// -- Model dump before env processor pipeline: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun test() { - if Eq(Test::foo(|(x: u64, _: u64): (u64, u64)| x, |(_: u64, y: u64): (u64, u64)| y, 10, 100), 110) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor unused checks: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun test() { - if Eq(Test::foo(|(x: u64, _: u64): (u64, u64)| x, |(_: u64, y: u64): (u64, u64)| y, 10, 100), 110) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor type parameter check: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun test() { - if Eq(Test::foo(|(x: u64, _: u64): (u64, u64)| x, |(_: u64, y: u64): (u64, u64)| y, 10, 100), 110) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor check recursive struct definition: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun test() { - if Eq(Test::foo(|(x: u64, _: u64): (u64, u64)| x, |(_: u64, y: u64): (u64, u64)| y, 10, 100), 110) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun test() { - if Eq(Test::foo(|(x: u64, _: u64): (u64, u64)| x, |(_: u64, y: u64): (u64, u64)| y, 10, 100), 110) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor unused struct params check: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun test() { - if Eq(Test::foo(|(x: u64, _: u64): (u64, u64)| x, |(_: u64, y: u64): (u64, u64)| y, 10, 100), 110) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check before inlining: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun test() { - if Eq(Test::foo(|(x: u64, _: u64): (u64, u64)| x, |(_: u64, y: u64): (u64, u64)| y, 10, 100), 110) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor inlining: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun test() { - if Eq(Test::foo(|(x: u64, _: u64): (u64, u64)| x, |(_: u64, y: u64): (u64, u64)| y, 10, 100), 110) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check after inlining: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun test() { - if Eq(Test::foo(|(x: u64, _: u64): (u64, u64)| x, |(_: u64, y: u64): (u64, u64)| y, 10, 100), 110) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor acquires check: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun test() { - if Eq(Test::foo(|(x: u64, _: u64): (u64, u64)| x, |(_: u64, y: u64): (u64, u64)| y, 10, 100), 110) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor simplifier: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun test() { - if Eq(Test::foo(|(x: u64, _: u64): (u64, u64)| x, |(_: u64, y: u64): (u64, u64)| y, 10, 100), 110) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor lambda-lifting: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun test() { - if Eq(Test::foo(closure Test::test$lambda$1(), closure Test::test$lambda$2(), 10, 100), 110) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - private fun test$lambda$1(x: u64,param$1: u64): u64 { - { - let _: u64 = param$1; - x - } - } - private fun test$lambda$2(param$0: u64,y: u64): u64 { - { - let _: u64 = param$0; - y - } - } -} // end 0x42::Test - - -// -- Model dump after env processor specification checker: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun test() { - if Eq(Test::foo(closure Test::test$lambda$1(), closure Test::test$lambda$2(), 10, 100), 110) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - private fun test$lambda$1(x: u64,param$1: u64): u64 { - { - let _: u64 = param$1; - x - } - } - private fun test$lambda$2(param$0: u64,y: u64): u64 { - { - let _: u64 = param$0; - y - } - } -} // end 0x42::Test - - -// -- Model dump after env processor specification rewriter: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun test() { - if Eq(Test::foo(closure Test::test$lambda$1(), closure Test::test$lambda$2(), 10, 100), 110) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - private fun test$lambda$1(x: u64,param$1: u64): u64 { - { - let _: u64 = param$1; - x - } - } - private fun test$lambda$2(param$0: u64,y: u64): u64 { - { - let _: u64 = param$0; - y - } - } -} // end 0x42::Test - - Diagnostics: -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda/inline-parity/bug_10991.move:4:9 - │ -4 │ f(x, _y) + g(x, _y) - │ ^ - -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda/inline-parity/bug_10991.move:4:20 - │ -4 │ f(x, _y) + g(x, _y) - │ ^ - -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/bug_10991.move:8:21 │ 8 │ assert!(foo(|x, _| x, |_, y| y, 10, 100) == 110, 0); │ ^^^^^^^^ -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/bug_10991.move:8:31 │ 8 │ assert!(foo(|x, _| x, |_, y| y, 10, 100) == 110, 0); diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/bug_10991_noparam.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/bug_10991_noparam.lambda.exp index b1ce2d980a7d7..4e0a669644167 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/bug_10991_noparam.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/bug_10991_noparam.lambda.exp @@ -1,302 +1,12 @@ -// -- Model dump before env processor pipeline: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun test() { - if Eq(Test::foo(|(_: u64, _: u64): (u64, u64)| 3, |(_: u64, _: u64): (u64, u64)| 10, 10, 100), 13) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor unused checks: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun test() { - if Eq(Test::foo(|(_: u64, _: u64): (u64, u64)| 3, |(_: u64, _: u64): (u64, u64)| 10, 10, 100), 13) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor type parameter check: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun test() { - if Eq(Test::foo(|(_: u64, _: u64): (u64, u64)| 3, |(_: u64, _: u64): (u64, u64)| 10, 10, 100), 13) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor check recursive struct definition: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun test() { - if Eq(Test::foo(|(_: u64, _: u64): (u64, u64)| 3, |(_: u64, _: u64): (u64, u64)| 10, 10, 100), 13) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun test() { - if Eq(Test::foo(|(_: u64, _: u64): (u64, u64)| 3, |(_: u64, _: u64): (u64, u64)| 10, 10, 100), 13) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor unused struct params check: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun test() { - if Eq(Test::foo(|(_: u64, _: u64): (u64, u64)| 3, |(_: u64, _: u64): (u64, u64)| 10, 10, 100), 13) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check before inlining: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun test() { - if Eq(Test::foo(|(_: u64, _: u64): (u64, u64)| 3, |(_: u64, _: u64): (u64, u64)| 10, 10, 100), 13) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor inlining: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun test() { - if Eq(Test::foo(|(_: u64, _: u64): (u64, u64)| 3, |(_: u64, _: u64): (u64, u64)| 10, 10, 100), 13) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check after inlining: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun test() { - if Eq(Test::foo(|(_: u64, _: u64): (u64, u64)| 3, |(_: u64, _: u64): (u64, u64)| 10, 10, 100), 13) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor acquires check: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun test() { - if Eq(Test::foo(|(_: u64, _: u64): (u64, u64)| 3, |(_: u64, _: u64): (u64, u64)| 10, 10, 100), 13) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor simplifier: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun test() { - if Eq(Test::foo(|(_: u64, _: u64): (u64, u64)| 3, |(_: u64, _: u64): (u64, u64)| 10, 10, 100), 13) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor lambda-lifting: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun test() { - if Eq(Test::foo(closure Test::test$lambda$1(), closure Test::test$lambda$2(), 10, 100), 13) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - private fun test$lambda$1(param$0: u64,param$1: u64): u64 { - { - let _: u64 = param$1; - { - let _: u64 = param$0; - 3 - } - } - } - private fun test$lambda$2(param$0: u64,param$1: u64): u64 { - { - let _: u64 = param$1; - { - let _: u64 = param$0; - 10 - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor specification checker: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun test() { - if Eq(Test::foo(closure Test::test$lambda$1(), closure Test::test$lambda$2(), 10, 100), 13) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - private fun test$lambda$1(param$0: u64,param$1: u64): u64 { - { - let _: u64 = param$1; - { - let _: u64 = param$0; - 3 - } - } - } - private fun test$lambda$2(param$0: u64,param$1: u64): u64 { - { - let _: u64 = param$1; - { - let _: u64 = param$0; - 10 - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor specification rewriter: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun test() { - if Eq(Test::foo(closure Test::test$lambda$1(), closure Test::test$lambda$2(), 10, 100), 13) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - private fun test$lambda$1(param$0: u64,param$1: u64): u64 { - { - let _: u64 = param$1; - { - let _: u64 = param$0; - 3 - } - } - } - private fun test$lambda$2(param$0: u64,param$1: u64): u64 { - { - let _: u64 = param$1; - { - let _: u64 = param$0; - 10 - } - } - } -} // end 0x42::Test - - Diagnostics: -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda/inline-parity/bug_10991_noparam.move:4:9 - │ -4 │ f(x, _y) + g(x, _y) - │ ^ - -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda/inline-parity/bug_10991_noparam.move:4:20 - │ -4 │ f(x, _y) + g(x, _y) - │ ^ - -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/bug_10991_noparam.move:8:21 │ 8 │ assert!(foo(|_, _| 3, |_, _| 10, 10, 100) == 13, 0); │ ^^^^^^^^ -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/bug_10991_noparam.move:8:31 │ 8 │ assert!(foo(|_, _| 3, |_, _| 10, 10, 100) == 13, 0); diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/bug_10991_noparam2.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/bug_10991_noparam2.lambda.exp index f0eec150641eb..371ec55cd00c2 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/bug_10991_noparam2.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/bug_10991_noparam2.lambda.exp @@ -1,284 +1,12 @@ -// -- Model dump before env processor pipeline: -module 0x42::Test { - private fun foo(f: |u64|u64,g: |u64|u64,x: u64,_: u64): u64 { - Add((f)(x), (g)(x)) - } - public fun test() { - if Eq(Test::foo(|_: u64| 3, |_: u64| 10, 10, 100), 13) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor unused checks: -module 0x42::Test { - private fun foo(f: |u64|u64,g: |u64|u64,x: u64,_: u64): u64 { - Add((f)(x), (g)(x)) - } - public fun test() { - if Eq(Test::foo(|_: u64| 3, |_: u64| 10, 10, 100), 13) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor type parameter check: -module 0x42::Test { - private fun foo(f: |u64|u64,g: |u64|u64,x: u64,_: u64): u64 { - Add((f)(x), (g)(x)) - } - public fun test() { - if Eq(Test::foo(|_: u64| 3, |_: u64| 10, 10, 100), 13) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor check recursive struct definition: -module 0x42::Test { - private fun foo(f: |u64|u64,g: |u64|u64,x: u64,_: u64): u64 { - Add((f)(x), (g)(x)) - } - public fun test() { - if Eq(Test::foo(|_: u64| 3, |_: u64| 10, 10, 100), 13) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x42::Test { - private fun foo(f: |u64|u64,g: |u64|u64,x: u64,_: u64): u64 { - Add((f)(x), (g)(x)) - } - public fun test() { - if Eq(Test::foo(|_: u64| 3, |_: u64| 10, 10, 100), 13) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor unused struct params check: -module 0x42::Test { - private fun foo(f: |u64|u64,g: |u64|u64,x: u64,_: u64): u64 { - Add((f)(x), (g)(x)) - } - public fun test() { - if Eq(Test::foo(|_: u64| 3, |_: u64| 10, 10, 100), 13) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check before inlining: -module 0x42::Test { - private fun foo(f: |u64|u64,g: |u64|u64,x: u64,_: u64): u64 { - Add((f)(x), (g)(x)) - } - public fun test() { - if Eq(Test::foo(|_: u64| 3, |_: u64| 10, 10, 100), 13) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor inlining: -module 0x42::Test { - private fun foo(f: |u64|u64,g: |u64|u64,x: u64,_: u64): u64 { - Add((f)(x), (g)(x)) - } - public fun test() { - if Eq(Test::foo(|_: u64| 3, |_: u64| 10, 10, 100), 13) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check after inlining: -module 0x42::Test { - private fun foo(f: |u64|u64,g: |u64|u64,x: u64,_: u64): u64 { - Add((f)(x), (g)(x)) - } - public fun test() { - if Eq(Test::foo(|_: u64| 3, |_: u64| 10, 10, 100), 13) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor acquires check: -module 0x42::Test { - private fun foo(f: |u64|u64,g: |u64|u64,x: u64,_: u64): u64 { - Add((f)(x), (g)(x)) - } - public fun test() { - if Eq(Test::foo(|_: u64| 3, |_: u64| 10, 10, 100), 13) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor simplifier: -module 0x42::Test { - private fun foo(f: |u64|u64,g: |u64|u64,x: u64,_: u64): u64 { - Add((f)(x), (g)(x)) - } - public fun test() { - if Eq(Test::foo(|_: u64| 3, |_: u64| 10, 10, 100), 13) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor lambda-lifting: -module 0x42::Test { - private fun foo(f: |u64|u64,g: |u64|u64,x: u64,_: u64): u64 { - Add((f)(x), (g)(x)) - } - public fun test() { - if Eq(Test::foo(closure Test::test$lambda$1(), closure Test::test$lambda$2(), 10, 100), 13) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - private fun test$lambda$1(param$0: u64): u64 { - { - let _: u64 = param$0; - 3 - } - } - private fun test$lambda$2(param$0: u64): u64 { - { - let _: u64 = param$0; - 10 - } - } -} // end 0x42::Test - - -// -- Model dump after env processor specification checker: -module 0x42::Test { - private fun foo(f: |u64|u64,g: |u64|u64,x: u64,_: u64): u64 { - Add((f)(x), (g)(x)) - } - public fun test() { - if Eq(Test::foo(closure Test::test$lambda$1(), closure Test::test$lambda$2(), 10, 100), 13) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - private fun test$lambda$1(param$0: u64): u64 { - { - let _: u64 = param$0; - 3 - } - } - private fun test$lambda$2(param$0: u64): u64 { - { - let _: u64 = param$0; - 10 - } - } -} // end 0x42::Test - - -// -- Model dump after env processor specification rewriter: -module 0x42::Test { - private fun foo(f: |u64|u64,g: |u64|u64,x: u64,_: u64): u64 { - Add((f)(x), (g)(x)) - } - public fun test() { - if Eq(Test::foo(closure Test::test$lambda$1(), closure Test::test$lambda$2(), 10, 100), 13) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - private fun test$lambda$1(param$0: u64): u64 { - { - let _: u64 = param$0; - 3 - } - } - private fun test$lambda$2(param$0: u64): u64 { - { - let _: u64 = param$0; - 10 - } - } -} // end 0x42::Test - - Diagnostics: -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda/inline-parity/bug_10991_noparam2.move:4:9 - │ -4 │ f(x) + g(x) - │ ^ - -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda/inline-parity/bug_10991_noparam2.move:4:16 - │ -4 │ f(x) + g(x) - │ ^ - -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/bug_10991_noparam2.move:8:21 │ 8 │ assert!(foo(|_| 3, |_| 10, 10, 100) == 13, 0); │ ^^^^^ -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/bug_10991_noparam2.move:8:28 │ 8 │ assert!(foo(|_| 3, |_| 10, 10, 100) == 13, 0); diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/bug_10991a.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/bug_10991a.lambda.exp index 172a728293cdf..25c91e5fe78b4 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/bug_10991a.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/bug_10991a.lambda.exp @@ -1,326 +1,24 @@ -// -- Model dump before env processor pipeline: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,h: |(u64, u64)|u64,i: |(u64, u64)|u64,x: u64,y: u64): u64 { - Add(Add(Add((f)(x, y), (g)(x, y)), (h)(x, y)), (i)(x, y)) - } - public fun test() { - if Eq(Test::foo(|(x: u64, _: u64): (u64, u64)| x, |(_: u64, y: u64): (u64, u64)| y, |(a: u64, _b: u64): (u64, u64)| a, |(_c: u64, d: u64): (u64, u64)| d, 10, 100), 220) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor unused checks: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,h: |(u64, u64)|u64,i: |(u64, u64)|u64,x: u64,y: u64): u64 { - Add(Add(Add((f)(x, y), (g)(x, y)), (h)(x, y)), (i)(x, y)) - } - public fun test() { - if Eq(Test::foo(|(x: u64, _: u64): (u64, u64)| x, |(_: u64, y: u64): (u64, u64)| y, |(a: u64, _b: u64): (u64, u64)| a, |(_c: u64, d: u64): (u64, u64)| d, 10, 100), 220) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor type parameter check: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,h: |(u64, u64)|u64,i: |(u64, u64)|u64,x: u64,y: u64): u64 { - Add(Add(Add((f)(x, y), (g)(x, y)), (h)(x, y)), (i)(x, y)) - } - public fun test() { - if Eq(Test::foo(|(x: u64, _: u64): (u64, u64)| x, |(_: u64, y: u64): (u64, u64)| y, |(a: u64, _b: u64): (u64, u64)| a, |(_c: u64, d: u64): (u64, u64)| d, 10, 100), 220) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor check recursive struct definition: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,h: |(u64, u64)|u64,i: |(u64, u64)|u64,x: u64,y: u64): u64 { - Add(Add(Add((f)(x, y), (g)(x, y)), (h)(x, y)), (i)(x, y)) - } - public fun test() { - if Eq(Test::foo(|(x: u64, _: u64): (u64, u64)| x, |(_: u64, y: u64): (u64, u64)| y, |(a: u64, _b: u64): (u64, u64)| a, |(_c: u64, d: u64): (u64, u64)| d, 10, 100), 220) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,h: |(u64, u64)|u64,i: |(u64, u64)|u64,x: u64,y: u64): u64 { - Add(Add(Add((f)(x, y), (g)(x, y)), (h)(x, y)), (i)(x, y)) - } - public fun test() { - if Eq(Test::foo(|(x: u64, _: u64): (u64, u64)| x, |(_: u64, y: u64): (u64, u64)| y, |(a: u64, _b: u64): (u64, u64)| a, |(_c: u64, d: u64): (u64, u64)| d, 10, 100), 220) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor unused struct params check: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,h: |(u64, u64)|u64,i: |(u64, u64)|u64,x: u64,y: u64): u64 { - Add(Add(Add((f)(x, y), (g)(x, y)), (h)(x, y)), (i)(x, y)) - } - public fun test() { - if Eq(Test::foo(|(x: u64, _: u64): (u64, u64)| x, |(_: u64, y: u64): (u64, u64)| y, |(a: u64, _b: u64): (u64, u64)| a, |(_c: u64, d: u64): (u64, u64)| d, 10, 100), 220) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check before inlining: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,h: |(u64, u64)|u64,i: |(u64, u64)|u64,x: u64,y: u64): u64 { - Add(Add(Add((f)(x, y), (g)(x, y)), (h)(x, y)), (i)(x, y)) - } - public fun test() { - if Eq(Test::foo(|(x: u64, _: u64): (u64, u64)| x, |(_: u64, y: u64): (u64, u64)| y, |(a: u64, _b: u64): (u64, u64)| a, |(_c: u64, d: u64): (u64, u64)| d, 10, 100), 220) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor inlining: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,h: |(u64, u64)|u64,i: |(u64, u64)|u64,x: u64,y: u64): u64 { - Add(Add(Add((f)(x, y), (g)(x, y)), (h)(x, y)), (i)(x, y)) - } - public fun test() { - if Eq(Test::foo(|(x: u64, _: u64): (u64, u64)| x, |(_: u64, y: u64): (u64, u64)| y, |(a: u64, _b: u64): (u64, u64)| a, |(_c: u64, d: u64): (u64, u64)| d, 10, 100), 220) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check after inlining: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,h: |(u64, u64)|u64,i: |(u64, u64)|u64,x: u64,y: u64): u64 { - Add(Add(Add((f)(x, y), (g)(x, y)), (h)(x, y)), (i)(x, y)) - } - public fun test() { - if Eq(Test::foo(|(x: u64, _: u64): (u64, u64)| x, |(_: u64, y: u64): (u64, u64)| y, |(a: u64, _b: u64): (u64, u64)| a, |(_c: u64, d: u64): (u64, u64)| d, 10, 100), 220) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor acquires check: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,h: |(u64, u64)|u64,i: |(u64, u64)|u64,x: u64,y: u64): u64 { - Add(Add(Add((f)(x, y), (g)(x, y)), (h)(x, y)), (i)(x, y)) - } - public fun test() { - if Eq(Test::foo(|(x: u64, _: u64): (u64, u64)| x, |(_: u64, y: u64): (u64, u64)| y, |(a: u64, _b: u64): (u64, u64)| a, |(_c: u64, d: u64): (u64, u64)| d, 10, 100), 220) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor simplifier: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,h: |(u64, u64)|u64,i: |(u64, u64)|u64,x: u64,y: u64): u64 { - Add(Add(Add((f)(x, y), (g)(x, y)), (h)(x, y)), (i)(x, y)) - } - public fun test() { - if Eq(Test::foo(|(x: u64, _: u64): (u64, u64)| x, |(_: u64, y: u64): (u64, u64)| y, |(a: u64, _b: u64): (u64, u64)| a, |(_c: u64, d: u64): (u64, u64)| d, 10, 100), 220) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor lambda-lifting: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,h: |(u64, u64)|u64,i: |(u64, u64)|u64,x: u64,y: u64): u64 { - Add(Add(Add((f)(x, y), (g)(x, y)), (h)(x, y)), (i)(x, y)) - } - public fun test() { - if Eq(Test::foo(closure Test::test$lambda$1(), closure Test::test$lambda$2(), closure Test::test$lambda$3(), closure Test::test$lambda$4(), 10, 100), 220) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - private fun test$lambda$1(x: u64,param$1: u64): u64 { - { - let _: u64 = param$1; - x - } - } - private fun test$lambda$2(param$0: u64,y: u64): u64 { - { - let _: u64 = param$0; - y - } - } - private fun test$lambda$3(a: u64,_b: u64): u64 { - a - } - private fun test$lambda$4(_c: u64,d: u64): u64 { - d - } -} // end 0x42::Test - - -// -- Model dump after env processor specification checker: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,h: |(u64, u64)|u64,i: |(u64, u64)|u64,x: u64,y: u64): u64 { - Add(Add(Add((f)(x, y), (g)(x, y)), (h)(x, y)), (i)(x, y)) - } - public fun test() { - if Eq(Test::foo(closure Test::test$lambda$1(), closure Test::test$lambda$2(), closure Test::test$lambda$3(), closure Test::test$lambda$4(), 10, 100), 220) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - private fun test$lambda$1(x: u64,param$1: u64): u64 { - { - let _: u64 = param$1; - x - } - } - private fun test$lambda$2(param$0: u64,y: u64): u64 { - { - let _: u64 = param$0; - y - } - } - private fun test$lambda$3(a: u64,_b: u64): u64 { - a - } - private fun test$lambda$4(_c: u64,d: u64): u64 { - d - } -} // end 0x42::Test - - -// -- Model dump after env processor specification rewriter: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,h: |(u64, u64)|u64,i: |(u64, u64)|u64,x: u64,y: u64): u64 { - Add(Add(Add((f)(x, y), (g)(x, y)), (h)(x, y)), (i)(x, y)) - } - public fun test() { - if Eq(Test::foo(closure Test::test$lambda$1(), closure Test::test$lambda$2(), closure Test::test$lambda$3(), closure Test::test$lambda$4(), 10, 100), 220) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - private fun test$lambda$1(x: u64,param$1: u64): u64 { - { - let _: u64 = param$1; - x - } - } - private fun test$lambda$2(param$0: u64,y: u64): u64 { - { - let _: u64 = param$0; - y - } - } - private fun test$lambda$3(a: u64,_b: u64): u64 { - a - } - private fun test$lambda$4(_c: u64,d: u64): u64 { - d - } -} // end 0x42::Test - - Diagnostics: -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda/inline-parity/bug_10991a.move:6:13 - │ -6 │ f(x, y) + g(x, y) + h(x, y) + i(x, y) - │ ^ - -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda/inline-parity/bug_10991a.move:6:23 - │ -6 │ f(x, y) + g(x, y) + h(x, y) + i(x, y) - │ ^ - -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda/inline-parity/bug_10991a.move:6:33 - │ -6 │ f(x, y) + g(x, y) + h(x, y) + i(x, y) - │ ^ - -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda/inline-parity/bug_10991a.move:6:43 - │ -6 │ f(x, y) + g(x, y) + h(x, y) + i(x, y) - │ ^ - -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/bug_10991a.move:10:21 │ 10 │ assert!(foo(|x, _| x, |_, y| y, │ ^^^^^^^^ -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/bug_10991a.move:10:31 │ 10 │ assert!(foo(|x, _| x, |_, y| y, │ ^^^^^^^^ -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/bug_10991a.move:11:6 │ 11 │ |a, _b| a, |_c, d| d, │ ^^^^^^^^^ -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/bug_10991a.move:11:17 │ 11 │ |a, _b| a, |_c, d| d, diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/bug_10991b.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/bug_10991b.lambda.exp index 4d75c19204ac0..b6c3a1e3475eb 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/bug_10991b.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/bug_10991b.lambda.exp @@ -1,254 +1,6 @@ -// -- Model dump before env processor pipeline: -module 0x42::Test { - private fun foo(g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - (g)(x, _y) - } - public fun test() { - if Eq(Test::foo(|(_: u64, y: u64): (u64, u64)| y, 10, 100), 100) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor unused checks: -module 0x42::Test { - private fun foo(g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - (g)(x, _y) - } - public fun test() { - if Eq(Test::foo(|(_: u64, y: u64): (u64, u64)| y, 10, 100), 100) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor type parameter check: -module 0x42::Test { - private fun foo(g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - (g)(x, _y) - } - public fun test() { - if Eq(Test::foo(|(_: u64, y: u64): (u64, u64)| y, 10, 100), 100) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor check recursive struct definition: -module 0x42::Test { - private fun foo(g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - (g)(x, _y) - } - public fun test() { - if Eq(Test::foo(|(_: u64, y: u64): (u64, u64)| y, 10, 100), 100) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x42::Test { - private fun foo(g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - (g)(x, _y) - } - public fun test() { - if Eq(Test::foo(|(_: u64, y: u64): (u64, u64)| y, 10, 100), 100) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor unused struct params check: -module 0x42::Test { - private fun foo(g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - (g)(x, _y) - } - public fun test() { - if Eq(Test::foo(|(_: u64, y: u64): (u64, u64)| y, 10, 100), 100) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check before inlining: -module 0x42::Test { - private fun foo(g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - (g)(x, _y) - } - public fun test() { - if Eq(Test::foo(|(_: u64, y: u64): (u64, u64)| y, 10, 100), 100) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor inlining: -module 0x42::Test { - private fun foo(g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - (g)(x, _y) - } - public fun test() { - if Eq(Test::foo(|(_: u64, y: u64): (u64, u64)| y, 10, 100), 100) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check after inlining: -module 0x42::Test { - private fun foo(g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - (g)(x, _y) - } - public fun test() { - if Eq(Test::foo(|(_: u64, y: u64): (u64, u64)| y, 10, 100), 100) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor acquires check: -module 0x42::Test { - private fun foo(g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - (g)(x, _y) - } - public fun test() { - if Eq(Test::foo(|(_: u64, y: u64): (u64, u64)| y, 10, 100), 100) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor simplifier: -module 0x42::Test { - private fun foo(g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - (g)(x, _y) - } - public fun test() { - if Eq(Test::foo(|(_: u64, y: u64): (u64, u64)| y, 10, 100), 100) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor lambda-lifting: -module 0x42::Test { - private fun foo(g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - (g)(x, _y) - } - public fun test() { - if Eq(Test::foo(closure Test::test$lambda$1(), 10, 100), 100) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - private fun test$lambda$1(param$0: u64,y: u64): u64 { - { - let _: u64 = param$0; - y - } - } -} // end 0x42::Test - - -// -- Model dump after env processor specification checker: -module 0x42::Test { - private fun foo(g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - (g)(x, _y) - } - public fun test() { - if Eq(Test::foo(closure Test::test$lambda$1(), 10, 100), 100) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - private fun test$lambda$1(param$0: u64,y: u64): u64 { - { - let _: u64 = param$0; - y - } - } -} // end 0x42::Test - - -// -- Model dump after env processor specification rewriter: -module 0x42::Test { - private fun foo(g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - (g)(x, _y) - } - public fun test() { - if Eq(Test::foo(closure Test::test$lambda$1(), 10, 100), 100) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - private fun test$lambda$1(param$0: u64,y: u64): u64 { - { - let _: u64 = param$0; - y - } - } -} // end 0x42::Test - - Diagnostics: -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda/inline-parity/bug_10991b.move:4:9 - │ -4 │ g(x, _y) - │ ^ - -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/bug_10991b.move:8:21 │ 8 │ assert!(foo(|_, y| y, diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/bug_10991c.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/bug_10991c.lambda.exp index 486526cead33b..8c14ccf4b24c1 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/bug_10991c.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/bug_10991c.lambda.exp @@ -1,263 +1,6 @@ -// -- Model dump before env processor pipeline: -module 0x42::Test { - private fun foo(g: |(u64, u64, u64, u64)|u64,x: u64,y: u64,z: u64,q: u64): u64 { - (g)(x, y, z, q) - } - public fun test() { - if Eq(Test::foo(|(_: u64, y: u64, _: u64, q: u64): (u64, u64, u64, u64)| Add(y, q), 10, 100, 1000, 10000), 10100) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor unused checks: -module 0x42::Test { - private fun foo(g: |(u64, u64, u64, u64)|u64,x: u64,y: u64,z: u64,q: u64): u64 { - (g)(x, y, z, q) - } - public fun test() { - if Eq(Test::foo(|(_: u64, y: u64, _: u64, q: u64): (u64, u64, u64, u64)| Add(y, q), 10, 100, 1000, 10000), 10100) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor type parameter check: -module 0x42::Test { - private fun foo(g: |(u64, u64, u64, u64)|u64,x: u64,y: u64,z: u64,q: u64): u64 { - (g)(x, y, z, q) - } - public fun test() { - if Eq(Test::foo(|(_: u64, y: u64, _: u64, q: u64): (u64, u64, u64, u64)| Add(y, q), 10, 100, 1000, 10000), 10100) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor check recursive struct definition: -module 0x42::Test { - private fun foo(g: |(u64, u64, u64, u64)|u64,x: u64,y: u64,z: u64,q: u64): u64 { - (g)(x, y, z, q) - } - public fun test() { - if Eq(Test::foo(|(_: u64, y: u64, _: u64, q: u64): (u64, u64, u64, u64)| Add(y, q), 10, 100, 1000, 10000), 10100) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x42::Test { - private fun foo(g: |(u64, u64, u64, u64)|u64,x: u64,y: u64,z: u64,q: u64): u64 { - (g)(x, y, z, q) - } - public fun test() { - if Eq(Test::foo(|(_: u64, y: u64, _: u64, q: u64): (u64, u64, u64, u64)| Add(y, q), 10, 100, 1000, 10000), 10100) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor unused struct params check: -module 0x42::Test { - private fun foo(g: |(u64, u64, u64, u64)|u64,x: u64,y: u64,z: u64,q: u64): u64 { - (g)(x, y, z, q) - } - public fun test() { - if Eq(Test::foo(|(_: u64, y: u64, _: u64, q: u64): (u64, u64, u64, u64)| Add(y, q), 10, 100, 1000, 10000), 10100) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check before inlining: -module 0x42::Test { - private fun foo(g: |(u64, u64, u64, u64)|u64,x: u64,y: u64,z: u64,q: u64): u64 { - (g)(x, y, z, q) - } - public fun test() { - if Eq(Test::foo(|(_: u64, y: u64, _: u64, q: u64): (u64, u64, u64, u64)| Add(y, q), 10, 100, 1000, 10000), 10100) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor inlining: -module 0x42::Test { - private fun foo(g: |(u64, u64, u64, u64)|u64,x: u64,y: u64,z: u64,q: u64): u64 { - (g)(x, y, z, q) - } - public fun test() { - if Eq(Test::foo(|(_: u64, y: u64, _: u64, q: u64): (u64, u64, u64, u64)| Add(y, q), 10, 100, 1000, 10000), 10100) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check after inlining: -module 0x42::Test { - private fun foo(g: |(u64, u64, u64, u64)|u64,x: u64,y: u64,z: u64,q: u64): u64 { - (g)(x, y, z, q) - } - public fun test() { - if Eq(Test::foo(|(_: u64, y: u64, _: u64, q: u64): (u64, u64, u64, u64)| Add(y, q), 10, 100, 1000, 10000), 10100) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor acquires check: -module 0x42::Test { - private fun foo(g: |(u64, u64, u64, u64)|u64,x: u64,y: u64,z: u64,q: u64): u64 { - (g)(x, y, z, q) - } - public fun test() { - if Eq(Test::foo(|(_: u64, y: u64, _: u64, q: u64): (u64, u64, u64, u64)| Add(y, q), 10, 100, 1000, 10000), 10100) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor simplifier: -module 0x42::Test { - private fun foo(g: |(u64, u64, u64, u64)|u64,x: u64,y: u64,z: u64,q: u64): u64 { - (g)(x, y, z, q) - } - public fun test() { - if Eq(Test::foo(|(_: u64, y: u64, _: u64, q: u64): (u64, u64, u64, u64)| Add(y, q), 10, 100, 1000, 10000), 10100) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::Test - - -// -- Model dump after env processor lambda-lifting: -module 0x42::Test { - private fun foo(g: |(u64, u64, u64, u64)|u64,x: u64,y: u64,z: u64,q: u64): u64 { - (g)(x, y, z, q) - } - public fun test() { - if Eq(Test::foo(closure Test::test$lambda$1(), 10, 100, 1000, 10000), 10100) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - private fun test$lambda$1(param$0: u64,y: u64,param$2: u64,q: u64): u64 { - { - let _: u64 = param$2; - { - let _: u64 = param$0; - Add(y, q) - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor specification checker: -module 0x42::Test { - private fun foo(g: |(u64, u64, u64, u64)|u64,x: u64,y: u64,z: u64,q: u64): u64 { - (g)(x, y, z, q) - } - public fun test() { - if Eq(Test::foo(closure Test::test$lambda$1(), 10, 100, 1000, 10000), 10100) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - private fun test$lambda$1(param$0: u64,y: u64,param$2: u64,q: u64): u64 { - { - let _: u64 = param$2; - { - let _: u64 = param$0; - Add(y, q) - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor specification rewriter: -module 0x42::Test { - private fun foo(g: |(u64, u64, u64, u64)|u64,x: u64,y: u64,z: u64,q: u64): u64 { - (g)(x, y, z, q) - } - public fun test() { - if Eq(Test::foo(closure Test::test$lambda$1(), 10, 100, 1000, 10000), 10100) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - private fun test$lambda$1(param$0: u64,y: u64,param$2: u64,q: u64): u64 { - { - let _: u64 = param$2; - { - let _: u64 = param$0; - Add(y, q) - } - } - } -} // end 0x42::Test - - Diagnostics: -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda/inline-parity/bug_10991c.move:4:9 - │ -4 │ g(x, y, z, q) - │ ^ - -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/bug_10991c.move:8:21 │ 8 │ assert!(foo(|_, y, _, q| y + q, diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/dotdot_valid.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/dotdot_valid.lambda.exp index de57ae7f20e1a..6ff406090045e 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/dotdot_valid.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/dotdot_valid.lambda.exp @@ -1,4204 +1,6 @@ -// -- Model dump before env processor pipeline: -module 0x42::test { - enum E1 { - A { - 0: u8, - 1: bool, - } - B { - 0: u8, - } - C { - x: u8, - y: S1, - } - } - struct S0 { - dummy_field: bool, - } - struct S1 { - 0: u8, - } - struct S2 { - 0: bool, - 1: S0, - } - struct S3 { - x: bool, - y: u8, - } - struct S4 { - x: T, - y: S3, - } - struct S5 { - 0: T, - 1: U, - } - struct S6 { - x: T, - y: U, - } - struct S7 { - 0: u8, - 1: u16, - 2: u32, - 3: u64, - } - private fun lambda_param(f: |S2|bool): bool { - { - let x: S2 = pack test::S2(true, pack test::S0(false)); - (f)(x) - } - } - private fun nested1(x: S4) { - { - let test::S4{ x: _x, y: _ } = x; - { - let test::S4{ x: _, y: _y } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _x, y: _ } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _y } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - Tuple() - } - } - } - } - } - } - } - } - private fun nested1_ref(x: &S4) { - { - let test::S4{ x: _x, y: _ } = x; - { - let test::S4{ x: _, y: _y } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _x, y: _ } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _y } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - Tuple() - } - } - } - } - } - } - } - } - private fun nested2(x: S5) { - { - let test::S5{ 0: _, 1: test::S1{ 0: _ } } = x; - Tuple() - } - } - private fun nested2_ref(x: &S5) { - { - let test::S5{ 0: _, 1: test::S1{ 0: _ } } = x; - Tuple() - } - } - private fun nested3(x: S5>) { - { - let test::S5>{ 0: _, 1: test::S4{ x: _, y: _ } } = x; - Tuple() - } - } - private fun nested3_ref(x: &S5>) { - { - let test::S5>{ 0: _, 1: test::S4{ x: _, y: _ } } = x; - Tuple() - } - } - private fun nested4(x: S4) { - { - let test::S4{ x: test::S1{ 0: _ }, y: _ } = x; - Tuple() - } - } - private fun nested4_ref(x: &S4) { - { - let test::S4{ x: test::S1{ 0: _ }, y: _ } = x; - Tuple() - } - } - private fun simple_0(x: S0) { - { - let test::S0{ dummy_field: _ } = x; - Tuple() - } - } - private fun simple_0_ref(x: &S0) { - { - let test::S0{ dummy_field: _ } = x; - Tuple() - } - } - private fun simple_1(x: S1) { - { - let test::S1{ 0: _ } = x; - Tuple() - } - } - private fun simple_1_ref(x: &mut S1) { - { - let test::S1{ 0: _ } = x; - Tuple() - } - } - private fun simple_2(x: S2) { - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _ } = x; - { - let test::S2{ 0: _, 1: _x } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - Tuple() - } - } - } - } - } - } - } - } - } - private fun simple_2_ref(x: &S2) { - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _ } = x; - { - let test::S2{ 0: _, 1: _x } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - Tuple() - } - } - } - } - } - } - } - } - } - private fun simple_3(x: S3) { - { - let test::S3{ x: _, y: _ } = x; - { - let test::S3{ x: _x, y: _ } = x; - { - let test::S3{ x: _, y: _y } = x; - Tuple() - } - } - } - } - private fun simple_3_ref(x: S3) { - { - let test::S3{ x: _, y: _ } = x; - { - let test::S3{ x: _x, y: _ } = x; - { - let test::S3{ x: _, y: _y } = x; - Tuple() - } - } - } - } - private fun simple_4(x: E1): u8 { - match (x) { - test::E1::A{ 0: x, 1: _ } => { - x - } - test::E1::B{ 0: x } => { - x - } - test::E1::C{ x, y: _ } => { - x - } - } - - } - private fun simple_4_ref(x: &E1): &u8 { - match (x) { - test::E1::A{ 0: x, 1: _ } => { - x - } - test::E1::B{ 0: x } => { - x - } - } - - } - private fun simple_5(x: E1): u8 { - match (x) { - test::E1::A{ 0: _, 1: y } => { - if y { - 1 - } else { - 0 - } - } - test::E1::B{ 0: x } => { - x - } - test::E1::C{ x: _, y: test::S1{ 0: x } } => { - x - } - } - - } - private fun simple_6(x: &S7) { - { - let test::S7{ 0: _w, 1: _, 2: _, 3: _z } = x; - { - let test::S7{ 0: _w, 1: _x, 2: _y, 3: _z } = x; - Tuple() - } - } - } - private fun test_lambda_param(): bool { - test::lambda_param(|test::S2{ 0: x, 1: _ }| x) - } -} // end 0x42::test - - -// -- Model dump after env processor unused checks: -module 0x42::test { - enum E1 { - A { - 0: u8, - 1: bool, - } - B { - 0: u8, - } - C { - x: u8, - y: S1, - } - } - struct S0 { - dummy_field: bool, - } - struct S1 { - 0: u8, - } - struct S2 { - 0: bool, - 1: S0, - } - struct S3 { - x: bool, - y: u8, - } - struct S4 { - x: T, - y: S3, - } - struct S5 { - 0: T, - 1: U, - } - struct S6 { - x: T, - y: U, - } - struct S7 { - 0: u8, - 1: u16, - 2: u32, - 3: u64, - } - private fun lambda_param(f: |S2|bool): bool { - { - let x: S2 = pack test::S2(true, pack test::S0(false)); - (f)(x) - } - } - private fun nested1(x: S4) { - { - let test::S4{ x: _x, y: _ } = x; - { - let test::S4{ x: _, y: _y } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _x, y: _ } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _y } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - Tuple() - } - } - } - } - } - } - } - } - private fun nested1_ref(x: &S4) { - { - let test::S4{ x: _x, y: _ } = x; - { - let test::S4{ x: _, y: _y } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _x, y: _ } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _y } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - Tuple() - } - } - } - } - } - } - } - } - private fun nested2(x: S5) { - { - let test::S5{ 0: _, 1: test::S1{ 0: _ } } = x; - Tuple() - } - } - private fun nested2_ref(x: &S5) { - { - let test::S5{ 0: _, 1: test::S1{ 0: _ } } = x; - Tuple() - } - } - private fun nested3(x: S5>) { - { - let test::S5>{ 0: _, 1: test::S4{ x: _, y: _ } } = x; - Tuple() - } - } - private fun nested3_ref(x: &S5>) { - { - let test::S5>{ 0: _, 1: test::S4{ x: _, y: _ } } = x; - Tuple() - } - } - private fun nested4(x: S4) { - { - let test::S4{ x: test::S1{ 0: _ }, y: _ } = x; - Tuple() - } - } - private fun nested4_ref(x: &S4) { - { - let test::S4{ x: test::S1{ 0: _ }, y: _ } = x; - Tuple() - } - } - private fun simple_0(x: S0) { - { - let test::S0{ dummy_field: _ } = x; - Tuple() - } - } - private fun simple_0_ref(x: &S0) { - { - let test::S0{ dummy_field: _ } = x; - Tuple() - } - } - private fun simple_1(x: S1) { - { - let test::S1{ 0: _ } = x; - Tuple() - } - } - private fun simple_1_ref(x: &mut S1) { - { - let test::S1{ 0: _ } = x; - Tuple() - } - } - private fun simple_2(x: S2) { - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _ } = x; - { - let test::S2{ 0: _, 1: _x } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - Tuple() - } - } - } - } - } - } - } - } - } - private fun simple_2_ref(x: &S2) { - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _ } = x; - { - let test::S2{ 0: _, 1: _x } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - Tuple() - } - } - } - } - } - } - } - } - } - private fun simple_3(x: S3) { - { - let test::S3{ x: _, y: _ } = x; - { - let test::S3{ x: _x, y: _ } = x; - { - let test::S3{ x: _, y: _y } = x; - Tuple() - } - } - } - } - private fun simple_3_ref(x: S3) { - { - let test::S3{ x: _, y: _ } = x; - { - let test::S3{ x: _x, y: _ } = x; - { - let test::S3{ x: _, y: _y } = x; - Tuple() - } - } - } - } - private fun simple_4(x: E1): u8 { - match (x) { - test::E1::A{ 0: x, 1: _ } => { - x - } - test::E1::B{ 0: x } => { - x - } - test::E1::C{ x, y: _ } => { - x - } - } - - } - private fun simple_4_ref(x: &E1): &u8 { - match (x) { - test::E1::A{ 0: x, 1: _ } => { - x - } - test::E1::B{ 0: x } => { - x - } - } - - } - private fun simple_5(x: E1): u8 { - match (x) { - test::E1::A{ 0: _, 1: y } => { - if y { - 1 - } else { - 0 - } - } - test::E1::B{ 0: x } => { - x - } - test::E1::C{ x: _, y: test::S1{ 0: x } } => { - x - } - } - - } - private fun simple_6(x: &S7) { - { - let test::S7{ 0: _w, 1: _, 2: _, 3: _z } = x; - { - let test::S7{ 0: _w, 1: _x, 2: _y, 3: _z } = x; - Tuple() - } - } - } - private fun test_lambda_param(): bool { - test::lambda_param(|test::S2{ 0: x, 1: _ }| x) - } -} // end 0x42::test - - -// -- Model dump after env processor type parameter check: -module 0x42::test { - enum E1 { - A { - 0: u8, - 1: bool, - } - B { - 0: u8, - } - C { - x: u8, - y: S1, - } - } - struct S0 { - dummy_field: bool, - } - struct S1 { - 0: u8, - } - struct S2 { - 0: bool, - 1: S0, - } - struct S3 { - x: bool, - y: u8, - } - struct S4 { - x: T, - y: S3, - } - struct S5 { - 0: T, - 1: U, - } - struct S6 { - x: T, - y: U, - } - struct S7 { - 0: u8, - 1: u16, - 2: u32, - 3: u64, - } - private fun lambda_param(f: |S2|bool): bool { - { - let x: S2 = pack test::S2(true, pack test::S0(false)); - (f)(x) - } - } - private fun nested1(x: S4) { - { - let test::S4{ x: _x, y: _ } = x; - { - let test::S4{ x: _, y: _y } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _x, y: _ } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _y } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - Tuple() - } - } - } - } - } - } - } - } - private fun nested1_ref(x: &S4) { - { - let test::S4{ x: _x, y: _ } = x; - { - let test::S4{ x: _, y: _y } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _x, y: _ } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _y } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - Tuple() - } - } - } - } - } - } - } - } - private fun nested2(x: S5) { - { - let test::S5{ 0: _, 1: test::S1{ 0: _ } } = x; - Tuple() - } - } - private fun nested2_ref(x: &S5) { - { - let test::S5{ 0: _, 1: test::S1{ 0: _ } } = x; - Tuple() - } - } - private fun nested3(x: S5>) { - { - let test::S5>{ 0: _, 1: test::S4{ x: _, y: _ } } = x; - Tuple() - } - } - private fun nested3_ref(x: &S5>) { - { - let test::S5>{ 0: _, 1: test::S4{ x: _, y: _ } } = x; - Tuple() - } - } - private fun nested4(x: S4) { - { - let test::S4{ x: test::S1{ 0: _ }, y: _ } = x; - Tuple() - } - } - private fun nested4_ref(x: &S4) { - { - let test::S4{ x: test::S1{ 0: _ }, y: _ } = x; - Tuple() - } - } - private fun simple_0(x: S0) { - { - let test::S0{ dummy_field: _ } = x; - Tuple() - } - } - private fun simple_0_ref(x: &S0) { - { - let test::S0{ dummy_field: _ } = x; - Tuple() - } - } - private fun simple_1(x: S1) { - { - let test::S1{ 0: _ } = x; - Tuple() - } - } - private fun simple_1_ref(x: &mut S1) { - { - let test::S1{ 0: _ } = x; - Tuple() - } - } - private fun simple_2(x: S2) { - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _ } = x; - { - let test::S2{ 0: _, 1: _x } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - Tuple() - } - } - } - } - } - } - } - } - } - private fun simple_2_ref(x: &S2) { - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _ } = x; - { - let test::S2{ 0: _, 1: _x } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - Tuple() - } - } - } - } - } - } - } - } - } - private fun simple_3(x: S3) { - { - let test::S3{ x: _, y: _ } = x; - { - let test::S3{ x: _x, y: _ } = x; - { - let test::S3{ x: _, y: _y } = x; - Tuple() - } - } - } - } - private fun simple_3_ref(x: S3) { - { - let test::S3{ x: _, y: _ } = x; - { - let test::S3{ x: _x, y: _ } = x; - { - let test::S3{ x: _, y: _y } = x; - Tuple() - } - } - } - } - private fun simple_4(x: E1): u8 { - match (x) { - test::E1::A{ 0: x, 1: _ } => { - x - } - test::E1::B{ 0: x } => { - x - } - test::E1::C{ x, y: _ } => { - x - } - } - - } - private fun simple_4_ref(x: &E1): &u8 { - match (x) { - test::E1::A{ 0: x, 1: _ } => { - x - } - test::E1::B{ 0: x } => { - x - } - } - - } - private fun simple_5(x: E1): u8 { - match (x) { - test::E1::A{ 0: _, 1: y } => { - if y { - 1 - } else { - 0 - } - } - test::E1::B{ 0: x } => { - x - } - test::E1::C{ x: _, y: test::S1{ 0: x } } => { - x - } - } - - } - private fun simple_6(x: &S7) { - { - let test::S7{ 0: _w, 1: _, 2: _, 3: _z } = x; - { - let test::S7{ 0: _w, 1: _x, 2: _y, 3: _z } = x; - Tuple() - } - } - } - private fun test_lambda_param(): bool { - test::lambda_param(|test::S2{ 0: x, 1: _ }| x) - } -} // end 0x42::test - - -// -- Model dump after env processor check recursive struct definition: -module 0x42::test { - enum E1 { - A { - 0: u8, - 1: bool, - } - B { - 0: u8, - } - C { - x: u8, - y: S1, - } - } - struct S0 { - dummy_field: bool, - } - struct S1 { - 0: u8, - } - struct S2 { - 0: bool, - 1: S0, - } - struct S3 { - x: bool, - y: u8, - } - struct S4 { - x: T, - y: S3, - } - struct S5 { - 0: T, - 1: U, - } - struct S6 { - x: T, - y: U, - } - struct S7 { - 0: u8, - 1: u16, - 2: u32, - 3: u64, - } - private fun lambda_param(f: |S2|bool): bool { - { - let x: S2 = pack test::S2(true, pack test::S0(false)); - (f)(x) - } - } - private fun nested1(x: S4) { - { - let test::S4{ x: _x, y: _ } = x; - { - let test::S4{ x: _, y: _y } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _x, y: _ } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _y } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - Tuple() - } - } - } - } - } - } - } - } - private fun nested1_ref(x: &S4) { - { - let test::S4{ x: _x, y: _ } = x; - { - let test::S4{ x: _, y: _y } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _x, y: _ } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _y } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - Tuple() - } - } - } - } - } - } - } - } - private fun nested2(x: S5) { - { - let test::S5{ 0: _, 1: test::S1{ 0: _ } } = x; - Tuple() - } - } - private fun nested2_ref(x: &S5) { - { - let test::S5{ 0: _, 1: test::S1{ 0: _ } } = x; - Tuple() - } - } - private fun nested3(x: S5>) { - { - let test::S5>{ 0: _, 1: test::S4{ x: _, y: _ } } = x; - Tuple() - } - } - private fun nested3_ref(x: &S5>) { - { - let test::S5>{ 0: _, 1: test::S4{ x: _, y: _ } } = x; - Tuple() - } - } - private fun nested4(x: S4) { - { - let test::S4{ x: test::S1{ 0: _ }, y: _ } = x; - Tuple() - } - } - private fun nested4_ref(x: &S4) { - { - let test::S4{ x: test::S1{ 0: _ }, y: _ } = x; - Tuple() - } - } - private fun simple_0(x: S0) { - { - let test::S0{ dummy_field: _ } = x; - Tuple() - } - } - private fun simple_0_ref(x: &S0) { - { - let test::S0{ dummy_field: _ } = x; - Tuple() - } - } - private fun simple_1(x: S1) { - { - let test::S1{ 0: _ } = x; - Tuple() - } - } - private fun simple_1_ref(x: &mut S1) { - { - let test::S1{ 0: _ } = x; - Tuple() - } - } - private fun simple_2(x: S2) { - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _ } = x; - { - let test::S2{ 0: _, 1: _x } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - Tuple() - } - } - } - } - } - } - } - } - } - private fun simple_2_ref(x: &S2) { - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _ } = x; - { - let test::S2{ 0: _, 1: _x } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - Tuple() - } - } - } - } - } - } - } - } - } - private fun simple_3(x: S3) { - { - let test::S3{ x: _, y: _ } = x; - { - let test::S3{ x: _x, y: _ } = x; - { - let test::S3{ x: _, y: _y } = x; - Tuple() - } - } - } - } - private fun simple_3_ref(x: S3) { - { - let test::S3{ x: _, y: _ } = x; - { - let test::S3{ x: _x, y: _ } = x; - { - let test::S3{ x: _, y: _y } = x; - Tuple() - } - } - } - } - private fun simple_4(x: E1): u8 { - match (x) { - test::E1::A{ 0: x, 1: _ } => { - x - } - test::E1::B{ 0: x } => { - x - } - test::E1::C{ x, y: _ } => { - x - } - } - - } - private fun simple_4_ref(x: &E1): &u8 { - match (x) { - test::E1::A{ 0: x, 1: _ } => { - x - } - test::E1::B{ 0: x } => { - x - } - } - - } - private fun simple_5(x: E1): u8 { - match (x) { - test::E1::A{ 0: _, 1: y } => { - if y { - 1 - } else { - 0 - } - } - test::E1::B{ 0: x } => { - x - } - test::E1::C{ x: _, y: test::S1{ 0: x } } => { - x - } - } - - } - private fun simple_6(x: &S7) { - { - let test::S7{ 0: _w, 1: _, 2: _, 3: _z } = x; - { - let test::S7{ 0: _w, 1: _x, 2: _y, 3: _z } = x; - Tuple() - } - } - } - private fun test_lambda_param(): bool { - test::lambda_param(|test::S2{ 0: x, 1: _ }| x) - } -} // end 0x42::test - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x42::test { - enum E1 { - A { - 0: u8, - 1: bool, - } - B { - 0: u8, - } - C { - x: u8, - y: S1, - } - } - struct S0 { - dummy_field: bool, - } - struct S1 { - 0: u8, - } - struct S2 { - 0: bool, - 1: S0, - } - struct S3 { - x: bool, - y: u8, - } - struct S4 { - x: T, - y: S3, - } - struct S5 { - 0: T, - 1: U, - } - struct S6 { - x: T, - y: U, - } - struct S7 { - 0: u8, - 1: u16, - 2: u32, - 3: u64, - } - private fun lambda_param(f: |S2|bool): bool { - { - let x: S2 = pack test::S2(true, pack test::S0(false)); - (f)(x) - } - } - private fun nested1(x: S4) { - { - let test::S4{ x: _x, y: _ } = x; - { - let test::S4{ x: _, y: _y } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _x, y: _ } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _y } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - Tuple() - } - } - } - } - } - } - } - } - private fun nested1_ref(x: &S4) { - { - let test::S4{ x: _x, y: _ } = x; - { - let test::S4{ x: _, y: _y } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _x, y: _ } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _y } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - Tuple() - } - } - } - } - } - } - } - } - private fun nested2(x: S5) { - { - let test::S5{ 0: _, 1: test::S1{ 0: _ } } = x; - Tuple() - } - } - private fun nested2_ref(x: &S5) { - { - let test::S5{ 0: _, 1: test::S1{ 0: _ } } = x; - Tuple() - } - } - private fun nested3(x: S5>) { - { - let test::S5>{ 0: _, 1: test::S4{ x: _, y: _ } } = x; - Tuple() - } - } - private fun nested3_ref(x: &S5>) { - { - let test::S5>{ 0: _, 1: test::S4{ x: _, y: _ } } = x; - Tuple() - } - } - private fun nested4(x: S4) { - { - let test::S4{ x: test::S1{ 0: _ }, y: _ } = x; - Tuple() - } - } - private fun nested4_ref(x: &S4) { - { - let test::S4{ x: test::S1{ 0: _ }, y: _ } = x; - Tuple() - } - } - private fun simple_0(x: S0) { - { - let test::S0{ dummy_field: _ } = x; - Tuple() - } - } - private fun simple_0_ref(x: &S0) { - { - let test::S0{ dummy_field: _ } = x; - Tuple() - } - } - private fun simple_1(x: S1) { - { - let test::S1{ 0: _ } = x; - Tuple() - } - } - private fun simple_1_ref(x: &mut S1) { - { - let test::S1{ 0: _ } = x; - Tuple() - } - } - private fun simple_2(x: S2) { - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _ } = x; - { - let test::S2{ 0: _, 1: _x } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - Tuple() - } - } - } - } - } - } - } - } - } - private fun simple_2_ref(x: &S2) { - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _ } = x; - { - let test::S2{ 0: _, 1: _x } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - Tuple() - } - } - } - } - } - } - } - } - } - private fun simple_3(x: S3) { - { - let test::S3{ x: _, y: _ } = x; - { - let test::S3{ x: _x, y: _ } = x; - { - let test::S3{ x: _, y: _y } = x; - Tuple() - } - } - } - } - private fun simple_3_ref(x: S3) { - { - let test::S3{ x: _, y: _ } = x; - { - let test::S3{ x: _x, y: _ } = x; - { - let test::S3{ x: _, y: _y } = x; - Tuple() - } - } - } - } - private fun simple_4(x: E1): u8 { - match (x) { - test::E1::A{ 0: x, 1: _ } => { - x - } - test::E1::B{ 0: x } => { - x - } - test::E1::C{ x, y: _ } => { - x - } - } - - } - private fun simple_4_ref(x: &E1): &u8 { - match (x) { - test::E1::A{ 0: x, 1: _ } => { - x - } - test::E1::B{ 0: x } => { - x - } - } - - } - private fun simple_5(x: E1): u8 { - match (x) { - test::E1::A{ 0: _, 1: y } => { - if y { - 1 - } else { - 0 - } - } - test::E1::B{ 0: x } => { - x - } - test::E1::C{ x: _, y: test::S1{ 0: x } } => { - x - } - } - - } - private fun simple_6(x: &S7) { - { - let test::S7{ 0: _w, 1: _, 2: _, 3: _z } = x; - { - let test::S7{ 0: _w, 1: _x, 2: _y, 3: _z } = x; - Tuple() - } - } - } - private fun test_lambda_param(): bool { - test::lambda_param(|test::S2{ 0: x, 1: _ }| x) - } -} // end 0x42::test - - -// -- Model dump after env processor unused struct params check: -module 0x42::test { - enum E1 { - A { - 0: u8, - 1: bool, - } - B { - 0: u8, - } - C { - x: u8, - y: S1, - } - } - struct S0 { - dummy_field: bool, - } - struct S1 { - 0: u8, - } - struct S2 { - 0: bool, - 1: S0, - } - struct S3 { - x: bool, - y: u8, - } - struct S4 { - x: T, - y: S3, - } - struct S5 { - 0: T, - 1: U, - } - struct S6 { - x: T, - y: U, - } - struct S7 { - 0: u8, - 1: u16, - 2: u32, - 3: u64, - } - private fun lambda_param(f: |S2|bool): bool { - { - let x: S2 = pack test::S2(true, pack test::S0(false)); - (f)(x) - } - } - private fun nested1(x: S4) { - { - let test::S4{ x: _x, y: _ } = x; - { - let test::S4{ x: _, y: _y } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _x, y: _ } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _y } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - Tuple() - } - } - } - } - } - } - } - } - private fun nested1_ref(x: &S4) { - { - let test::S4{ x: _x, y: _ } = x; - { - let test::S4{ x: _, y: _y } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _x, y: _ } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _y } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - Tuple() - } - } - } - } - } - } - } - } - private fun nested2(x: S5) { - { - let test::S5{ 0: _, 1: test::S1{ 0: _ } } = x; - Tuple() - } - } - private fun nested2_ref(x: &S5) { - { - let test::S5{ 0: _, 1: test::S1{ 0: _ } } = x; - Tuple() - } - } - private fun nested3(x: S5>) { - { - let test::S5>{ 0: _, 1: test::S4{ x: _, y: _ } } = x; - Tuple() - } - } - private fun nested3_ref(x: &S5>) { - { - let test::S5>{ 0: _, 1: test::S4{ x: _, y: _ } } = x; - Tuple() - } - } - private fun nested4(x: S4) { - { - let test::S4{ x: test::S1{ 0: _ }, y: _ } = x; - Tuple() - } - } - private fun nested4_ref(x: &S4) { - { - let test::S4{ x: test::S1{ 0: _ }, y: _ } = x; - Tuple() - } - } - private fun simple_0(x: S0) { - { - let test::S0{ dummy_field: _ } = x; - Tuple() - } - } - private fun simple_0_ref(x: &S0) { - { - let test::S0{ dummy_field: _ } = x; - Tuple() - } - } - private fun simple_1(x: S1) { - { - let test::S1{ 0: _ } = x; - Tuple() - } - } - private fun simple_1_ref(x: &mut S1) { - { - let test::S1{ 0: _ } = x; - Tuple() - } - } - private fun simple_2(x: S2) { - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _ } = x; - { - let test::S2{ 0: _, 1: _x } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - Tuple() - } - } - } - } - } - } - } - } - } - private fun simple_2_ref(x: &S2) { - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _ } = x; - { - let test::S2{ 0: _, 1: _x } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - Tuple() - } - } - } - } - } - } - } - } - } - private fun simple_3(x: S3) { - { - let test::S3{ x: _, y: _ } = x; - { - let test::S3{ x: _x, y: _ } = x; - { - let test::S3{ x: _, y: _y } = x; - Tuple() - } - } - } - } - private fun simple_3_ref(x: S3) { - { - let test::S3{ x: _, y: _ } = x; - { - let test::S3{ x: _x, y: _ } = x; - { - let test::S3{ x: _, y: _y } = x; - Tuple() - } - } - } - } - private fun simple_4(x: E1): u8 { - match (x) { - test::E1::A{ 0: x, 1: _ } => { - x - } - test::E1::B{ 0: x } => { - x - } - test::E1::C{ x, y: _ } => { - x - } - } - - } - private fun simple_4_ref(x: &E1): &u8 { - match (x) { - test::E1::A{ 0: x, 1: _ } => { - x - } - test::E1::B{ 0: x } => { - x - } - } - - } - private fun simple_5(x: E1): u8 { - match (x) { - test::E1::A{ 0: _, 1: y } => { - if y { - 1 - } else { - 0 - } - } - test::E1::B{ 0: x } => { - x - } - test::E1::C{ x: _, y: test::S1{ 0: x } } => { - x - } - } - - } - private fun simple_6(x: &S7) { - { - let test::S7{ 0: _w, 1: _, 2: _, 3: _z } = x; - { - let test::S7{ 0: _w, 1: _x, 2: _y, 3: _z } = x; - Tuple() - } - } - } - private fun test_lambda_param(): bool { - test::lambda_param(|test::S2{ 0: x, 1: _ }| x) - } -} // end 0x42::test - - -// -- Model dump after env processor access and use check before inlining: -module 0x42::test { - enum E1 { - A { - 0: u8, - 1: bool, - } - B { - 0: u8, - } - C { - x: u8, - y: S1, - } - } - struct S0 { - dummy_field: bool, - } - struct S1 { - 0: u8, - } - struct S2 { - 0: bool, - 1: S0, - } - struct S3 { - x: bool, - y: u8, - } - struct S4 { - x: T, - y: S3, - } - struct S5 { - 0: T, - 1: U, - } - struct S6 { - x: T, - y: U, - } - struct S7 { - 0: u8, - 1: u16, - 2: u32, - 3: u64, - } - private fun lambda_param(f: |S2|bool): bool { - { - let x: S2 = pack test::S2(true, pack test::S0(false)); - (f)(x) - } - } - private fun nested1(x: S4) { - { - let test::S4{ x: _x, y: _ } = x; - { - let test::S4{ x: _, y: _y } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _x, y: _ } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _y } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - Tuple() - } - } - } - } - } - } - } - } - private fun nested1_ref(x: &S4) { - { - let test::S4{ x: _x, y: _ } = x; - { - let test::S4{ x: _, y: _y } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _x, y: _ } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _y } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - Tuple() - } - } - } - } - } - } - } - } - private fun nested2(x: S5) { - { - let test::S5{ 0: _, 1: test::S1{ 0: _ } } = x; - Tuple() - } - } - private fun nested2_ref(x: &S5) { - { - let test::S5{ 0: _, 1: test::S1{ 0: _ } } = x; - Tuple() - } - } - private fun nested3(x: S5>) { - { - let test::S5>{ 0: _, 1: test::S4{ x: _, y: _ } } = x; - Tuple() - } - } - private fun nested3_ref(x: &S5>) { - { - let test::S5>{ 0: _, 1: test::S4{ x: _, y: _ } } = x; - Tuple() - } - } - private fun nested4(x: S4) { - { - let test::S4{ x: test::S1{ 0: _ }, y: _ } = x; - Tuple() - } - } - private fun nested4_ref(x: &S4) { - { - let test::S4{ x: test::S1{ 0: _ }, y: _ } = x; - Tuple() - } - } - private fun simple_0(x: S0) { - { - let test::S0{ dummy_field: _ } = x; - Tuple() - } - } - private fun simple_0_ref(x: &S0) { - { - let test::S0{ dummy_field: _ } = x; - Tuple() - } - } - private fun simple_1(x: S1) { - { - let test::S1{ 0: _ } = x; - Tuple() - } - } - private fun simple_1_ref(x: &mut S1) { - { - let test::S1{ 0: _ } = x; - Tuple() - } - } - private fun simple_2(x: S2) { - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _ } = x; - { - let test::S2{ 0: _, 1: _x } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - Tuple() - } - } - } - } - } - } - } - } - } - private fun simple_2_ref(x: &S2) { - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _ } = x; - { - let test::S2{ 0: _, 1: _x } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - Tuple() - } - } - } - } - } - } - } - } - } - private fun simple_3(x: S3) { - { - let test::S3{ x: _, y: _ } = x; - { - let test::S3{ x: _x, y: _ } = x; - { - let test::S3{ x: _, y: _y } = x; - Tuple() - } - } - } - } - private fun simple_3_ref(x: S3) { - { - let test::S3{ x: _, y: _ } = x; - { - let test::S3{ x: _x, y: _ } = x; - { - let test::S3{ x: _, y: _y } = x; - Tuple() - } - } - } - } - private fun simple_4(x: E1): u8 { - match (x) { - test::E1::A{ 0: x, 1: _ } => { - x - } - test::E1::B{ 0: x } => { - x - } - test::E1::C{ x, y: _ } => { - x - } - } - - } - private fun simple_4_ref(x: &E1): &u8 { - match (x) { - test::E1::A{ 0: x, 1: _ } => { - x - } - test::E1::B{ 0: x } => { - x - } - } - - } - private fun simple_5(x: E1): u8 { - match (x) { - test::E1::A{ 0: _, 1: y } => { - if y { - 1 - } else { - 0 - } - } - test::E1::B{ 0: x } => { - x - } - test::E1::C{ x: _, y: test::S1{ 0: x } } => { - x - } - } - - } - private fun simple_6(x: &S7) { - { - let test::S7{ 0: _w, 1: _, 2: _, 3: _z } = x; - { - let test::S7{ 0: _w, 1: _x, 2: _y, 3: _z } = x; - Tuple() - } - } - } - private fun test_lambda_param(): bool { - test::lambda_param(|test::S2{ 0: x, 1: _ }| x) - } -} // end 0x42::test - - -// -- Model dump after env processor inlining: -module 0x42::test { - enum E1 { - A { - 0: u8, - 1: bool, - } - B { - 0: u8, - } - C { - x: u8, - y: S1, - } - } - struct S0 { - dummy_field: bool, - } - struct S1 { - 0: u8, - } - struct S2 { - 0: bool, - 1: S0, - } - struct S3 { - x: bool, - y: u8, - } - struct S4 { - x: T, - y: S3, - } - struct S5 { - 0: T, - 1: U, - } - struct S6 { - x: T, - y: U, - } - struct S7 { - 0: u8, - 1: u16, - 2: u32, - 3: u64, - } - private fun lambda_param(f: |S2|bool): bool { - { - let x: S2 = pack test::S2(true, pack test::S0(false)); - (f)(x) - } - } - private fun nested1(x: S4) { - { - let test::S4{ x: _x, y: _ } = x; - { - let test::S4{ x: _, y: _y } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _x, y: _ } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _y } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - Tuple() - } - } - } - } - } - } - } - } - private fun nested1_ref(x: &S4) { - { - let test::S4{ x: _x, y: _ } = x; - { - let test::S4{ x: _, y: _y } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _x, y: _ } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _y } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - Tuple() - } - } - } - } - } - } - } - } - private fun nested2(x: S5) { - { - let test::S5{ 0: _, 1: test::S1{ 0: _ } } = x; - Tuple() - } - } - private fun nested2_ref(x: &S5) { - { - let test::S5{ 0: _, 1: test::S1{ 0: _ } } = x; - Tuple() - } - } - private fun nested3(x: S5>) { - { - let test::S5>{ 0: _, 1: test::S4{ x: _, y: _ } } = x; - Tuple() - } - } - private fun nested3_ref(x: &S5>) { - { - let test::S5>{ 0: _, 1: test::S4{ x: _, y: _ } } = x; - Tuple() - } - } - private fun nested4(x: S4) { - { - let test::S4{ x: test::S1{ 0: _ }, y: _ } = x; - Tuple() - } - } - private fun nested4_ref(x: &S4) { - { - let test::S4{ x: test::S1{ 0: _ }, y: _ } = x; - Tuple() - } - } - private fun simple_0(x: S0) { - { - let test::S0{ dummy_field: _ } = x; - Tuple() - } - } - private fun simple_0_ref(x: &S0) { - { - let test::S0{ dummy_field: _ } = x; - Tuple() - } - } - private fun simple_1(x: S1) { - { - let test::S1{ 0: _ } = x; - Tuple() - } - } - private fun simple_1_ref(x: &mut S1) { - { - let test::S1{ 0: _ } = x; - Tuple() - } - } - private fun simple_2(x: S2) { - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _ } = x; - { - let test::S2{ 0: _, 1: _x } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - Tuple() - } - } - } - } - } - } - } - } - } - private fun simple_2_ref(x: &S2) { - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _ } = x; - { - let test::S2{ 0: _, 1: _x } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - Tuple() - } - } - } - } - } - } - } - } - } - private fun simple_3(x: S3) { - { - let test::S3{ x: _, y: _ } = x; - { - let test::S3{ x: _x, y: _ } = x; - { - let test::S3{ x: _, y: _y } = x; - Tuple() - } - } - } - } - private fun simple_3_ref(x: S3) { - { - let test::S3{ x: _, y: _ } = x; - { - let test::S3{ x: _x, y: _ } = x; - { - let test::S3{ x: _, y: _y } = x; - Tuple() - } - } - } - } - private fun simple_4(x: E1): u8 { - match (x) { - test::E1::A{ 0: x, 1: _ } => { - x - } - test::E1::B{ 0: x } => { - x - } - test::E1::C{ x, y: _ } => { - x - } - } - - } - private fun simple_4_ref(x: &E1): &u8 { - match (x) { - test::E1::A{ 0: x, 1: _ } => { - x - } - test::E1::B{ 0: x } => { - x - } - } - - } - private fun simple_5(x: E1): u8 { - match (x) { - test::E1::A{ 0: _, 1: y } => { - if y { - 1 - } else { - 0 - } - } - test::E1::B{ 0: x } => { - x - } - test::E1::C{ x: _, y: test::S1{ 0: x } } => { - x - } - } - - } - private fun simple_6(x: &S7) { - { - let test::S7{ 0: _w, 1: _, 2: _, 3: _z } = x; - { - let test::S7{ 0: _w, 1: _x, 2: _y, 3: _z } = x; - Tuple() - } - } - } - private fun test_lambda_param(): bool { - test::lambda_param(|test::S2{ 0: x, 1: _ }| x) - } -} // end 0x42::test - - -// -- Model dump after env processor access and use check after inlining: -module 0x42::test { - enum E1 { - A { - 0: u8, - 1: bool, - } - B { - 0: u8, - } - C { - x: u8, - y: S1, - } - } - struct S0 { - dummy_field: bool, - } - struct S1 { - 0: u8, - } - struct S2 { - 0: bool, - 1: S0, - } - struct S3 { - x: bool, - y: u8, - } - struct S4 { - x: T, - y: S3, - } - struct S5 { - 0: T, - 1: U, - } - struct S6 { - x: T, - y: U, - } - struct S7 { - 0: u8, - 1: u16, - 2: u32, - 3: u64, - } - private fun lambda_param(f: |S2|bool): bool { - { - let x: S2 = pack test::S2(true, pack test::S0(false)); - (f)(x) - } - } - private fun nested1(x: S4) { - { - let test::S4{ x: _x, y: _ } = x; - { - let test::S4{ x: _, y: _y } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _x, y: _ } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _y } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - Tuple() - } - } - } - } - } - } - } - } - private fun nested1_ref(x: &S4) { - { - let test::S4{ x: _x, y: _ } = x; - { - let test::S4{ x: _, y: _y } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _x, y: _ } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _y } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - Tuple() - } - } - } - } - } - } - } - } - private fun nested2(x: S5) { - { - let test::S5{ 0: _, 1: test::S1{ 0: _ } } = x; - Tuple() - } - } - private fun nested2_ref(x: &S5) { - { - let test::S5{ 0: _, 1: test::S1{ 0: _ } } = x; - Tuple() - } - } - private fun nested3(x: S5>) { - { - let test::S5>{ 0: _, 1: test::S4{ x: _, y: _ } } = x; - Tuple() - } - } - private fun nested3_ref(x: &S5>) { - { - let test::S5>{ 0: _, 1: test::S4{ x: _, y: _ } } = x; - Tuple() - } - } - private fun nested4(x: S4) { - { - let test::S4{ x: test::S1{ 0: _ }, y: _ } = x; - Tuple() - } - } - private fun nested4_ref(x: &S4) { - { - let test::S4{ x: test::S1{ 0: _ }, y: _ } = x; - Tuple() - } - } - private fun simple_0(x: S0) { - { - let test::S0{ dummy_field: _ } = x; - Tuple() - } - } - private fun simple_0_ref(x: &S0) { - { - let test::S0{ dummy_field: _ } = x; - Tuple() - } - } - private fun simple_1(x: S1) { - { - let test::S1{ 0: _ } = x; - Tuple() - } - } - private fun simple_1_ref(x: &mut S1) { - { - let test::S1{ 0: _ } = x; - Tuple() - } - } - private fun simple_2(x: S2) { - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _ } = x; - { - let test::S2{ 0: _, 1: _x } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - Tuple() - } - } - } - } - } - } - } - } - } - private fun simple_2_ref(x: &S2) { - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _ } = x; - { - let test::S2{ 0: _, 1: _x } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - Tuple() - } - } - } - } - } - } - } - } - } - private fun simple_3(x: S3) { - { - let test::S3{ x: _, y: _ } = x; - { - let test::S3{ x: _x, y: _ } = x; - { - let test::S3{ x: _, y: _y } = x; - Tuple() - } - } - } - } - private fun simple_3_ref(x: S3) { - { - let test::S3{ x: _, y: _ } = x; - { - let test::S3{ x: _x, y: _ } = x; - { - let test::S3{ x: _, y: _y } = x; - Tuple() - } - } - } - } - private fun simple_4(x: E1): u8 { - match (x) { - test::E1::A{ 0: x, 1: _ } => { - x - } - test::E1::B{ 0: x } => { - x - } - test::E1::C{ x, y: _ } => { - x - } - } - - } - private fun simple_4_ref(x: &E1): &u8 { - match (x) { - test::E1::A{ 0: x, 1: _ } => { - x - } - test::E1::B{ 0: x } => { - x - } - } - - } - private fun simple_5(x: E1): u8 { - match (x) { - test::E1::A{ 0: _, 1: y } => { - if y { - 1 - } else { - 0 - } - } - test::E1::B{ 0: x } => { - x - } - test::E1::C{ x: _, y: test::S1{ 0: x } } => { - x - } - } - - } - private fun simple_6(x: &S7) { - { - let test::S7{ 0: _w, 1: _, 2: _, 3: _z } = x; - { - let test::S7{ 0: _w, 1: _x, 2: _y, 3: _z } = x; - Tuple() - } - } - } - private fun test_lambda_param(): bool { - test::lambda_param(|test::S2{ 0: x, 1: _ }| x) - } -} // end 0x42::test - - -// -- Model dump after env processor acquires check: -module 0x42::test { - enum E1 { - A { - 0: u8, - 1: bool, - } - B { - 0: u8, - } - C { - x: u8, - y: S1, - } - } - struct S0 { - dummy_field: bool, - } - struct S1 { - 0: u8, - } - struct S2 { - 0: bool, - 1: S0, - } - struct S3 { - x: bool, - y: u8, - } - struct S4 { - x: T, - y: S3, - } - struct S5 { - 0: T, - 1: U, - } - struct S6 { - x: T, - y: U, - } - struct S7 { - 0: u8, - 1: u16, - 2: u32, - 3: u64, - } - private fun lambda_param(f: |S2|bool): bool { - { - let x: S2 = pack test::S2(true, pack test::S0(false)); - (f)(x) - } - } - private fun nested1(x: S4) { - { - let test::S4{ x: _x, y: _ } = x; - { - let test::S4{ x: _, y: _y } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _x, y: _ } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _y } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - Tuple() - } - } - } - } - } - } - } - } - private fun nested1_ref(x: &S4) { - { - let test::S4{ x: _x, y: _ } = x; - { - let test::S4{ x: _, y: _y } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _x, y: _ } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _y } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - Tuple() - } - } - } - } - } - } - } - } - private fun nested2(x: S5) { - { - let test::S5{ 0: _, 1: test::S1{ 0: _ } } = x; - Tuple() - } - } - private fun nested2_ref(x: &S5) { - { - let test::S5{ 0: _, 1: test::S1{ 0: _ } } = x; - Tuple() - } - } - private fun nested3(x: S5>) { - { - let test::S5>{ 0: _, 1: test::S4{ x: _, y: _ } } = x; - Tuple() - } - } - private fun nested3_ref(x: &S5>) { - { - let test::S5>{ 0: _, 1: test::S4{ x: _, y: _ } } = x; - Tuple() - } - } - private fun nested4(x: S4) { - { - let test::S4{ x: test::S1{ 0: _ }, y: _ } = x; - Tuple() - } - } - private fun nested4_ref(x: &S4) { - { - let test::S4{ x: test::S1{ 0: _ }, y: _ } = x; - Tuple() - } - } - private fun simple_0(x: S0) { - { - let test::S0{ dummy_field: _ } = x; - Tuple() - } - } - private fun simple_0_ref(x: &S0) { - { - let test::S0{ dummy_field: _ } = x; - Tuple() - } - } - private fun simple_1(x: S1) { - { - let test::S1{ 0: _ } = x; - Tuple() - } - } - private fun simple_1_ref(x: &mut S1) { - { - let test::S1{ 0: _ } = x; - Tuple() - } - } - private fun simple_2(x: S2) { - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _ } = x; - { - let test::S2{ 0: _, 1: _x } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - Tuple() - } - } - } - } - } - } - } - } - } - private fun simple_2_ref(x: &S2) { - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _ } = x; - { - let test::S2{ 0: _, 1: _x } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - Tuple() - } - } - } - } - } - } - } - } - } - private fun simple_3(x: S3) { - { - let test::S3{ x: _, y: _ } = x; - { - let test::S3{ x: _x, y: _ } = x; - { - let test::S3{ x: _, y: _y } = x; - Tuple() - } - } - } - } - private fun simple_3_ref(x: S3) { - { - let test::S3{ x: _, y: _ } = x; - { - let test::S3{ x: _x, y: _ } = x; - { - let test::S3{ x: _, y: _y } = x; - Tuple() - } - } - } - } - private fun simple_4(x: E1): u8 { - match (x) { - test::E1::A{ 0: x, 1: _ } => { - x - } - test::E1::B{ 0: x } => { - x - } - test::E1::C{ x, y: _ } => { - x - } - } - - } - private fun simple_4_ref(x: &E1): &u8 { - match (x) { - test::E1::A{ 0: x, 1: _ } => { - x - } - test::E1::B{ 0: x } => { - x - } - } - - } - private fun simple_5(x: E1): u8 { - match (x) { - test::E1::A{ 0: _, 1: y } => { - if y { - 1 - } else { - 0 - } - } - test::E1::B{ 0: x } => { - x - } - test::E1::C{ x: _, y: test::S1{ 0: x } } => { - x - } - } - - } - private fun simple_6(x: &S7) { - { - let test::S7{ 0: _w, 1: _, 2: _, 3: _z } = x; - { - let test::S7{ 0: _w, 1: _x, 2: _y, 3: _z } = x; - Tuple() - } - } - } - private fun test_lambda_param(): bool { - test::lambda_param(|test::S2{ 0: x, 1: _ }| x) - } -} // end 0x42::test - - -// -- Model dump after env processor simplifier: -module 0x42::test { - enum E1 { - A { - 0: u8, - 1: bool, - } - B { - 0: u8, - } - C { - x: u8, - y: S1, - } - } - struct S0 { - dummy_field: bool, - } - struct S1 { - 0: u8, - } - struct S2 { - 0: bool, - 1: S0, - } - struct S3 { - x: bool, - y: u8, - } - struct S4 { - x: T, - y: S3, - } - struct S5 { - 0: T, - 1: U, - } - struct S6 { - x: T, - y: U, - } - struct S7 { - 0: u8, - 1: u16, - 2: u32, - 3: u64, - } - private fun lambda_param(f: |S2|bool): bool { - { - let x: S2 = pack test::S2(true, pack test::S0(false)); - (f)(x) - } - } - private fun nested1(x: S4) { - { - let test::S4{ x: _x, y: _ } = x; - { - let test::S4{ x: _, y: _y } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _x, y: _ } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _y } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - Tuple() - } - } - } - } - } - } - } - } - private fun nested1_ref(x: &S4) { - { - let test::S4{ x: _x, y: _ } = x; - { - let test::S4{ x: _, y: _y } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _x, y: _ } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _y } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - Tuple() - } - } - } - } - } - } - } - } - private fun nested2(x: S5) { - { - let test::S5{ 0: _, 1: test::S1{ 0: _ } } = x; - Tuple() - } - } - private fun nested2_ref(x: &S5) { - { - let test::S5{ 0: _, 1: test::S1{ 0: _ } } = x; - Tuple() - } - } - private fun nested3(x: S5>) { - { - let test::S5>{ 0: _, 1: test::S4{ x: _, y: _ } } = x; - Tuple() - } - } - private fun nested3_ref(x: &S5>) { - { - let test::S5>{ 0: _, 1: test::S4{ x: _, y: _ } } = x; - Tuple() - } - } - private fun nested4(x: S4) { - { - let test::S4{ x: test::S1{ 0: _ }, y: _ } = x; - Tuple() - } - } - private fun nested4_ref(x: &S4) { - { - let test::S4{ x: test::S1{ 0: _ }, y: _ } = x; - Tuple() - } - } - private fun simple_0(x: S0) { - { - let test::S0{ dummy_field: _ } = x; - Tuple() - } - } - private fun simple_0_ref(x: &S0) { - { - let test::S0{ dummy_field: _ } = x; - Tuple() - } - } - private fun simple_1(x: S1) { - { - let test::S1{ 0: _ } = x; - Tuple() - } - } - private fun simple_1_ref(x: &mut S1) { - { - let test::S1{ 0: _ } = x; - Tuple() - } - } - private fun simple_2(x: S2) { - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _ } = x; - { - let test::S2{ 0: _, 1: _x } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - Tuple() - } - } - } - } - } - } - } - } - } - private fun simple_2_ref(x: &S2) { - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _ } = x; - { - let test::S2{ 0: _, 1: _x } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - Tuple() - } - } - } - } - } - } - } - } - } - private fun simple_3(x: S3) { - { - let test::S3{ x: _, y: _ } = x; - { - let test::S3{ x: _x, y: _ } = x; - { - let test::S3{ x: _, y: _y } = x; - Tuple() - } - } - } - } - private fun simple_3_ref(x: S3) { - { - let test::S3{ x: _, y: _ } = x; - { - let test::S3{ x: _x, y: _ } = x; - { - let test::S3{ x: _, y: _y } = x; - Tuple() - } - } - } - } - private fun simple_4(x: E1): u8 { - match (x) { - test::E1::A{ 0: x, 1: _ } => { - x - } - test::E1::B{ 0: x } => { - x - } - test::E1::C{ x, y: _ } => { - x - } - } - - } - private fun simple_4_ref(x: &E1): &u8 { - match (x) { - test::E1::A{ 0: x, 1: _ } => { - x - } - test::E1::B{ 0: x } => { - x - } - } - - } - private fun simple_5(x: E1): u8 { - match (x) { - test::E1::A{ 0: _, 1: y } => { - if y { - 1 - } else { - 0 - } - } - test::E1::B{ 0: x } => { - x - } - test::E1::C{ x: _, y: test::S1{ 0: x } } => { - x - } - } - - } - private fun simple_6(x: &S7) { - { - let test::S7{ 0: _w, 1: _, 2: _, 3: _z } = x; - { - let test::S7{ 0: _w, 1: _x, 2: _y, 3: _z } = x; - Tuple() - } - } - } - private fun test_lambda_param(): bool { - test::lambda_param(|test::S2{ 0: x, 1: _ }| x) - } -} // end 0x42::test - - -// -- Model dump after env processor lambda-lifting: -module 0x42::test { - enum E1 { - A { - 0: u8, - 1: bool, - } - B { - 0: u8, - } - C { - x: u8, - y: S1, - } - } - struct S0 { - dummy_field: bool, - } - struct S1 { - 0: u8, - } - struct S2 { - 0: bool, - 1: S0, - } - struct S3 { - x: bool, - y: u8, - } - struct S4 { - x: T, - y: S3, - } - struct S5 { - 0: T, - 1: U, - } - struct S6 { - x: T, - y: U, - } - struct S7 { - 0: u8, - 1: u16, - 2: u32, - 3: u64, - } - private fun lambda_param(f: |S2|bool): bool { - { - let x: S2 = pack test::S2(true, pack test::S0(false)); - (f)(x) - } - } - private fun nested1(x: S4) { - { - let test::S4{ x: _x, y: _ } = x; - { - let test::S4{ x: _, y: _y } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _x, y: _ } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _y } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - Tuple() - } - } - } - } - } - } - } - } - private fun nested1_ref(x: &S4) { - { - let test::S4{ x: _x, y: _ } = x; - { - let test::S4{ x: _, y: _y } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _x, y: _ } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _y } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - Tuple() - } - } - } - } - } - } - } - } - private fun nested2(x: S5) { - { - let test::S5{ 0: _, 1: test::S1{ 0: _ } } = x; - Tuple() - } - } - private fun nested2_ref(x: &S5) { - { - let test::S5{ 0: _, 1: test::S1{ 0: _ } } = x; - Tuple() - } - } - private fun nested3(x: S5>) { - { - let test::S5>{ 0: _, 1: test::S4{ x: _, y: _ } } = x; - Tuple() - } - } - private fun nested3_ref(x: &S5>) { - { - let test::S5>{ 0: _, 1: test::S4{ x: _, y: _ } } = x; - Tuple() - } - } - private fun nested4(x: S4) { - { - let test::S4{ x: test::S1{ 0: _ }, y: _ } = x; - Tuple() - } - } - private fun nested4_ref(x: &S4) { - { - let test::S4{ x: test::S1{ 0: _ }, y: _ } = x; - Tuple() - } - } - private fun simple_0(x: S0) { - { - let test::S0{ dummy_field: _ } = x; - Tuple() - } - } - private fun simple_0_ref(x: &S0) { - { - let test::S0{ dummy_field: _ } = x; - Tuple() - } - } - private fun simple_1(x: S1) { - { - let test::S1{ 0: _ } = x; - Tuple() - } - } - private fun simple_1_ref(x: &mut S1) { - { - let test::S1{ 0: _ } = x; - Tuple() - } - } - private fun simple_2(x: S2) { - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _ } = x; - { - let test::S2{ 0: _, 1: _x } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - Tuple() - } - } - } - } - } - } - } - } - } - private fun simple_2_ref(x: &S2) { - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _ } = x; - { - let test::S2{ 0: _, 1: _x } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - Tuple() - } - } - } - } - } - } - } - } - } - private fun simple_3(x: S3) { - { - let test::S3{ x: _, y: _ } = x; - { - let test::S3{ x: _x, y: _ } = x; - { - let test::S3{ x: _, y: _y } = x; - Tuple() - } - } - } - } - private fun simple_3_ref(x: S3) { - { - let test::S3{ x: _, y: _ } = x; - { - let test::S3{ x: _x, y: _ } = x; - { - let test::S3{ x: _, y: _y } = x; - Tuple() - } - } - } - } - private fun simple_4(x: E1): u8 { - match (x) { - test::E1::A{ 0: x, 1: _ } => { - x - } - test::E1::B{ 0: x } => { - x - } - test::E1::C{ x, y: _ } => { - x - } - } - - } - private fun simple_4_ref(x: &E1): &u8 { - match (x) { - test::E1::A{ 0: x, 1: _ } => { - x - } - test::E1::B{ 0: x } => { - x - } - } - - } - private fun simple_5(x: E1): u8 { - match (x) { - test::E1::A{ 0: _, 1: y } => { - if y { - 1 - } else { - 0 - } - } - test::E1::B{ 0: x } => { - x - } - test::E1::C{ x: _, y: test::S1{ 0: x } } => { - x - } - } - - } - private fun simple_6(x: &S7) { - { - let test::S7{ 0: _w, 1: _, 2: _, 3: _z } = x; - { - let test::S7{ 0: _w, 1: _x, 2: _y, 3: _z } = x; - Tuple() - } - } - } - private fun test_lambda_param(): bool { - test::lambda_param(closure test::test_lambda_param$lambda$1()) - } - private fun test_lambda_param$lambda$1(param$0: S2): bool { - { - let test::S2{ 0: x, 1: _ } = param$0; - x - } - } -} // end 0x42::test - - -// -- Model dump after env processor specification checker: -module 0x42::test { - enum E1 { - A { - 0: u8, - 1: bool, - } - B { - 0: u8, - } - C { - x: u8, - y: S1, - } - } - struct S0 { - dummy_field: bool, - } - struct S1 { - 0: u8, - } - struct S2 { - 0: bool, - 1: S0, - } - struct S3 { - x: bool, - y: u8, - } - struct S4 { - x: T, - y: S3, - } - struct S5 { - 0: T, - 1: U, - } - struct S6 { - x: T, - y: U, - } - struct S7 { - 0: u8, - 1: u16, - 2: u32, - 3: u64, - } - private fun lambda_param(f: |S2|bool): bool { - { - let x: S2 = pack test::S2(true, pack test::S0(false)); - (f)(x) - } - } - private fun nested1(x: S4) { - { - let test::S4{ x: _x, y: _ } = x; - { - let test::S4{ x: _, y: _y } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _x, y: _ } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _y } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - Tuple() - } - } - } - } - } - } - } - } - private fun nested1_ref(x: &S4) { - { - let test::S4{ x: _x, y: _ } = x; - { - let test::S4{ x: _, y: _y } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _x, y: _ } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _y } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - Tuple() - } - } - } - } - } - } - } - } - private fun nested2(x: S5) { - { - let test::S5{ 0: _, 1: test::S1{ 0: _ } } = x; - Tuple() - } - } - private fun nested2_ref(x: &S5) { - { - let test::S5{ 0: _, 1: test::S1{ 0: _ } } = x; - Tuple() - } - } - private fun nested3(x: S5>) { - { - let test::S5>{ 0: _, 1: test::S4{ x: _, y: _ } } = x; - Tuple() - } - } - private fun nested3_ref(x: &S5>) { - { - let test::S5>{ 0: _, 1: test::S4{ x: _, y: _ } } = x; - Tuple() - } - } - private fun nested4(x: S4) { - { - let test::S4{ x: test::S1{ 0: _ }, y: _ } = x; - Tuple() - } - } - private fun nested4_ref(x: &S4) { - { - let test::S4{ x: test::S1{ 0: _ }, y: _ } = x; - Tuple() - } - } - private fun simple_0(x: S0) { - { - let test::S0{ dummy_field: _ } = x; - Tuple() - } - } - private fun simple_0_ref(x: &S0) { - { - let test::S0{ dummy_field: _ } = x; - Tuple() - } - } - private fun simple_1(x: S1) { - { - let test::S1{ 0: _ } = x; - Tuple() - } - } - private fun simple_1_ref(x: &mut S1) { - { - let test::S1{ 0: _ } = x; - Tuple() - } - } - private fun simple_2(x: S2) { - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _ } = x; - { - let test::S2{ 0: _, 1: _x } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - Tuple() - } - } - } - } - } - } - } - } - } - private fun simple_2_ref(x: &S2) { - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _ } = x; - { - let test::S2{ 0: _, 1: _x } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - Tuple() - } - } - } - } - } - } - } - } - } - private fun simple_3(x: S3) { - { - let test::S3{ x: _, y: _ } = x; - { - let test::S3{ x: _x, y: _ } = x; - { - let test::S3{ x: _, y: _y } = x; - Tuple() - } - } - } - } - private fun simple_3_ref(x: S3) { - { - let test::S3{ x: _, y: _ } = x; - { - let test::S3{ x: _x, y: _ } = x; - { - let test::S3{ x: _, y: _y } = x; - Tuple() - } - } - } - } - private fun simple_4(x: E1): u8 { - match (x) { - test::E1::A{ 0: x, 1: _ } => { - x - } - test::E1::B{ 0: x } => { - x - } - test::E1::C{ x, y: _ } => { - x - } - } - - } - private fun simple_4_ref(x: &E1): &u8 { - match (x) { - test::E1::A{ 0: x, 1: _ } => { - x - } - test::E1::B{ 0: x } => { - x - } - } - - } - private fun simple_5(x: E1): u8 { - match (x) { - test::E1::A{ 0: _, 1: y } => { - if y { - 1 - } else { - 0 - } - } - test::E1::B{ 0: x } => { - x - } - test::E1::C{ x: _, y: test::S1{ 0: x } } => { - x - } - } - - } - private fun simple_6(x: &S7) { - { - let test::S7{ 0: _w, 1: _, 2: _, 3: _z } = x; - { - let test::S7{ 0: _w, 1: _x, 2: _y, 3: _z } = x; - Tuple() - } - } - } - private fun test_lambda_param(): bool { - test::lambda_param(closure test::test_lambda_param$lambda$1()) - } - private fun test_lambda_param$lambda$1(param$0: S2): bool { - { - let test::S2{ 0: x, 1: _ } = param$0; - x - } - } -} // end 0x42::test - - -// -- Model dump after env processor specification rewriter: -module 0x42::test { - enum E1 { - A { - 0: u8, - 1: bool, - } - B { - 0: u8, - } - C { - x: u8, - y: S1, - } - } - struct S0 { - dummy_field: bool, - } - struct S1 { - 0: u8, - } - struct S2 { - 0: bool, - 1: S0, - } - struct S3 { - x: bool, - y: u8, - } - struct S4 { - x: T, - y: S3, - } - struct S5 { - 0: T, - 1: U, - } - struct S6 { - x: T, - y: U, - } - struct S7 { - 0: u8, - 1: u16, - 2: u32, - 3: u64, - } - private fun lambda_param(f: |S2|bool): bool { - { - let x: S2 = pack test::S2(true, pack test::S0(false)); - (f)(x) - } - } - private fun nested1(x: S4) { - { - let test::S4{ x: _x, y: _ } = x; - { - let test::S4{ x: _, y: _y } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _x, y: _ } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _y } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - Tuple() - } - } - } - } - } - } - } - } - private fun nested1_ref(x: &S4) { - { - let test::S4{ x: _x, y: _ } = x; - { - let test::S4{ x: _, y: _y } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _x, y: _ } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - { - let test::S4{ x: _, y: test::S3{ x: _, y: _y } } = x; - { - let test::S4{ x: _x2, y: test::S3{ x: _x1, y: _ } } = x; - Tuple() - } - } - } - } - } - } - } - } - private fun nested2(x: S5) { - { - let test::S5{ 0: _, 1: test::S1{ 0: _ } } = x; - Tuple() - } - } - private fun nested2_ref(x: &S5) { - { - let test::S5{ 0: _, 1: test::S1{ 0: _ } } = x; - Tuple() - } - } - private fun nested3(x: S5>) { - { - let test::S5>{ 0: _, 1: test::S4{ x: _, y: _ } } = x; - Tuple() - } - } - private fun nested3_ref(x: &S5>) { - { - let test::S5>{ 0: _, 1: test::S4{ x: _, y: _ } } = x; - Tuple() - } - } - private fun nested4(x: S4) { - { - let test::S4{ x: test::S1{ 0: _ }, y: _ } = x; - Tuple() - } - } - private fun nested4_ref(x: &S4) { - { - let test::S4{ x: test::S1{ 0: _ }, y: _ } = x; - Tuple() - } - } - private fun simple_0(x: S0) { - { - let test::S0{ dummy_field: _ } = x; - Tuple() - } - } - private fun simple_0_ref(x: &S0) { - { - let test::S0{ dummy_field: _ } = x; - Tuple() - } - } - private fun simple_1(x: S1) { - { - let test::S1{ 0: _ } = x; - Tuple() - } - } - private fun simple_1_ref(x: &mut S1) { - { - let test::S1{ 0: _ } = x; - Tuple() - } - } - private fun simple_2(x: S2) { - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _ } = x; - { - let test::S2{ 0: _, 1: _x } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - Tuple() - } - } - } - } - } - } - } - } - } - private fun simple_2_ref(x: &S2) { - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _ } = x; - { - let test::S2{ 0: _, 1: _x } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _, 1: _ } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - { - let test::S2{ 0: _x, 1: _y } = x; - Tuple() - } - } - } - } - } - } - } - } - } - private fun simple_3(x: S3) { - { - let test::S3{ x: _, y: _ } = x; - { - let test::S3{ x: _x, y: _ } = x; - { - let test::S3{ x: _, y: _y } = x; - Tuple() - } - } - } - } - private fun simple_3_ref(x: S3) { - { - let test::S3{ x: _, y: _ } = x; - { - let test::S3{ x: _x, y: _ } = x; - { - let test::S3{ x: _, y: _y } = x; - Tuple() - } - } - } - } - private fun simple_4(x: E1): u8 { - match (x) { - test::E1::A{ 0: x, 1: _ } => { - x - } - test::E1::B{ 0: x } => { - x - } - test::E1::C{ x, y: _ } => { - x - } - } - - } - private fun simple_4_ref(x: &E1): &u8 { - match (x) { - test::E1::A{ 0: x, 1: _ } => { - x - } - test::E1::B{ 0: x } => { - x - } - } - - } - private fun simple_5(x: E1): u8 { - match (x) { - test::E1::A{ 0: _, 1: y } => { - if y { - 1 - } else { - 0 - } - } - test::E1::B{ 0: x } => { - x - } - test::E1::C{ x: _, y: test::S1{ 0: x } } => { - x - } - } - - } - private fun simple_6(x: &S7) { - { - let test::S7{ 0: _w, 1: _, 2: _, 3: _z } = x; - { - let test::S7{ 0: _w, 1: _x, 2: _y, 3: _z } = x; - Tuple() - } - } - } - private fun test_lambda_param(): bool { - test::lambda_param(closure test::test_lambda_param$lambda$1()) - } - private fun test_lambda_param$lambda$1(param$0: S2): bool { - { - let test::S2{ 0: x, 1: _ } = param$0; - x - } - } -} // end 0x42::test - - Diagnostics: -error: match not exhaustive - ┌─ tests/lambda/inline-parity/dotdot_valid.move:142:16 - │ -142 │ match (x) { - │ ^ - │ - = missing `E1::C{..}` - -error: match not exhaustive - ┌─ tests/lambda/inline-parity/dotdot_valid.move:153:16 - │ -153 │ match (x) { - │ ^ - │ - = missing `E1::C{..}` - -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda/inline-parity/dotdot_valid.move:177:9 - │ -177 │ f(x) - │ ^ - -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/dotdot_valid.move:181:22 │ 181 │ lambda_param(|S2(x, ..)| x) diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/eq_inline.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/eq_inline.lambda.exp index 7fc8364520041..2d77507a43a0a 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/eq_inline.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/eq_inline.lambda.exp @@ -1,194 +1,3 @@ -// -- Model dump before env processor pipeline: -module 0x42::m { - private fun foo(f: |&u64|) { - Tuple() - } - private fun g() { - m::foo(|v: &u64| Eq(v, Borrow(Immutable)(1)); - Tuple()); - Tuple() - } -} // end 0x42::m - - -// -- Model dump after env processor unused checks: -module 0x42::m { - private fun foo(f: |&u64|) { - Tuple() - } - private fun g() { - m::foo(|v: &u64| Eq(v, Borrow(Immutable)(1)); - Tuple()); - Tuple() - } -} // end 0x42::m - - -// -- Model dump after env processor type parameter check: -module 0x42::m { - private fun foo(f: |&u64|) { - Tuple() - } - private fun g() { - m::foo(|v: &u64| Eq(v, Borrow(Immutable)(1)); - Tuple()); - Tuple() - } -} // end 0x42::m - - -// -- Model dump after env processor check recursive struct definition: -module 0x42::m { - private fun foo(f: |&u64|) { - Tuple() - } - private fun g() { - m::foo(|v: &u64| Eq(v, Borrow(Immutable)(1)); - Tuple()); - Tuple() - } -} // end 0x42::m - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x42::m { - private fun foo(f: |&u64|) { - Tuple() - } - private fun g() { - m::foo(|v: &u64| Eq(v, Borrow(Immutable)(1)); - Tuple()); - Tuple() - } -} // end 0x42::m - - -// -- Model dump after env processor unused struct params check: -module 0x42::m { - private fun foo(f: |&u64|) { - Tuple() - } - private fun g() { - m::foo(|v: &u64| Eq(v, Borrow(Immutable)(1)); - Tuple()); - Tuple() - } -} // end 0x42::m - - -// -- Model dump after env processor access and use check before inlining: -module 0x42::m { - private fun foo(f: |&u64|) { - Tuple() - } - private fun g() { - m::foo(|v: &u64| Eq(v, Borrow(Immutable)(1)); - Tuple()); - Tuple() - } -} // end 0x42::m - - -// -- Model dump after env processor inlining: -module 0x42::m { - private fun foo(f: |&u64|) { - Tuple() - } - private fun g() { - m::foo(|v: &u64| Eq(v, Borrow(Immutable)(1)); - Tuple()); - Tuple() - } -} // end 0x42::m - - -// -- Model dump after env processor access and use check after inlining: -module 0x42::m { - private fun foo(f: |&u64|) { - Tuple() - } - private fun g() { - m::foo(|v: &u64| Eq(v, Borrow(Immutable)(1)); - Tuple()); - Tuple() - } -} // end 0x42::m - - -// -- Model dump after env processor acquires check: -module 0x42::m { - private fun foo(f: |&u64|) { - Tuple() - } - private fun g() { - m::foo(|v: &u64| Eq(v, Borrow(Immutable)(1)); - Tuple()); - Tuple() - } -} // end 0x42::m - - -// -- Model dump after env processor simplifier: -module 0x42::m { - private fun foo(f: |&u64|) { - Tuple() - } - private fun g() { - m::foo(|v: &u64| Eq(v, Borrow(Immutable)(1)); - Tuple()); - Tuple() - } -} // end 0x42::m - - -// -- Model dump after env processor lambda-lifting: -module 0x42::m { - private fun foo(f: |&u64|) { - Tuple() - } - private fun g() { - m::foo(closure m::g$lambda$1()); - Tuple() - } - private fun g$lambda$1(v: &u64) { - Eq(v, Borrow(Immutable)(1)); - Tuple() - } -} // end 0x42::m - - -// -- Model dump after env processor specification checker: -module 0x42::m { - private fun foo(f: |&u64|) { - Tuple() - } - private fun g() { - m::foo(closure m::g$lambda$1()); - Tuple() - } - private fun g$lambda$1(v: &u64) { - Eq(v, Borrow(Immutable)(1)); - Tuple() - } -} // end 0x42::m - - -// -- Model dump after env processor specification rewriter: -module 0x42::m { - private fun foo(f: |&u64|) { - Tuple() - } - private fun g() { - m::foo(closure m::g$lambda$1()); - Tuple() - } - private fun g$lambda$1(v: &u64) { - Eq(v, Borrow(Immutable)(1)); - Tuple() - } -} // end 0x42::m - - Diagnostics: warning: Unused parameter `f`. Consider removing or prefixing with an underscore: `_f` @@ -197,9 +6,7 @@ warning: Unused parameter `f`. Consider removing or prefixing with an underscore 3 │ fun foo(f: |&u64|) { │ ^ - -Diagnostics: -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/eq_inline.move:7:13 │ 7 │ foo(|v| { diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/eval_ignored_param.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/eval_ignored_param.lambda.exp index 2bbc4c4bfd603..0f8ce62667495 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/eval_ignored_param.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/eval_ignored_param.lambda.exp @@ -1,503 +1,12 @@ -// -- Model dump before env processor pipeline: -module 0x42::Test { - private fun foo(f: |(u64, u64, u64)|u64,g: |(u64, u64, u64)|u64,x: u64,_: u64,y: u64,z: u64): u64 { - { - let r1: u64 = (f)(x: u64 = Add(x, 1); - x, y: u64 = Add(y, 1); - y, z: u64 = Add(z, 1); - z); - { - let r2: u64 = (g)(x: u64 = Add(x, 1); - x, y: u64 = Add(y, 1); - y, z: u64 = Add(z, 1); - z); - Add(Add(Add(Add(r1, r2), Mul(3, x)), Mul(5, y)), Mul(7, z)) - } - } - } - public fun test() { - { - let r: u64 = Test::foo(|(x: u64, _: u64, z: u64): (u64, u64, u64)| Mul(x, z), |(_: u64, y: u64, _: u64): (u64, u64, u64)| y, 1, 10, 100, 1000); - if Eq(r, 9637) { - Tuple() - } else { - Abort(r) - }; - Tuple() - } - } -} // end 0x42::Test - - -// -- Model dump after env processor unused checks: -module 0x42::Test { - private fun foo(f: |(u64, u64, u64)|u64,g: |(u64, u64, u64)|u64,x: u64,_: u64,y: u64,z: u64): u64 { - { - let r1: u64 = (f)(x: u64 = Add(x, 1); - x, y: u64 = Add(y, 1); - y, z: u64 = Add(z, 1); - z); - { - let r2: u64 = (g)(x: u64 = Add(x, 1); - x, y: u64 = Add(y, 1); - y, z: u64 = Add(z, 1); - z); - Add(Add(Add(Add(r1, r2), Mul(3, x)), Mul(5, y)), Mul(7, z)) - } - } - } - public fun test() { - { - let r: u64 = Test::foo(|(x: u64, _: u64, z: u64): (u64, u64, u64)| Mul(x, z), |(_: u64, y: u64, _: u64): (u64, u64, u64)| y, 1, 10, 100, 1000); - if Eq(r, 9637) { - Tuple() - } else { - Abort(r) - }; - Tuple() - } - } -} // end 0x42::Test - - -// -- Model dump after env processor type parameter check: -module 0x42::Test { - private fun foo(f: |(u64, u64, u64)|u64,g: |(u64, u64, u64)|u64,x: u64,_: u64,y: u64,z: u64): u64 { - { - let r1: u64 = (f)(x: u64 = Add(x, 1); - x, y: u64 = Add(y, 1); - y, z: u64 = Add(z, 1); - z); - { - let r2: u64 = (g)(x: u64 = Add(x, 1); - x, y: u64 = Add(y, 1); - y, z: u64 = Add(z, 1); - z); - Add(Add(Add(Add(r1, r2), Mul(3, x)), Mul(5, y)), Mul(7, z)) - } - } - } - public fun test() { - { - let r: u64 = Test::foo(|(x: u64, _: u64, z: u64): (u64, u64, u64)| Mul(x, z), |(_: u64, y: u64, _: u64): (u64, u64, u64)| y, 1, 10, 100, 1000); - if Eq(r, 9637) { - Tuple() - } else { - Abort(r) - }; - Tuple() - } - } -} // end 0x42::Test - - -// -- Model dump after env processor check recursive struct definition: -module 0x42::Test { - private fun foo(f: |(u64, u64, u64)|u64,g: |(u64, u64, u64)|u64,x: u64,_: u64,y: u64,z: u64): u64 { - { - let r1: u64 = (f)(x: u64 = Add(x, 1); - x, y: u64 = Add(y, 1); - y, z: u64 = Add(z, 1); - z); - { - let r2: u64 = (g)(x: u64 = Add(x, 1); - x, y: u64 = Add(y, 1); - y, z: u64 = Add(z, 1); - z); - Add(Add(Add(Add(r1, r2), Mul(3, x)), Mul(5, y)), Mul(7, z)) - } - } - } - public fun test() { - { - let r: u64 = Test::foo(|(x: u64, _: u64, z: u64): (u64, u64, u64)| Mul(x, z), |(_: u64, y: u64, _: u64): (u64, u64, u64)| y, 1, 10, 100, 1000); - if Eq(r, 9637) { - Tuple() - } else { - Abort(r) - }; - Tuple() - } - } -} // end 0x42::Test - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x42::Test { - private fun foo(f: |(u64, u64, u64)|u64,g: |(u64, u64, u64)|u64,x: u64,_: u64,y: u64,z: u64): u64 { - { - let r1: u64 = (f)(x: u64 = Add(x, 1); - x, y: u64 = Add(y, 1); - y, z: u64 = Add(z, 1); - z); - { - let r2: u64 = (g)(x: u64 = Add(x, 1); - x, y: u64 = Add(y, 1); - y, z: u64 = Add(z, 1); - z); - Add(Add(Add(Add(r1, r2), Mul(3, x)), Mul(5, y)), Mul(7, z)) - } - } - } - public fun test() { - { - let r: u64 = Test::foo(|(x: u64, _: u64, z: u64): (u64, u64, u64)| Mul(x, z), |(_: u64, y: u64, _: u64): (u64, u64, u64)| y, 1, 10, 100, 1000); - if Eq(r, 9637) { - Tuple() - } else { - Abort(r) - }; - Tuple() - } - } -} // end 0x42::Test - - -// -- Model dump after env processor unused struct params check: -module 0x42::Test { - private fun foo(f: |(u64, u64, u64)|u64,g: |(u64, u64, u64)|u64,x: u64,_: u64,y: u64,z: u64): u64 { - { - let r1: u64 = (f)(x: u64 = Add(x, 1); - x, y: u64 = Add(y, 1); - y, z: u64 = Add(z, 1); - z); - { - let r2: u64 = (g)(x: u64 = Add(x, 1); - x, y: u64 = Add(y, 1); - y, z: u64 = Add(z, 1); - z); - Add(Add(Add(Add(r1, r2), Mul(3, x)), Mul(5, y)), Mul(7, z)) - } - } - } - public fun test() { - { - let r: u64 = Test::foo(|(x: u64, _: u64, z: u64): (u64, u64, u64)| Mul(x, z), |(_: u64, y: u64, _: u64): (u64, u64, u64)| y, 1, 10, 100, 1000); - if Eq(r, 9637) { - Tuple() - } else { - Abort(r) - }; - Tuple() - } - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check before inlining: -module 0x42::Test { - private fun foo(f: |(u64, u64, u64)|u64,g: |(u64, u64, u64)|u64,x: u64,_: u64,y: u64,z: u64): u64 { - { - let r1: u64 = (f)(x: u64 = Add(x, 1); - x, y: u64 = Add(y, 1); - y, z: u64 = Add(z, 1); - z); - { - let r2: u64 = (g)(x: u64 = Add(x, 1); - x, y: u64 = Add(y, 1); - y, z: u64 = Add(z, 1); - z); - Add(Add(Add(Add(r1, r2), Mul(3, x)), Mul(5, y)), Mul(7, z)) - } - } - } - public fun test() { - { - let r: u64 = Test::foo(|(x: u64, _: u64, z: u64): (u64, u64, u64)| Mul(x, z), |(_: u64, y: u64, _: u64): (u64, u64, u64)| y, 1, 10, 100, 1000); - if Eq(r, 9637) { - Tuple() - } else { - Abort(r) - }; - Tuple() - } - } -} // end 0x42::Test - - -// -- Model dump after env processor inlining: -module 0x42::Test { - private fun foo(f: |(u64, u64, u64)|u64,g: |(u64, u64, u64)|u64,x: u64,_: u64,y: u64,z: u64): u64 { - { - let r1: u64 = (f)(x: u64 = Add(x, 1); - x, y: u64 = Add(y, 1); - y, z: u64 = Add(z, 1); - z); - { - let r2: u64 = (g)(x: u64 = Add(x, 1); - x, y: u64 = Add(y, 1); - y, z: u64 = Add(z, 1); - z); - Add(Add(Add(Add(r1, r2), Mul(3, x)), Mul(5, y)), Mul(7, z)) - } - } - } - public fun test() { - { - let r: u64 = Test::foo(|(x: u64, _: u64, z: u64): (u64, u64, u64)| Mul(x, z), |(_: u64, y: u64, _: u64): (u64, u64, u64)| y, 1, 10, 100, 1000); - if Eq(r, 9637) { - Tuple() - } else { - Abort(r) - }; - Tuple() - } - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check after inlining: -module 0x42::Test { - private fun foo(f: |(u64, u64, u64)|u64,g: |(u64, u64, u64)|u64,x: u64,_: u64,y: u64,z: u64): u64 { - { - let r1: u64 = (f)(x: u64 = Add(x, 1); - x, y: u64 = Add(y, 1); - y, z: u64 = Add(z, 1); - z); - { - let r2: u64 = (g)(x: u64 = Add(x, 1); - x, y: u64 = Add(y, 1); - y, z: u64 = Add(z, 1); - z); - Add(Add(Add(Add(r1, r2), Mul(3, x)), Mul(5, y)), Mul(7, z)) - } - } - } - public fun test() { - { - let r: u64 = Test::foo(|(x: u64, _: u64, z: u64): (u64, u64, u64)| Mul(x, z), |(_: u64, y: u64, _: u64): (u64, u64, u64)| y, 1, 10, 100, 1000); - if Eq(r, 9637) { - Tuple() - } else { - Abort(r) - }; - Tuple() - } - } -} // end 0x42::Test - - -// -- Model dump after env processor acquires check: -module 0x42::Test { - private fun foo(f: |(u64, u64, u64)|u64,g: |(u64, u64, u64)|u64,x: u64,_: u64,y: u64,z: u64): u64 { - { - let r1: u64 = (f)(x: u64 = Add(x, 1); - x, y: u64 = Add(y, 1); - y, z: u64 = Add(z, 1); - z); - { - let r2: u64 = (g)(x: u64 = Add(x, 1); - x, y: u64 = Add(y, 1); - y, z: u64 = Add(z, 1); - z); - Add(Add(Add(Add(r1, r2), Mul(3, x)), Mul(5, y)), Mul(7, z)) - } - } - } - public fun test() { - { - let r: u64 = Test::foo(|(x: u64, _: u64, z: u64): (u64, u64, u64)| Mul(x, z), |(_: u64, y: u64, _: u64): (u64, u64, u64)| y, 1, 10, 100, 1000); - if Eq(r, 9637) { - Tuple() - } else { - Abort(r) - }; - Tuple() - } - } -} // end 0x42::Test - - -// -- Model dump after env processor simplifier: -module 0x42::Test { - private fun foo(f: |(u64, u64, u64)|u64,g: |(u64, u64, u64)|u64,x: u64,_: u64,y: u64,z: u64): u64 { - { - let r1: u64 = (f)(x: u64 = Add(x, 1); - x, y: u64 = Add(y, 1); - y, z: u64 = Add(z, 1); - z); - { - let r2: u64 = (g)(x: u64 = Add(x, 1); - x, y: u64 = Add(y, 1); - y, z: u64 = Add(z, 1); - z); - Add(Add(Add(Add(r1, r2), Mul(3, x)), Mul(5, y)), Mul(7, z)) - } - } - } - public fun test() { - { - let r: u64 = Test::foo(|(x: u64, _: u64, z: u64): (u64, u64, u64)| Mul(x, z), |(_: u64, y: u64, _: u64): (u64, u64, u64)| y, 1, 10, 100, 1000); - if Eq(r, 9637) { - Tuple() - } else { - Abort(r) - }; - Tuple() - } - } -} // end 0x42::Test - - -// -- Model dump after env processor lambda-lifting: -module 0x42::Test { - private fun foo(f: |(u64, u64, u64)|u64,g: |(u64, u64, u64)|u64,x: u64,_: u64,y: u64,z: u64): u64 { - { - let r1: u64 = (f)(x: u64 = Add(x, 1); - x, y: u64 = Add(y, 1); - y, z: u64 = Add(z, 1); - z); - { - let r2: u64 = (g)(x: u64 = Add(x, 1); - x, y: u64 = Add(y, 1); - y, z: u64 = Add(z, 1); - z); - Add(Add(Add(Add(r1, r2), Mul(3, x)), Mul(5, y)), Mul(7, z)) - } - } - } - public fun test() { - { - let r: u64 = Test::foo(closure Test::test$lambda$1(), closure Test::test$lambda$2(), 1, 10, 100, 1000); - if Eq(r, 9637) { - Tuple() - } else { - Abort(r) - }; - Tuple() - } - } - private fun test$lambda$1(x: u64,param$1: u64,z: u64): u64 { - { - let _: u64 = param$1; - Mul(x, z) - } - } - private fun test$lambda$2(param$0: u64,y: u64,param$2: u64): u64 { - { - let _: u64 = param$2; - { - let _: u64 = param$0; - y - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor specification checker: -module 0x42::Test { - private fun foo(f: |(u64, u64, u64)|u64,g: |(u64, u64, u64)|u64,x: u64,_: u64,y: u64,z: u64): u64 { - { - let r1: u64 = (f)(x: u64 = Add(x, 1); - x, y: u64 = Add(y, 1); - y, z: u64 = Add(z, 1); - z); - { - let r2: u64 = (g)(x: u64 = Add(x, 1); - x, y: u64 = Add(y, 1); - y, z: u64 = Add(z, 1); - z); - Add(Add(Add(Add(r1, r2), Mul(3, x)), Mul(5, y)), Mul(7, z)) - } - } - } - public fun test() { - { - let r: u64 = Test::foo(closure Test::test$lambda$1(), closure Test::test$lambda$2(), 1, 10, 100, 1000); - if Eq(r, 9637) { - Tuple() - } else { - Abort(r) - }; - Tuple() - } - } - private fun test$lambda$1(x: u64,param$1: u64,z: u64): u64 { - { - let _: u64 = param$1; - Mul(x, z) - } - } - private fun test$lambda$2(param$0: u64,y: u64,param$2: u64): u64 { - { - let _: u64 = param$2; - { - let _: u64 = param$0; - y - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor specification rewriter: -module 0x42::Test { - private fun foo(f: |(u64, u64, u64)|u64,g: |(u64, u64, u64)|u64,x: u64,_: u64,y: u64,z: u64): u64 { - { - let r1: u64 = (f)(x: u64 = Add(x, 1); - x, y: u64 = Add(y, 1); - y, z: u64 = Add(z, 1); - z); - { - let r2: u64 = (g)(x: u64 = Add(x, 1); - x, y: u64 = Add(y, 1); - y, z: u64 = Add(z, 1); - z); - Add(Add(Add(Add(r1, r2), Mul(3, x)), Mul(5, y)), Mul(7, z)) - } - } - } - public fun test() { - { - let r: u64 = Test::foo(closure Test::test$lambda$1(), closure Test::test$lambda$2(), 1, 10, 100, 1000); - if Eq(r, 9637) { - Tuple() - } else { - Abort(r) - }; - Tuple() - } - } - private fun test$lambda$1(x: u64,param$1: u64,z: u64): u64 { - { - let _: u64 = param$1; - Mul(x, z) - } - } - private fun test$lambda$2(param$0: u64,y: u64,param$2: u64): u64 { - { - let _: u64 = param$2; - { - let _: u64 = param$0; - y - } - } - } -} // end 0x42::Test - - Diagnostics: -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda/inline-parity/eval_ignored_param.move:4:11 - │ -4 │ let r1 = f({x = x + 1; x}, {y = y + 1; y}, {z = z + 1; z}); - │ ^ - -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda/inline-parity/eval_ignored_param.move:5:11 - │ -5 │ let r2 = g({x = x + 1; x}, {y = y + 1; y}, {z = z + 1 ; z}); - │ ^ - -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/eval_ignored_param.move:10:14 │ 10 │ let r = foo(|x, _, z| x*z, |_, y, _| y, 1, 10, 100, 1000); │ ^^^^^^^^^^^^^ -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/eval_ignored_param.move:10:29 │ 10 │ let r = foo(|x, _, z| x*z, |_, y, _| y, 1, 10, 100, 1000); diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/generic_calls.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/generic_calls.lambda.exp index 3381b1bbcf75c..a5ab0261e218b 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/generic_calls.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/generic_calls.lambda.exp @@ -1,609 +1,6 @@ -// -- Model dump before env processor pipeline: -module 0x42::m { - struct S { - x: T, - } - private fun id(self: S): S { - self - } - private fun inlined(f: |S|S,s: S) { - (f)(s); - Tuple() - } - private fun receiver(self: S,y: T) { - select m::S.x>(self) = y; - Tuple() - } - private fun receiver_more_generics(self: S,_y: R) { - Tuple() - } - private fun receiver_needs_type_args(self: S,_y: T) { - Abort(1) - } - private fun receiver_ref(self: &S,_y: T) { - Tuple() - } - private fun receiver_ref_mut(self: &mut S,y: T) { - select m::S.x<&mut S>(self) = y - } - private fun test_call_styles(s: S,x: u64) { - m::receiver(s, x); - m::receiver_ref(Borrow(Immutable)(s), x); - m::receiver_ref_mut(Borrow(Mutable)(s), x); - m::receiver_more_generics(s, 22); - m::receiver_needs_type_args(s, x); - Tuple() - } - private fun test_receiver_inference(s: S) { - m::inlined(|s: S| m::id(s), s) - } -} // end 0x42::m - - -// -- Model dump after env processor unused checks: -module 0x42::m { - struct S { - x: T, - } - private fun id(self: S): S { - self - } - private fun inlined(f: |S|S,s: S) { - (f)(s); - Tuple() - } - private fun receiver(self: S,y: T) { - select m::S.x>(self) = y; - Tuple() - } - private fun receiver_more_generics(self: S,_y: R) { - Tuple() - } - private fun receiver_needs_type_args(self: S,_y: T) { - Abort(1) - } - private fun receiver_ref(self: &S,_y: T) { - Tuple() - } - private fun receiver_ref_mut(self: &mut S,y: T) { - select m::S.x<&mut S>(self) = y - } - private fun test_call_styles(s: S,x: u64) { - m::receiver(s, x); - m::receiver_ref(Borrow(Immutable)(s), x); - m::receiver_ref_mut(Borrow(Mutable)(s), x); - m::receiver_more_generics(s, 22); - m::receiver_needs_type_args(s, x); - Tuple() - } - private fun test_receiver_inference(s: S) { - m::inlined(|s: S| m::id(s), s) - } -} // end 0x42::m - - -// -- Model dump after env processor type parameter check: -module 0x42::m { - struct S { - x: T, - } - private fun id(self: S): S { - self - } - private fun inlined(f: |S|S,s: S) { - (f)(s); - Tuple() - } - private fun receiver(self: S,y: T) { - select m::S.x>(self) = y; - Tuple() - } - private fun receiver_more_generics(self: S,_y: R) { - Tuple() - } - private fun receiver_needs_type_args(self: S,_y: T) { - Abort(1) - } - private fun receiver_ref(self: &S,_y: T) { - Tuple() - } - private fun receiver_ref_mut(self: &mut S,y: T) { - select m::S.x<&mut S>(self) = y - } - private fun test_call_styles(s: S,x: u64) { - m::receiver(s, x); - m::receiver_ref(Borrow(Immutable)(s), x); - m::receiver_ref_mut(Borrow(Mutable)(s), x); - m::receiver_more_generics(s, 22); - m::receiver_needs_type_args(s, x); - Tuple() - } - private fun test_receiver_inference(s: S) { - m::inlined(|s: S| m::id(s), s) - } -} // end 0x42::m - - -// -- Model dump after env processor check recursive struct definition: -module 0x42::m { - struct S { - x: T, - } - private fun id(self: S): S { - self - } - private fun inlined(f: |S|S,s: S) { - (f)(s); - Tuple() - } - private fun receiver(self: S,y: T) { - select m::S.x>(self) = y; - Tuple() - } - private fun receiver_more_generics(self: S,_y: R) { - Tuple() - } - private fun receiver_needs_type_args(self: S,_y: T) { - Abort(1) - } - private fun receiver_ref(self: &S,_y: T) { - Tuple() - } - private fun receiver_ref_mut(self: &mut S,y: T) { - select m::S.x<&mut S>(self) = y - } - private fun test_call_styles(s: S,x: u64) { - m::receiver(s, x); - m::receiver_ref(Borrow(Immutable)(s), x); - m::receiver_ref_mut(Borrow(Mutable)(s), x); - m::receiver_more_generics(s, 22); - m::receiver_needs_type_args(s, x); - Tuple() - } - private fun test_receiver_inference(s: S) { - m::inlined(|s: S| m::id(s), s) - } -} // end 0x42::m - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x42::m { - struct S { - x: T, - } - private fun id(self: S): S { - self - } - private fun inlined(f: |S|S,s: S) { - (f)(s); - Tuple() - } - private fun receiver(self: S,y: T) { - select m::S.x>(self) = y; - Tuple() - } - private fun receiver_more_generics(self: S,_y: R) { - Tuple() - } - private fun receiver_needs_type_args(self: S,_y: T) { - Abort(1) - } - private fun receiver_ref(self: &S,_y: T) { - Tuple() - } - private fun receiver_ref_mut(self: &mut S,y: T) { - select m::S.x<&mut S>(self) = y - } - private fun test_call_styles(s: S,x: u64) { - m::receiver(s, x); - m::receiver_ref(Borrow(Immutable)(s), x); - m::receiver_ref_mut(Borrow(Mutable)(s), x); - m::receiver_more_generics(s, 22); - m::receiver_needs_type_args(s, x); - Tuple() - } - private fun test_receiver_inference(s: S) { - m::inlined(|s: S| m::id(s), s) - } -} // end 0x42::m - - -// -- Model dump after env processor unused struct params check: -module 0x42::m { - struct S { - x: T, - } - private fun id(self: S): S { - self - } - private fun inlined(f: |S|S,s: S) { - (f)(s); - Tuple() - } - private fun receiver(self: S,y: T) { - select m::S.x>(self) = y; - Tuple() - } - private fun receiver_more_generics(self: S,_y: R) { - Tuple() - } - private fun receiver_needs_type_args(self: S,_y: T) { - Abort(1) - } - private fun receiver_ref(self: &S,_y: T) { - Tuple() - } - private fun receiver_ref_mut(self: &mut S,y: T) { - select m::S.x<&mut S>(self) = y - } - private fun test_call_styles(s: S,x: u64) { - m::receiver(s, x); - m::receiver_ref(Borrow(Immutable)(s), x); - m::receiver_ref_mut(Borrow(Mutable)(s), x); - m::receiver_more_generics(s, 22); - m::receiver_needs_type_args(s, x); - Tuple() - } - private fun test_receiver_inference(s: S) { - m::inlined(|s: S| m::id(s), s) - } -} // end 0x42::m - - -// -- Model dump after env processor access and use check before inlining: -module 0x42::m { - struct S { - x: T, - } - private fun id(self: S): S { - self - } - private fun inlined(f: |S|S,s: S) { - (f)(s); - Tuple() - } - private fun receiver(self: S,y: T) { - select m::S.x>(self) = y; - Tuple() - } - private fun receiver_more_generics(self: S,_y: R) { - Tuple() - } - private fun receiver_needs_type_args(self: S,_y: T) { - Abort(1) - } - private fun receiver_ref(self: &S,_y: T) { - Tuple() - } - private fun receiver_ref_mut(self: &mut S,y: T) { - select m::S.x<&mut S>(self) = y - } - private fun test_call_styles(s: S,x: u64) { - m::receiver(s, x); - m::receiver_ref(Borrow(Immutable)(s), x); - m::receiver_ref_mut(Borrow(Mutable)(s), x); - m::receiver_more_generics(s, 22); - m::receiver_needs_type_args(s, x); - Tuple() - } - private fun test_receiver_inference(s: S) { - m::inlined(|s: S| m::id(s), s) - } -} // end 0x42::m - - -// -- Model dump after env processor inlining: -module 0x42::m { - struct S { - x: T, - } - private fun id(self: S): S { - self - } - private fun inlined(f: |S|S,s: S) { - (f)(s); - Tuple() - } - private fun receiver(self: S,y: T) { - select m::S.x>(self) = y; - Tuple() - } - private fun receiver_more_generics(self: S,_y: R) { - Tuple() - } - private fun receiver_needs_type_args(self: S,_y: T) { - Abort(1) - } - private fun receiver_ref(self: &S,_y: T) { - Tuple() - } - private fun receiver_ref_mut(self: &mut S,y: T) { - select m::S.x<&mut S>(self) = y - } - private fun test_call_styles(s: S,x: u64) { - m::receiver(s, x); - m::receiver_ref(Borrow(Immutable)(s), x); - m::receiver_ref_mut(Borrow(Mutable)(s), x); - m::receiver_more_generics(s, 22); - m::receiver_needs_type_args(s, x); - Tuple() - } - private fun test_receiver_inference(s: S) { - m::inlined(|s: S| m::id(s), s) - } -} // end 0x42::m - - -// -- Model dump after env processor access and use check after inlining: -module 0x42::m { - struct S { - x: T, - } - private fun id(self: S): S { - self - } - private fun inlined(f: |S|S,s: S) { - (f)(s); - Tuple() - } - private fun receiver(self: S,y: T) { - select m::S.x>(self) = y; - Tuple() - } - private fun receiver_more_generics(self: S,_y: R) { - Tuple() - } - private fun receiver_needs_type_args(self: S,_y: T) { - Abort(1) - } - private fun receiver_ref(self: &S,_y: T) { - Tuple() - } - private fun receiver_ref_mut(self: &mut S,y: T) { - select m::S.x<&mut S>(self) = y - } - private fun test_call_styles(s: S,x: u64) { - m::receiver(s, x); - m::receiver_ref(Borrow(Immutable)(s), x); - m::receiver_ref_mut(Borrow(Mutable)(s), x); - m::receiver_more_generics(s, 22); - m::receiver_needs_type_args(s, x); - Tuple() - } - private fun test_receiver_inference(s: S) { - m::inlined(|s: S| m::id(s), s) - } -} // end 0x42::m - - -// -- Model dump after env processor acquires check: -module 0x42::m { - struct S { - x: T, - } - private fun id(self: S): S { - self - } - private fun inlined(f: |S|S,s: S) { - (f)(s); - Tuple() - } - private fun receiver(self: S,y: T) { - select m::S.x>(self) = y; - Tuple() - } - private fun receiver_more_generics(self: S,_y: R) { - Tuple() - } - private fun receiver_needs_type_args(self: S,_y: T) { - Abort(1) - } - private fun receiver_ref(self: &S,_y: T) { - Tuple() - } - private fun receiver_ref_mut(self: &mut S,y: T) { - select m::S.x<&mut S>(self) = y - } - private fun test_call_styles(s: S,x: u64) { - m::receiver(s, x); - m::receiver_ref(Borrow(Immutable)(s), x); - m::receiver_ref_mut(Borrow(Mutable)(s), x); - m::receiver_more_generics(s, 22); - m::receiver_needs_type_args(s, x); - Tuple() - } - private fun test_receiver_inference(s: S) { - m::inlined(|s: S| m::id(s), s) - } -} // end 0x42::m - - -// -- Model dump after env processor simplifier: -module 0x42::m { - struct S { - x: T, - } - private fun id(self: S): S { - self - } - private fun inlined(f: |S|S,s: S) { - (f)(s); - Tuple() - } - private fun receiver(self: S,y: T) { - select m::S.x>(self) = y; - Tuple() - } - private fun receiver_more_generics(self: S,_y: R) { - Tuple() - } - private fun receiver_needs_type_args(self: S,_y: T) { - Abort(1) - } - private fun receiver_ref(self: &S,_y: T) { - Tuple() - } - private fun receiver_ref_mut(self: &mut S,y: T) { - select m::S.x<&mut S>(self) = y - } - private fun test_call_styles(s: S,x: u64) { - m::receiver(s, x); - m::receiver_ref(Borrow(Immutable)(s), x); - m::receiver_ref_mut(Borrow(Mutable)(s), x); - m::receiver_more_generics(s, 22); - m::receiver_needs_type_args(s, x); - Tuple() - } - private fun test_receiver_inference(s: S) { - m::inlined(|s: S| m::id(s), s) - } -} // end 0x42::m - - -// -- Model dump after env processor lambda-lifting: -module 0x42::m { - struct S { - x: T, - } - private fun id(self: S): S { - self - } - private fun inlined(f: |S|S,s: S) { - (f)(s); - Tuple() - } - private fun receiver(self: S,y: T) { - select m::S.x>(self) = y; - Tuple() - } - private fun receiver_more_generics(self: S,_y: R) { - Tuple() - } - private fun receiver_needs_type_args(self: S,_y: T) { - Abort(1) - } - private fun receiver_ref(self: &S,_y: T) { - Tuple() - } - private fun receiver_ref_mut(self: &mut S,y: T) { - select m::S.x<&mut S>(self) = y - } - private fun test_call_styles(s: S,x: u64) { - m::receiver(s, x); - m::receiver_ref(Borrow(Immutable)(s), x); - m::receiver_ref_mut(Borrow(Mutable)(s), x); - m::receiver_more_generics(s, 22); - m::receiver_needs_type_args(s, x); - Tuple() - } - private fun test_receiver_inference(s: S) { - m::inlined(closure m::test_receiver_inference$lambda$1(), s) - } - private fun test_receiver_inference$lambda$1(s: S): S { - m::id(s) - } -} // end 0x42::m - - -// -- Model dump after env processor specification checker: -module 0x42::m { - struct S { - x: T, - } - private fun id(self: S): S { - self - } - private fun inlined(f: |S|S,s: S) { - (f)(s); - Tuple() - } - private fun receiver(self: S,y: T) { - select m::S.x>(self) = y; - Tuple() - } - private fun receiver_more_generics(self: S,_y: R) { - Tuple() - } - private fun receiver_needs_type_args(self: S,_y: T) { - Abort(1) - } - private fun receiver_ref(self: &S,_y: T) { - Tuple() - } - private fun receiver_ref_mut(self: &mut S,y: T) { - select m::S.x<&mut S>(self) = y - } - private fun test_call_styles(s: S,x: u64) { - m::receiver(s, x); - m::receiver_ref(Borrow(Immutable)(s), x); - m::receiver_ref_mut(Borrow(Mutable)(s), x); - m::receiver_more_generics(s, 22); - m::receiver_needs_type_args(s, x); - Tuple() - } - private fun test_receiver_inference(s: S) { - m::inlined(closure m::test_receiver_inference$lambda$1(), s) - } - private fun test_receiver_inference$lambda$1(s: S): S { - m::id(s) - } -} // end 0x42::m - - -// -- Model dump after env processor specification rewriter: -module 0x42::m { - struct S { - x: T, - } - private fun id(self: S): S { - self - } - private fun inlined(f: |S|S,s: S) { - (f)(s); - Tuple() - } - private fun receiver(self: S,y: T) { - select m::S.x>(self) = y; - Tuple() - } - private fun receiver_more_generics(self: S,_y: R) { - Tuple() - } - private fun receiver_needs_type_args(self: S,_y: T) { - Abort(1) - } - private fun receiver_ref(self: &S,_y: T) { - Tuple() - } - private fun receiver_ref_mut(self: &mut S,y: T) { - select m::S.x<&mut S>(self) = y - } - private fun test_call_styles(s: S,x: u64) { - m::receiver(s, x); - m::receiver_ref(Borrow(Immutable)(s), x); - m::receiver_ref_mut(Borrow(Mutable)(s), x); - m::receiver_more_generics(s, 22); - m::receiver_needs_type_args(s, x); - Tuple() - } - private fun test_receiver_inference(s: S) { - m::inlined(closure m::test_receiver_inference$lambda$1(), s) - } - private fun test_receiver_inference$lambda$1(s: S): S { - m::id(s) - } -} // end 0x42::m - - Diagnostics: -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda/inline-parity/generic_calls.move:36:9 - │ -36 │ f(s); - │ ^ - -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/generic_calls.move:47:17 │ 47 │ inlined(|s| s.id(), s) diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/generics.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/generics.lambda.exp index 2a10fb8eecd8e..a025a6bc4d11e 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/generics.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/generics.lambda.exp @@ -1,334 +1,7 @@ -// -- Model dump before env processor pipeline: -module 0x42::Test { - use std::vector; - public fun foreach(v: &vector,action: |&X|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - (action)(vector::borrow(v, i)); - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - } - public fun test(): u64 { - { - let v: vector = Vector(1, 2, 3); - { - let sum: u64 = 0; - Test::foreach(Borrow(Immutable)(v), |e: &u64| sum: u64 = Add(sum, Deref(e))); - sum - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor unused checks: -module 0x42::Test { - use std::vector; - public fun foreach(v: &vector,action: |&X|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - (action)(vector::borrow(v, i)); - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - } - public fun test(): u64 { - { - let v: vector = Vector(1, 2, 3); - { - let sum: u64 = 0; - Test::foreach(Borrow(Immutable)(v), |e: &u64| sum: u64 = Add(sum, Deref(e))); - sum - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor type parameter check: -module 0x42::Test { - use std::vector; - public fun foreach(v: &vector,action: |&X|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - (action)(vector::borrow(v, i)); - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - } - public fun test(): u64 { - { - let v: vector = Vector(1, 2, 3); - { - let sum: u64 = 0; - Test::foreach(Borrow(Immutable)(v), |e: &u64| sum: u64 = Add(sum, Deref(e))); - sum - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor check recursive struct definition: -module 0x42::Test { - use std::vector; - public fun foreach(v: &vector,action: |&X|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - (action)(vector::borrow(v, i)); - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - } - public fun test(): u64 { - { - let v: vector = Vector(1, 2, 3); - { - let sum: u64 = 0; - Test::foreach(Borrow(Immutable)(v), |e: &u64| sum: u64 = Add(sum, Deref(e))); - sum - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x42::Test { - use std::vector; - public fun foreach(v: &vector,action: |&X|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - (action)(vector::borrow(v, i)); - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - } - public fun test(): u64 { - { - let v: vector = Vector(1, 2, 3); - { - let sum: u64 = 0; - Test::foreach(Borrow(Immutable)(v), |e: &u64| sum: u64 = Add(sum, Deref(e))); - sum - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor unused struct params check: -module 0x42::Test { - use std::vector; - public fun foreach(v: &vector,action: |&X|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - (action)(vector::borrow(v, i)); - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - } - public fun test(): u64 { - { - let v: vector = Vector(1, 2, 3); - { - let sum: u64 = 0; - Test::foreach(Borrow(Immutable)(v), |e: &u64| sum: u64 = Add(sum, Deref(e))); - sum - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check before inlining: -module 0x42::Test { - use std::vector; - public fun foreach(v: &vector,action: |&X|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - (action)(vector::borrow(v, i)); - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - } - public fun test(): u64 { - { - let v: vector = Vector(1, 2, 3); - { - let sum: u64 = 0; - Test::foreach(Borrow(Immutable)(v), |e: &u64| sum: u64 = Add(sum, Deref(e))); - sum - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor inlining: -module 0x42::Test { - use std::vector; - public fun foreach(v: &vector,action: |&X|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - (action)(vector::borrow(v, i)); - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - } - public fun test(): u64 { - { - let v: vector = Vector(1, 2, 3); - { - let sum: u64 = 0; - Test::foreach(Borrow(Immutable)(v), |e: &u64| sum: u64 = Add(sum, Deref(e))); - sum - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check after inlining: -module 0x42::Test { - use std::vector; - public fun foreach(v: &vector,action: |&X|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - (action)(vector::borrow(v, i)); - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - } - public fun test(): u64 { - { - let v: vector = Vector(1, 2, 3); - { - let sum: u64 = 0; - Test::foreach(Borrow(Immutable)(v), |e: &u64| sum: u64 = Add(sum, Deref(e))); - sum - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor acquires check: -module 0x42::Test { - use std::vector; - public fun foreach(v: &vector,action: |&X|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - (action)(vector::borrow(v, i)); - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - } - public fun test(): u64 { - { - let v: vector = Vector(1, 2, 3); - { - let sum: u64 = 0; - Test::foreach(Borrow(Immutable)(v), |e: &u64| sum: u64 = Add(sum, Deref(e))); - sum - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor simplifier: -module 0x42::Test { - use std::vector; - public fun foreach(v: &vector,action: |&X|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - (action)(vector::borrow(v, i)); - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - } - public fun test(): u64 { - { - let sum: u64 = 0; - Test::foreach(Borrow(Immutable)([Number(1), Number(2), Number(3)]), |e: &u64| sum: u64 = Add(sum, Deref(e))); - sum - } - } -} // end 0x42::Test - - Diagnostics: -error: captured variable `sum` cannot be modified inside of a lambda - ┌─ tests/lambda/inline-parity/generics.move:16:30 +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. + ┌─ tests/lambda/inline-parity/generics.move:16:26 │ 16 │ foreach(&v, |e| sum = sum + *e); - │ ^^^ + │ ^^^^^^^^^^^^^^^^^^ diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/inline_fun_in_spec.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/inline_fun_in_spec.lambda.exp index d4783a884aa54..af382c8a38bc9 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/inline_fun_in_spec.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/inline_fun_in_spec.lambda.exp @@ -1,645 +1,7 @@ -// -- Model dump before env processor pipeline: -module 0x42::m { - spec { - invariant forall a: address: TypeDomain
(): Implies(exists<0x42::m::S>(a), m::exec(|a: address| Lt(select m::S.f<0x42::m::S>(m::get<0x42::m::S>(a)), 10), a)); - } - - struct S { - f: u64, - } - spec { - invariant m::exec(|x: num| Gt(x, 0), select m::S.f()); - } - - private fun exec(f: |T|R,x: T): R { - { - let r: R = (f)(x); - spec { - assert Eq<#1>(r, (f)($t1)); - } - ; - r - } - } - private fun function_code_spec_block(x: u64): u64 { - spec { - assert m::exec(|y: num| Gt(y, 0), $t0); - } - ; - Add(x, 1) - } - private fun function_spec_block(x: u64): u64 { - Add(x, 1) - } - spec { - ensures Eq(result0(), m::exec(|x: num| Add(x, 1), $t0)); - } - - private inline fun get(a: address): &R { - BorrowGlobal(Immutable)(a) - } -} // end 0x42::m - - -// -- Model dump after env processor unused checks: -module 0x42::m { - spec { - invariant forall a: address: TypeDomain
(): Implies(exists<0x42::m::S>(a), m::exec(|a: address| Lt(select m::S.f<0x42::m::S>(m::get<0x42::m::S>(a)), 10), a)); - } - - struct S { - f: u64, - } - spec { - invariant m::exec(|x: num| Gt(x, 0), select m::S.f()); - } - - private fun exec(f: |T|R,x: T): R { - { - let r: R = (f)(x); - spec { - assert Eq<#1>(r, (f)($t1)); - } - ; - r - } - } - private fun function_code_spec_block(x: u64): u64 { - spec { - assert m::exec(|y: num| Gt(y, 0), $t0); - } - ; - Add(x, 1) - } - private fun function_spec_block(x: u64): u64 { - Add(x, 1) - } - spec { - ensures Eq(result0(), m::exec(|x: num| Add(x, 1), $t0)); - } - - private inline fun get(a: address): &R { - BorrowGlobal(Immutable)(a) - } -} // end 0x42::m - - -// -- Model dump after env processor type parameter check: -module 0x42::m { - spec { - invariant forall a: address: TypeDomain
(): Implies(exists<0x42::m::S>(a), m::exec(|a: address| Lt(select m::S.f<0x42::m::S>(m::get<0x42::m::S>(a)), 10), a)); - } - - struct S { - f: u64, - } - spec { - invariant m::exec(|x: num| Gt(x, 0), select m::S.f()); - } - - private fun exec(f: |T|R,x: T): R { - { - let r: R = (f)(x); - spec { - assert Eq<#1>(r, (f)($t1)); - } - ; - r - } - } - private fun function_code_spec_block(x: u64): u64 { - spec { - assert m::exec(|y: num| Gt(y, 0), $t0); - } - ; - Add(x, 1) - } - private fun function_spec_block(x: u64): u64 { - Add(x, 1) - } - spec { - ensures Eq(result0(), m::exec(|x: num| Add(x, 1), $t0)); - } - - private inline fun get(a: address): &R { - BorrowGlobal(Immutable)(a) - } -} // end 0x42::m - - -// -- Model dump after env processor check recursive struct definition: -module 0x42::m { - spec { - invariant forall a: address: TypeDomain
(): Implies(exists<0x42::m::S>(a), m::exec(|a: address| Lt(select m::S.f<0x42::m::S>(m::get<0x42::m::S>(a)), 10), a)); - } - - struct S { - f: u64, - } - spec { - invariant m::exec(|x: num| Gt(x, 0), select m::S.f()); - } - - private fun exec(f: |T|R,x: T): R { - { - let r: R = (f)(x); - spec { - assert Eq<#1>(r, (f)($t1)); - } - ; - r - } - } - private fun function_code_spec_block(x: u64): u64 { - spec { - assert m::exec(|y: num| Gt(y, 0), $t0); - } - ; - Add(x, 1) - } - private fun function_spec_block(x: u64): u64 { - Add(x, 1) - } - spec { - ensures Eq(result0(), m::exec(|x: num| Add(x, 1), $t0)); - } - - private inline fun get(a: address): &R { - BorrowGlobal(Immutable)(a) - } -} // end 0x42::m - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x42::m { - spec { - invariant forall a: address: TypeDomain
(): Implies(exists<0x42::m::S>(a), m::exec(|a: address| Lt(select m::S.f<0x42::m::S>(m::get<0x42::m::S>(a)), 10), a)); - } - - struct S { - f: u64, - } - spec { - invariant m::exec(|x: num| Gt(x, 0), select m::S.f()); - } - - private fun exec(f: |T|R,x: T): R { - { - let r: R = (f)(x); - spec { - assert Eq<#1>(r, (f)($t1)); - } - ; - r - } - } - private fun function_code_spec_block(x: u64): u64 { - spec { - assert m::exec(|y: num| Gt(y, 0), $t0); - } - ; - Add(x, 1) - } - private fun function_spec_block(x: u64): u64 { - Add(x, 1) - } - spec { - ensures Eq(result0(), m::exec(|x: num| Add(x, 1), $t0)); - } - - private inline fun get(a: address): &R { - BorrowGlobal(Immutable)(a) - } -} // end 0x42::m - - -// -- Model dump after env processor unused struct params check: -module 0x42::m { - spec { - invariant forall a: address: TypeDomain
(): Implies(exists<0x42::m::S>(a), m::exec(|a: address| Lt(select m::S.f<0x42::m::S>(m::get<0x42::m::S>(a)), 10), a)); - } - - struct S { - f: u64, - } - spec { - invariant m::exec(|x: num| Gt(x, 0), select m::S.f()); - } - - private fun exec(f: |T|R,x: T): R { - { - let r: R = (f)(x); - spec { - assert Eq<#1>(r, (f)($t1)); - } - ; - r - } - } - private fun function_code_spec_block(x: u64): u64 { - spec { - assert m::exec(|y: num| Gt(y, 0), $t0); - } - ; - Add(x, 1) - } - private fun function_spec_block(x: u64): u64 { - Add(x, 1) - } - spec { - ensures Eq(result0(), m::exec(|x: num| Add(x, 1), $t0)); - } - - private inline fun get(a: address): &R { - BorrowGlobal(Immutable)(a) - } -} // end 0x42::m - - -// -- Model dump after env processor access and use check before inlining: -module 0x42::m { - spec { - invariant forall a: address: TypeDomain
(): Implies(exists<0x42::m::S>(a), m::exec(|a: address| Lt(select m::S.f<0x42::m::S>(m::get<0x42::m::S>(a)), 10), a)); - } - - struct S { - f: u64, - } - spec { - invariant m::exec(|x: num| Gt(x, 0), select m::S.f()); - } - - private fun exec(f: |T|R,x: T): R { - { - let r: R = (f)(x); - spec { - assert Eq<#1>(r, (f)($t1)); - } - ; - r - } - } - private fun function_code_spec_block(x: u64): u64 { - spec { - assert m::exec(|y: num| Gt(y, 0), $t0); - } - ; - Add(x, 1) - } - private fun function_spec_block(x: u64): u64 { - Add(x, 1) - } - spec { - ensures Eq(result0(), m::exec(|x: num| Add(x, 1), $t0)); - } - - private inline fun get(a: address): &R { - BorrowGlobal(Immutable)(a) - } -} // end 0x42::m - - -// -- Model dump after env processor inlining: -module 0x42::m { - spec { - invariant forall a: address: TypeDomain
(): Implies(exists<0x42::m::S>(a), m::exec(|a: address| Lt(select m::S.f<0x42::m::S>({ - let (a: address): (address) = Tuple(a); - BorrowGlobal(Immutable)<0x42::m::S>(a) - }), 10), a)); - } - - struct S { - f: u64, - } - spec { - invariant m::exec(|x: num| Gt(x, 0), select m::S.f()); - } - - private fun exec(f: |T|R,x: T): R { - { - let r: R = (f)(x); - spec { - assert Eq<#1>(r, (f)($t1)); - } - ; - r - } - } - private fun function_code_spec_block(x: u64): u64 { - spec { - assert m::exec(|y: num| Gt(y, 0), $t0); - } - ; - Add(x, 1) - } - private fun function_spec_block(x: u64): u64 { - Add(x, 1) - } - spec { - ensures Eq(result0(), m::exec(|x: num| Add(x, 1), $t0)); - } - - private inline fun get(a: address): &R { - BorrowGlobal(Immutable)(a) - } -} // end 0x42::m - - -// -- Model dump after env processor access and use check after inlining: -module 0x42::m { - spec { - invariant forall a: address: TypeDomain
(): Implies(exists<0x42::m::S>(a), m::exec(|a: address| Lt(select m::S.f<0x42::m::S>({ - let (a: address): (address) = Tuple(a); - BorrowGlobal(Immutable)<0x42::m::S>(a) - }), 10), a)); - } - - struct S { - f: u64, - } - spec { - invariant m::exec(|x: num| Gt(x, 0), select m::S.f()); - } - - private fun exec(f: |T|R,x: T): R { - { - let r: R = (f)(x); - spec { - assert Eq<#1>(r, (f)($t1)); - } - ; - r - } - } - private fun function_code_spec_block(x: u64): u64 { - spec { - assert m::exec(|y: num| Gt(y, 0), $t0); - } - ; - Add(x, 1) - } - private fun function_spec_block(x: u64): u64 { - Add(x, 1) - } - spec { - ensures Eq(result0(), m::exec(|x: num| Add(x, 1), $t0)); - } - - private inline fun get(a: address): &R { - BorrowGlobal(Immutable)(a) - } -} // end 0x42::m - - -// -- Model dump after env processor acquires check: -module 0x42::m { - spec { - invariant forall a: address: TypeDomain
(): Implies(exists<0x42::m::S>(a), m::exec(|a: address| Lt(select m::S.f<0x42::m::S>({ - let (a: address): (address) = Tuple(a); - BorrowGlobal(Immutable)<0x42::m::S>(a) - }), 10), a)); - } - - struct S { - f: u64, - } - spec { - invariant m::exec(|x: num| Gt(x, 0), select m::S.f()); - } - - private fun exec(f: |T|R,x: T): R { - { - let r: R = (f)(x); - spec { - assert Eq<#1>(r, (f)($t1)); - } - ; - r - } - } - private fun function_code_spec_block(x: u64): u64 { - spec { - assert m::exec(|y: num| Gt(y, 0), $t0); - } - ; - Add(x, 1) - } - private fun function_spec_block(x: u64): u64 { - Add(x, 1) - } - spec { - ensures Eq(result0(), m::exec(|x: num| Add(x, 1), $t0)); - } - - private inline fun get(a: address): &R { - BorrowGlobal(Immutable)(a) - } -} // end 0x42::m - - -// -- Model dump after env processor simplifier: -module 0x42::m { - spec { - invariant forall a: address: TypeDomain
(): Implies(exists<0x42::m::S>(a), m::exec(|a: address| Lt(select m::S.f<0x42::m::S>({ - let (a: address): (address) = Tuple(a); - BorrowGlobal(Immutable)<0x42::m::S>(a) - }), 10), a)); - } - - struct S { - f: u64, - } - spec { - invariant m::exec(|x: num| Gt(x, 0), select m::S.f()); - } - - private fun exec(f: |T|R,x: T): R { - { - let r: R = (f)(x); - spec { - assert Eq<#1>(r, (f)($t1)); - } - ; - r - } - } - private fun function_code_spec_block(x: u64): u64 { - spec { - assert m::exec(|y: num| Gt(y, 0), $t0); - } - ; - Add(x, 1) - } - private fun function_spec_block(x: u64): u64 { - Add(x, 1) - } - spec { - ensures Eq(result0(), m::exec(|x: num| Add(x, 1), $t0)); - } - - private inline fun get(a: address): &R { - BorrowGlobal(Immutable)(a) - } -} // end 0x42::m - - -// -- Model dump after env processor lambda-lifting: -module 0x42::m { - spec { - invariant forall a: address: TypeDomain
(): Implies(exists<0x42::m::S>(a), m::exec(|a: address| Lt(select m::S.f<0x42::m::S>({ - let (a: address): (address) = Tuple(a); - BorrowGlobal(Immutable)<0x42::m::S>(a) - }), 10), a)); - } - - struct S { - f: u64, - } - spec { - invariant m::exec(|x: num| Gt(x, 0), select m::S.f()); - } - - private fun exec(f: |T|R,x: T): R { - { - let r: R = (f)(x); - spec { - assert Eq<#1>(r, (f)($t1)); - } - ; - r - } - } - private fun function_code_spec_block(x: u64): u64 { - spec { - assert m::exec(closure m::function_code_spec_block$lambda$1(), $t0); - } - ; - Add(x, 1) - } - private fun function_spec_block(x: u64): u64 { - Add(x, 1) - } - spec { - ensures Eq(result0(), m::exec(|x: num| Add(x, 1), $t0)); - } - - private inline fun get(a: address): &R { - BorrowGlobal(Immutable)(a) - } - private fun function_code_spec_block$lambda$1(y: num): bool { - Gt(y, 0) - } -} // end 0x42::m - - -// -- Model dump after env processor specification checker: -module 0x42::m { - spec { - invariant forall a: address: TypeDomain
(): Implies(exists<0x42::m::S>(a), m::exec(|a: address| Lt(select m::S.f<0x42::m::S>({ - let (a: address): (address) = Tuple(a); - BorrowGlobal(Immutable)<0x42::m::S>(a) - }), 10), a)); - } - - struct S { - f: u64, - } - spec { - invariant m::exec(|x: num| Gt(x, 0), select m::S.f()); - } - - private fun exec(f: |T|R,x: T): R { - { - let r: R = (f)(x); - spec { - assert Eq<#1>(r, (f)($t1)); - } - ; - r - } - } - private fun function_code_spec_block(x: u64): u64 { - spec { - assert m::exec(closure m::function_code_spec_block$lambda$1(), $t0); - } - ; - Add(x, 1) - } - private fun function_spec_block(x: u64): u64 { - Add(x, 1) - } - spec { - ensures Eq(result0(), m::exec(|x: num| Add(x, 1), $t0)); - } - - private inline fun get(a: address): &R { - BorrowGlobal(Immutable)(a) - } - private fun function_code_spec_block$lambda$1(y: num): bool { - Gt(y, 0) - } -} // end 0x42::m - - -// -- Model dump after env processor specification rewriter: -module 0x42::m { - spec { - invariant forall a: address: TypeDomain
(): Implies(exists<0x42::m::S>(a), m::$exec(|a: address| Lt(select m::S.f<0x42::m::S>({ - let (a: address): (address) = Tuple(a); - global<0x42::m::S>(a) - }), 10), a)); - } - - struct S { - f: u64, - } - spec { - invariant m::$exec(|x: num| Gt(x, 0), select m::S.f()); - } - - private fun exec(f: |T|R,x: T): R { - { - let r: R = (f)(x); - spec { - assert Eq<#1>(r, (f)($t1)); - } - ; - r - } - } - private fun function_code_spec_block(x: u64): u64 { - spec { - assert m::$exec(closure m::function_code_spec_block$lambda$1(), $t0); - } - ; - Add(x, 1) - } - private fun function_spec_block(x: u64): u64 { - Add(x, 1) - } - spec { - ensures Eq(result0(), m::$exec(|x: num| Add(x, 1), $t0)); - } - - private inline fun get(a: address): &R { - BorrowGlobal(Immutable)(a) - } - private fun function_code_spec_block$lambda$1(y: num): bool { - Gt(y, 0) - } - spec fun $exec(f: |#0|#1,x: #0): #1 { - { - let r: #1 = (f)(x); - r - } - } -} // end 0x42::m - - Diagnostics: -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda/inline-parity/inline_fun_in_spec.move:4:17 - │ -4 │ let r = f(x); - │ ^ +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. + ┌─ tests/lambda/inline-parity/inline_fun_in_spec.move:19:28 + │ +19 │ spec { assert exec(|y| y > 0, x); }; + │ ^^^^^^^^^ diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/inlining1.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/inlining1.lambda.exp index ccd5c61991485..d41643a06c7d0 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/inlining1.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/inlining1.lambda.exp @@ -1,296 +1,6 @@ -// -- Model dump before env processor pipeline: -module 0x42::Test { - private fun foo(f: |u64|u64,x: u64): u64 { - (f)(x) - } - public fun main() { - if Eq(Test::test(), 3) { - Tuple() - } else { - Abort(5) - }; - Tuple() - } - public fun test(): u64 { - Test::foo(|_: u64| 3, 10) - } -} // end 0x42::Test - - -// -- Model dump after env processor unused checks: -module 0x42::Test { - private fun foo(f: |u64|u64,x: u64): u64 { - (f)(x) - } - public fun main() { - if Eq(Test::test(), 3) { - Tuple() - } else { - Abort(5) - }; - Tuple() - } - public fun test(): u64 { - Test::foo(|_: u64| 3, 10) - } -} // end 0x42::Test - - -// -- Model dump after env processor type parameter check: -module 0x42::Test { - private fun foo(f: |u64|u64,x: u64): u64 { - (f)(x) - } - public fun main() { - if Eq(Test::test(), 3) { - Tuple() - } else { - Abort(5) - }; - Tuple() - } - public fun test(): u64 { - Test::foo(|_: u64| 3, 10) - } -} // end 0x42::Test - - -// -- Model dump after env processor check recursive struct definition: -module 0x42::Test { - private fun foo(f: |u64|u64,x: u64): u64 { - (f)(x) - } - public fun main() { - if Eq(Test::test(), 3) { - Tuple() - } else { - Abort(5) - }; - Tuple() - } - public fun test(): u64 { - Test::foo(|_: u64| 3, 10) - } -} // end 0x42::Test - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x42::Test { - private fun foo(f: |u64|u64,x: u64): u64 { - (f)(x) - } - public fun main() { - if Eq(Test::test(), 3) { - Tuple() - } else { - Abort(5) - }; - Tuple() - } - public fun test(): u64 { - Test::foo(|_: u64| 3, 10) - } -} // end 0x42::Test - - -// -- Model dump after env processor unused struct params check: -module 0x42::Test { - private fun foo(f: |u64|u64,x: u64): u64 { - (f)(x) - } - public fun main() { - if Eq(Test::test(), 3) { - Tuple() - } else { - Abort(5) - }; - Tuple() - } - public fun test(): u64 { - Test::foo(|_: u64| 3, 10) - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check before inlining: -module 0x42::Test { - private fun foo(f: |u64|u64,x: u64): u64 { - (f)(x) - } - public fun main() { - if Eq(Test::test(), 3) { - Tuple() - } else { - Abort(5) - }; - Tuple() - } - public fun test(): u64 { - Test::foo(|_: u64| 3, 10) - } -} // end 0x42::Test - - -// -- Model dump after env processor inlining: -module 0x42::Test { - private fun foo(f: |u64|u64,x: u64): u64 { - (f)(x) - } - public fun main() { - if Eq(Test::test(), 3) { - Tuple() - } else { - Abort(5) - }; - Tuple() - } - public fun test(): u64 { - Test::foo(|_: u64| 3, 10) - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check after inlining: -module 0x42::Test { - private fun foo(f: |u64|u64,x: u64): u64 { - (f)(x) - } - public fun main() { - if Eq(Test::test(), 3) { - Tuple() - } else { - Abort(5) - }; - Tuple() - } - public fun test(): u64 { - Test::foo(|_: u64| 3, 10) - } -} // end 0x42::Test - - -// -- Model dump after env processor acquires check: -module 0x42::Test { - private fun foo(f: |u64|u64,x: u64): u64 { - (f)(x) - } - public fun main() { - if Eq(Test::test(), 3) { - Tuple() - } else { - Abort(5) - }; - Tuple() - } - public fun test(): u64 { - Test::foo(|_: u64| 3, 10) - } -} // end 0x42::Test - - -// -- Model dump after env processor simplifier: -module 0x42::Test { - private fun foo(f: |u64|u64,x: u64): u64 { - (f)(x) - } - public fun main() { - if Eq(Test::test(), 3) { - Tuple() - } else { - Abort(5) - }; - Tuple() - } - public fun test(): u64 { - Test::foo(|_: u64| 3, 10) - } -} // end 0x42::Test - - -// -- Model dump after env processor lambda-lifting: -module 0x42::Test { - private fun foo(f: |u64|u64,x: u64): u64 { - (f)(x) - } - public fun main() { - if Eq(Test::test(), 3) { - Tuple() - } else { - Abort(5) - }; - Tuple() - } - public fun test(): u64 { - Test::foo(closure Test::test$lambda$1(), 10) - } - private fun test$lambda$1(param$0: u64): u64 { - { - let _: u64 = param$0; - 3 - } - } -} // end 0x42::Test - - -// -- Model dump after env processor specification checker: -module 0x42::Test { - private fun foo(f: |u64|u64,x: u64): u64 { - (f)(x) - } - public fun main() { - if Eq(Test::test(), 3) { - Tuple() - } else { - Abort(5) - }; - Tuple() - } - public fun test(): u64 { - Test::foo(closure Test::test$lambda$1(), 10) - } - private fun test$lambda$1(param$0: u64): u64 { - { - let _: u64 = param$0; - 3 - } - } -} // end 0x42::Test - - -// -- Model dump after env processor specification rewriter: -module 0x42::Test { - private fun foo(f: |u64|u64,x: u64): u64 { - (f)(x) - } - public fun main() { - if Eq(Test::test(), 3) { - Tuple() - } else { - Abort(5) - }; - Tuple() - } - public fun test(): u64 { - Test::foo(closure Test::test$lambda$1(), 10) - } - private fun test$lambda$1(param$0: u64): u64 { - { - let _: u64 = param$0; - 3 - } - } -} // end 0x42::Test - - Diagnostics: -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda/inline-parity/inlining1.move:4:9 - │ -4 │ f(x) - │ ^ - -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/inlining1.move:8:13 │ 8 │ foo(|_| 3, 10) diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/lambda.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/lambda.lambda.exp index 0edf647447ceb..70f1e1bbbc99f 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/lambda.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/lambda.lambda.exp @@ -1,752 +1,52 @@ -// -- Model dump before env processor pipeline: -module 0x42::LambdaTest1 { - public fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public fun inline_apply1(f: |u64|u64,b: u64): u64 { - LambdaTest1::inline_mul(Add((f)(b), 1), LambdaTest1::inline_mul(3, 4)) - } - public fun inline_mul(a: u64,b: u64): u64 { - Mul(a, b) - } -} // end 0x42::LambdaTest1 -module 0x42::LambdaTest2 { - use 0x42::LambdaTest1; // resolved as: 0x42::LambdaTest1 - use std::vector; - public fun foreach(v: &vector,action: |&T|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - (action)(vector::borrow(v, i)); - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - } - public fun inline_apply2(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(|z: u64| z, (g)(LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| x, 3)))), 2) - } - public fun inline_apply3(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(g, LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| LambdaTest1::inline_apply(|y: u64| y, x), 3))), 4) - } - public fun test_inline_lambda() { - { - let v: vector = Vector(1, 2, 3); - { - let product: u64 = 1; - LambdaTest2::foreach(Borrow(Immutable)(v), |e: &u64| product: u64 = LambdaTest1::inline_mul(product, Deref(e))); - Tuple() - } - } - } -} // end 0x42::LambdaTest2 -module 0x42::LambdaTest { - use 0x42::LambdaTest2; // resolved as: 0x42::LambdaTest2 - public fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public fun inline_apply_test(): u64 { - Add(LambdaTest2::inline_apply2(|x: u64| Add(x, 1), 3), LambdaTest2::inline_apply2(|x: u64| Mul(x, x), LambdaTest::inline_apply(|y: u64| y, 3))) - } - private fun test_lambda() { - { - let a: u64 = LambdaTest::inline_apply_test(); - if Eq(a, 1) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaTest - - -// -- Model dump after env processor unused checks: -module 0x42::LambdaTest1 { - public fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public fun inline_apply1(f: |u64|u64,b: u64): u64 { - LambdaTest1::inline_mul(Add((f)(b), 1), LambdaTest1::inline_mul(3, 4)) - } - public fun inline_mul(a: u64,b: u64): u64 { - Mul(a, b) - } -} // end 0x42::LambdaTest1 -module 0x42::LambdaTest2 { - use 0x42::LambdaTest1; // resolved as: 0x42::LambdaTest1 - use std::vector; - public fun foreach(v: &vector,action: |&T|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - (action)(vector::borrow(v, i)); - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - } - public fun inline_apply2(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(|z: u64| z, (g)(LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| x, 3)))), 2) - } - public fun inline_apply3(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(g, LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| LambdaTest1::inline_apply(|y: u64| y, x), 3))), 4) - } - public fun test_inline_lambda() { - { - let v: vector = Vector(1, 2, 3); - { - let product: u64 = 1; - LambdaTest2::foreach(Borrow(Immutable)(v), |e: &u64| product: u64 = LambdaTest1::inline_mul(product, Deref(e))); - Tuple() - } - } - } -} // end 0x42::LambdaTest2 -module 0x42::LambdaTest { - use 0x42::LambdaTest2; // resolved as: 0x42::LambdaTest2 - public fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public fun inline_apply_test(): u64 { - Add(LambdaTest2::inline_apply2(|x: u64| Add(x, 1), 3), LambdaTest2::inline_apply2(|x: u64| Mul(x, x), LambdaTest::inline_apply(|y: u64| y, 3))) - } - private fun test_lambda() { - { - let a: u64 = LambdaTest::inline_apply_test(); - if Eq(a, 1) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaTest - - -// -- Model dump after env processor type parameter check: -module 0x42::LambdaTest1 { - public fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public fun inline_apply1(f: |u64|u64,b: u64): u64 { - LambdaTest1::inline_mul(Add((f)(b), 1), LambdaTest1::inline_mul(3, 4)) - } - public fun inline_mul(a: u64,b: u64): u64 { - Mul(a, b) - } -} // end 0x42::LambdaTest1 -module 0x42::LambdaTest2 { - use 0x42::LambdaTest1; // resolved as: 0x42::LambdaTest1 - use std::vector; - public fun foreach(v: &vector,action: |&T|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - (action)(vector::borrow(v, i)); - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - } - public fun inline_apply2(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(|z: u64| z, (g)(LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| x, 3)))), 2) - } - public fun inline_apply3(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(g, LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| LambdaTest1::inline_apply(|y: u64| y, x), 3))), 4) - } - public fun test_inline_lambda() { - { - let v: vector = Vector(1, 2, 3); - { - let product: u64 = 1; - LambdaTest2::foreach(Borrow(Immutable)(v), |e: &u64| product: u64 = LambdaTest1::inline_mul(product, Deref(e))); - Tuple() - } - } - } -} // end 0x42::LambdaTest2 -module 0x42::LambdaTest { - use 0x42::LambdaTest2; // resolved as: 0x42::LambdaTest2 - public fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public fun inline_apply_test(): u64 { - Add(LambdaTest2::inline_apply2(|x: u64| Add(x, 1), 3), LambdaTest2::inline_apply2(|x: u64| Mul(x, x), LambdaTest::inline_apply(|y: u64| y, 3))) - } - private fun test_lambda() { - { - let a: u64 = LambdaTest::inline_apply_test(); - if Eq(a, 1) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaTest - - -// -- Model dump after env processor check recursive struct definition: -module 0x42::LambdaTest1 { - public fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public fun inline_apply1(f: |u64|u64,b: u64): u64 { - LambdaTest1::inline_mul(Add((f)(b), 1), LambdaTest1::inline_mul(3, 4)) - } - public fun inline_mul(a: u64,b: u64): u64 { - Mul(a, b) - } -} // end 0x42::LambdaTest1 -module 0x42::LambdaTest2 { - use 0x42::LambdaTest1; // resolved as: 0x42::LambdaTest1 - use std::vector; - public fun foreach(v: &vector,action: |&T|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - (action)(vector::borrow(v, i)); - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - } - public fun inline_apply2(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(|z: u64| z, (g)(LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| x, 3)))), 2) - } - public fun inline_apply3(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(g, LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| LambdaTest1::inline_apply(|y: u64| y, x), 3))), 4) - } - public fun test_inline_lambda() { - { - let v: vector = Vector(1, 2, 3); - { - let product: u64 = 1; - LambdaTest2::foreach(Borrow(Immutable)(v), |e: &u64| product: u64 = LambdaTest1::inline_mul(product, Deref(e))); - Tuple() - } - } - } -} // end 0x42::LambdaTest2 -module 0x42::LambdaTest { - use 0x42::LambdaTest2; // resolved as: 0x42::LambdaTest2 - public fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public fun inline_apply_test(): u64 { - Add(LambdaTest2::inline_apply2(|x: u64| Add(x, 1), 3), LambdaTest2::inline_apply2(|x: u64| Mul(x, x), LambdaTest::inline_apply(|y: u64| y, 3))) - } - private fun test_lambda() { - { - let a: u64 = LambdaTest::inline_apply_test(); - if Eq(a, 1) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaTest - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x42::LambdaTest1 { - public fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public fun inline_apply1(f: |u64|u64,b: u64): u64 { - LambdaTest1::inline_mul(Add((f)(b), 1), LambdaTest1::inline_mul(3, 4)) - } - public fun inline_mul(a: u64,b: u64): u64 { - Mul(a, b) - } -} // end 0x42::LambdaTest1 -module 0x42::LambdaTest2 { - use 0x42::LambdaTest1; // resolved as: 0x42::LambdaTest1 - use std::vector; - public fun foreach(v: &vector,action: |&T|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - (action)(vector::borrow(v, i)); - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - } - public fun inline_apply2(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(|z: u64| z, (g)(LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| x, 3)))), 2) - } - public fun inline_apply3(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(g, LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| LambdaTest1::inline_apply(|y: u64| y, x), 3))), 4) - } - public fun test_inline_lambda() { - { - let v: vector = Vector(1, 2, 3); - { - let product: u64 = 1; - LambdaTest2::foreach(Borrow(Immutable)(v), |e: &u64| product: u64 = LambdaTest1::inline_mul(product, Deref(e))); - Tuple() - } - } - } -} // end 0x42::LambdaTest2 -module 0x42::LambdaTest { - use 0x42::LambdaTest2; // resolved as: 0x42::LambdaTest2 - public fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public fun inline_apply_test(): u64 { - Add(LambdaTest2::inline_apply2(|x: u64| Add(x, 1), 3), LambdaTest2::inline_apply2(|x: u64| Mul(x, x), LambdaTest::inline_apply(|y: u64| y, 3))) - } - private fun test_lambda() { - { - let a: u64 = LambdaTest::inline_apply_test(); - if Eq(a, 1) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaTest - - -// -- Model dump after env processor unused struct params check: -module 0x42::LambdaTest1 { - public fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public fun inline_apply1(f: |u64|u64,b: u64): u64 { - LambdaTest1::inline_mul(Add((f)(b), 1), LambdaTest1::inline_mul(3, 4)) - } - public fun inline_mul(a: u64,b: u64): u64 { - Mul(a, b) - } -} // end 0x42::LambdaTest1 -module 0x42::LambdaTest2 { - use 0x42::LambdaTest1; // resolved as: 0x42::LambdaTest1 - use std::vector; - public fun foreach(v: &vector,action: |&T|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - (action)(vector::borrow(v, i)); - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - } - public fun inline_apply2(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(|z: u64| z, (g)(LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| x, 3)))), 2) - } - public fun inline_apply3(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(g, LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| LambdaTest1::inline_apply(|y: u64| y, x), 3))), 4) - } - public fun test_inline_lambda() { - { - let v: vector = Vector(1, 2, 3); - { - let product: u64 = 1; - LambdaTest2::foreach(Borrow(Immutable)(v), |e: &u64| product: u64 = LambdaTest1::inline_mul(product, Deref(e))); - Tuple() - } - } - } -} // end 0x42::LambdaTest2 -module 0x42::LambdaTest { - use 0x42::LambdaTest2; // resolved as: 0x42::LambdaTest2 - public fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public fun inline_apply_test(): u64 { - Add(LambdaTest2::inline_apply2(|x: u64| Add(x, 1), 3), LambdaTest2::inline_apply2(|x: u64| Mul(x, x), LambdaTest::inline_apply(|y: u64| y, 3))) - } - private fun test_lambda() { - { - let a: u64 = LambdaTest::inline_apply_test(); - if Eq(a, 1) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaTest - - -// -- Model dump after env processor access and use check before inlining: -module 0x42::LambdaTest1 { - public fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public fun inline_apply1(f: |u64|u64,b: u64): u64 { - LambdaTest1::inline_mul(Add((f)(b), 1), LambdaTest1::inline_mul(3, 4)) - } - public fun inline_mul(a: u64,b: u64): u64 { - Mul(a, b) - } -} // end 0x42::LambdaTest1 -module 0x42::LambdaTest2 { - use 0x42::LambdaTest1; // resolved as: 0x42::LambdaTest1 - use std::vector; - public fun foreach(v: &vector,action: |&T|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - (action)(vector::borrow(v, i)); - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - } - public fun inline_apply2(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(|z: u64| z, (g)(LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| x, 3)))), 2) - } - public fun inline_apply3(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(g, LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| LambdaTest1::inline_apply(|y: u64| y, x), 3))), 4) - } - public fun test_inline_lambda() { - { - let v: vector = Vector(1, 2, 3); - { - let product: u64 = 1; - LambdaTest2::foreach(Borrow(Immutable)(v), |e: &u64| product: u64 = LambdaTest1::inline_mul(product, Deref(e))); - Tuple() - } - } - } -} // end 0x42::LambdaTest2 -module 0x42::LambdaTest { - use 0x42::LambdaTest2; // resolved as: 0x42::LambdaTest2 - public fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public fun inline_apply_test(): u64 { - Add(LambdaTest2::inline_apply2(|x: u64| Add(x, 1), 3), LambdaTest2::inline_apply2(|x: u64| Mul(x, x), LambdaTest::inline_apply(|y: u64| y, 3))) - } - private fun test_lambda() { - { - let a: u64 = LambdaTest::inline_apply_test(); - if Eq(a, 1) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaTest - - -// -- Model dump after env processor inlining: -module 0x42::LambdaTest1 { - public fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public fun inline_apply1(f: |u64|u64,b: u64): u64 { - LambdaTest1::inline_mul(Add((f)(b), 1), LambdaTest1::inline_mul(3, 4)) - } - public fun inline_mul(a: u64,b: u64): u64 { - Mul(a, b) - } -} // end 0x42::LambdaTest1 -module 0x42::LambdaTest2 { - use 0x42::LambdaTest1; // resolved as: 0x42::LambdaTest1 - use std::vector; - public fun foreach(v: &vector,action: |&T|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - (action)(vector::borrow(v, i)); - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - } - public fun inline_apply2(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(|z: u64| z, (g)(LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| x, 3)))), 2) - } - public fun inline_apply3(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(g, LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| LambdaTest1::inline_apply(|y: u64| y, x), 3))), 4) - } - public fun test_inline_lambda() { - { - let v: vector = Vector(1, 2, 3); - { - let product: u64 = 1; - LambdaTest2::foreach(Borrow(Immutable)(v), |e: &u64| product: u64 = LambdaTest1::inline_mul(product, Deref(e))); - Tuple() - } - } - } -} // end 0x42::LambdaTest2 -module 0x42::LambdaTest { - use 0x42::LambdaTest2; // resolved as: 0x42::LambdaTest2 - public fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public fun inline_apply_test(): u64 { - Add(LambdaTest2::inline_apply2(|x: u64| Add(x, 1), 3), LambdaTest2::inline_apply2(|x: u64| Mul(x, x), LambdaTest::inline_apply(|y: u64| y, 3))) - } - private fun test_lambda() { - { - let a: u64 = LambdaTest::inline_apply_test(); - if Eq(a, 1) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaTest - - -// -- Model dump after env processor access and use check after inlining: -module 0x42::LambdaTest1 { - public fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public fun inline_apply1(f: |u64|u64,b: u64): u64 { - LambdaTest1::inline_mul(Add((f)(b), 1), LambdaTest1::inline_mul(3, 4)) - } - public fun inline_mul(a: u64,b: u64): u64 { - Mul(a, b) - } -} // end 0x42::LambdaTest1 -module 0x42::LambdaTest2 { - use 0x42::LambdaTest1; // resolved as: 0x42::LambdaTest1 - use std::vector; - public fun foreach(v: &vector,action: |&T|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - (action)(vector::borrow(v, i)); - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - } - public fun inline_apply2(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(|z: u64| z, (g)(LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| x, 3)))), 2) - } - public fun inline_apply3(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(g, LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| LambdaTest1::inline_apply(|y: u64| y, x), 3))), 4) - } - public fun test_inline_lambda() { - { - let v: vector = Vector(1, 2, 3); - { - let product: u64 = 1; - LambdaTest2::foreach(Borrow(Immutable)(v), |e: &u64| product: u64 = LambdaTest1::inline_mul(product, Deref(e))); - Tuple() - } - } - } -} // end 0x42::LambdaTest2 -module 0x42::LambdaTest { - use 0x42::LambdaTest2; // resolved as: 0x42::LambdaTest2 - public fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public fun inline_apply_test(): u64 { - Add(LambdaTest2::inline_apply2(|x: u64| Add(x, 1), 3), LambdaTest2::inline_apply2(|x: u64| Mul(x, x), LambdaTest::inline_apply(|y: u64| y, 3))) - } - private fun test_lambda() { - { - let a: u64 = LambdaTest::inline_apply_test(); - if Eq(a, 1) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaTest +Diagnostics: +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. + ┌─ tests/lambda/inline-parity/lambda.move:30:14 + │ +30 │ foreach(&v, |e| product = LambdaTest1::inline_mul(product, *e)); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -// -- Model dump after env processor acquires check: -module 0x42::LambdaTest1 { - public fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public fun inline_apply1(f: |u64|u64,b: u64): u64 { - LambdaTest1::inline_mul(Add((f)(b), 1), LambdaTest1::inline_mul(3, 4)) - } - public fun inline_mul(a: u64,b: u64): u64 { - Mul(a, b) - } -} // end 0x42::LambdaTest1 -module 0x42::LambdaTest2 { - use 0x42::LambdaTest1; // resolved as: 0x42::LambdaTest1 - use std::vector; - public fun foreach(v: &vector,action: |&T|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - (action)(vector::borrow(v, i)); - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - } - public fun inline_apply2(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(|z: u64| z, (g)(LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| x, 3)))), 2) - } - public fun inline_apply3(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(g, LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| LambdaTest1::inline_apply(|y: u64| y, x), 3))), 4) - } - public fun test_inline_lambda() { - { - let v: vector = Vector(1, 2, 3); - { - let product: u64 = 1; - LambdaTest2::foreach(Borrow(Immutable)(v), |e: &u64| product: u64 = LambdaTest1::inline_mul(product, Deref(e))); - Tuple() - } - } - } -} // end 0x42::LambdaTest2 -module 0x42::LambdaTest { - use 0x42::LambdaTest2; // resolved as: 0x42::LambdaTest2 - public fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public fun inline_apply_test(): u64 { - Add(LambdaTest2::inline_apply2(|x: u64| Add(x, 1), 3), LambdaTest2::inline_apply2(|x: u64| Mul(x, x), LambdaTest::inline_apply(|y: u64| y, 3))) - } - private fun test_lambda() { - { - let a: u64 = LambdaTest::inline_apply_test(); - if Eq(a, 1) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaTest +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. + ┌─ tests/lambda/inline-parity/lambda.move:34:29 + │ +34 │ LambdaTest1::inline_apply1(|z|z, g(LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x|x, 3)))) + 2 + │ ^^^^ +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. + ┌─ tests/lambda/inline-parity/lambda.move:34:90 + │ +34 │ LambdaTest1::inline_apply1(|z|z, g(LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x|x, 3)))) + 2 + │ ^^^^ -// -- Model dump after env processor simplifier: -module 0x42::LambdaTest1 { - public fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public fun inline_apply1(f: |u64|u64,b: u64): u64 { - LambdaTest1::inline_mul(Add((f)(b), 1), LambdaTest1::inline_mul(3, 4)) - } - public fun inline_mul(a: u64,b: u64): u64 { - Mul(a, b) - } -} // end 0x42::LambdaTest1 -module 0x42::LambdaTest2 { - use 0x42::LambdaTest1; // resolved as: 0x42::LambdaTest1 - use std::vector; - public fun foreach(v: &vector,action: |&T|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - (action)(vector::borrow(v, i)); - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - } - public fun inline_apply2(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(|z: u64| z, (g)(LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| x, 3)))), 2) - } - public fun inline_apply3(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(g, LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| LambdaTest1::inline_apply(|y: u64| y, x), 3))), 4) - } - public fun test_inline_lambda() { - { - let product: u64 = 1; - LambdaTest2::foreach(Borrow(Immutable)([Number(1), Number(2), Number(3)]), |e: &u64| product: u64 = LambdaTest1::inline_mul(product, Deref(e))); - Tuple() - } - } -} // end 0x42::LambdaTest2 -module 0x42::LambdaTest { - use 0x42::LambdaTest2; // resolved as: 0x42::LambdaTest2 - public fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public fun inline_apply_test(): u64 { - Add(LambdaTest2::inline_apply2(|x: u64| Add(x, 1), 3), LambdaTest2::inline_apply2(|x: u64| Mul(x, x), LambdaTest::inline_apply(|y: u64| y, 3))) - } - private fun test_lambda() { - { - let a: u64 = LambdaTest::inline_apply_test(); - if Eq(a, 1) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaTest +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. + ┌─ tests/lambda/inline-parity/lambda.move:40:29 + │ +40 │ LambdaTest1::inline_apply(|y|y, x) + │ ^^^^ +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. + ┌─ tests/lambda/inline-parity/lambda.move:39:59 + │ +39 │ LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x| { + │ ╭──────────────────────────────────────────────────────────────^ +40 │ │ LambdaTest1::inline_apply(|y|y, x) +41 │ │ }, + │ ╰─────────^ + +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. + ┌─ tests/lambda/inline-parity/lambda.move:54:29 + │ +54 │ LambdaTest2::inline_apply2(|x| x + 1, 3) + + │ ^^^^^^^^^ +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. + ┌─ tests/lambda/inline-parity/lambda.move:55:29 + │ +55 │ LambdaTest2::inline_apply2(|x| x * x, inline_apply(|y|y, 3)) + │ ^^^^^^^^^ -Diagnostics: -error: captured variable `product` cannot be modified inside of a lambda - ┌─ tests/lambda/inline-parity/lambda.move:30:18 +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. + ┌─ tests/lambda/inline-parity/lambda.move:55:53 │ -30 │ foreach(&v, |e| product = LambdaTest1::inline_mul(product, *e)); - │ ^^^^^^^ +55 │ LambdaTest2::inline_apply2(|x| x * x, inline_apply(|y|y, 3)) + │ ^^^^ diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/lambda_cast.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/lambda_cast.lambda.exp index cc4db35759051..6e2d5443ef82b 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/lambda_cast.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/lambda_cast.lambda.exp @@ -1,441 +1,19 @@ -// -- Model dump before env processor pipeline: -module 0x12391283::M { - use std::vector; - private fun test_1(): u64 { - { - let gas_schedule_blob: vector = Vector(115, 115, 95, 112, 97, 99, 107, 101, 100, 32, 0, 0, 0, 0, 0, 0, 0); - M::vector_fold(gas_schedule_blob, Cast(0), |(sum: u64, addend: u8): (u64, u8)| Add(sum, Cast(addend))) - } - } - private fun test_2(): u64 { - { - let gas_schedule_blob: vector = Vector(115, 115, 95, 112, 97, 99, 107, 101, 100, 32, 0, 0, 0, 0, 0, 0, 0); - M::vector_fold(gas_schedule_blob, Cast(0), |(sum: u64, addend: u8): (u64, u8)| Add(sum, Cast(addend))) - } - } - private fun vector_fold(v: vector,init: Accumulator,f: |(Accumulator, Element)|Accumulator): Accumulator { - { - let accu: Accumulator = init; - M::vector_for_each(v, |elem: Element| accu: Accumulator = (f)(accu, elem)); - accu - } - } - private fun vector_for_each(v: vector,f: |Element|) { - vector::reverse(Borrow(Mutable)(v)); - loop { - if Not(vector::is_empty(Borrow(Immutable)(v))) { - { - let e: Element = vector::pop_back(Borrow(Mutable)(v)); - (f)(e); - Tuple() - } - } else { - break - } - }; - Tuple() - } -} // end 0x12391283::M - - -// -- Model dump after env processor unused checks: -module 0x12391283::M { - use std::vector; - private fun test_1(): u64 { - { - let gas_schedule_blob: vector = Vector(115, 115, 95, 112, 97, 99, 107, 101, 100, 32, 0, 0, 0, 0, 0, 0, 0); - M::vector_fold(gas_schedule_blob, Cast(0), |(sum: u64, addend: u8): (u64, u8)| Add(sum, Cast(addend))) - } - } - private fun test_2(): u64 { - { - let gas_schedule_blob: vector = Vector(115, 115, 95, 112, 97, 99, 107, 101, 100, 32, 0, 0, 0, 0, 0, 0, 0); - M::vector_fold(gas_schedule_blob, Cast(0), |(sum: u64, addend: u8): (u64, u8)| Add(sum, Cast(addend))) - } - } - private fun vector_fold(v: vector,init: Accumulator,f: |(Accumulator, Element)|Accumulator): Accumulator { - { - let accu: Accumulator = init; - M::vector_for_each(v, |elem: Element| accu: Accumulator = (f)(accu, elem)); - accu - } - } - private fun vector_for_each(v: vector,f: |Element|) { - vector::reverse(Borrow(Mutable)(v)); - loop { - if Not(vector::is_empty(Borrow(Immutable)(v))) { - { - let e: Element = vector::pop_back(Borrow(Mutable)(v)); - (f)(e); - Tuple() - } - } else { - break - } - }; - Tuple() - } -} // end 0x12391283::M - - -// -- Model dump after env processor type parameter check: -module 0x12391283::M { - use std::vector; - private fun test_1(): u64 { - { - let gas_schedule_blob: vector = Vector(115, 115, 95, 112, 97, 99, 107, 101, 100, 32, 0, 0, 0, 0, 0, 0, 0); - M::vector_fold(gas_schedule_blob, Cast(0), |(sum: u64, addend: u8): (u64, u8)| Add(sum, Cast(addend))) - } - } - private fun test_2(): u64 { - { - let gas_schedule_blob: vector = Vector(115, 115, 95, 112, 97, 99, 107, 101, 100, 32, 0, 0, 0, 0, 0, 0, 0); - M::vector_fold(gas_schedule_blob, Cast(0), |(sum: u64, addend: u8): (u64, u8)| Add(sum, Cast(addend))) - } - } - private fun vector_fold(v: vector,init: Accumulator,f: |(Accumulator, Element)|Accumulator): Accumulator { - { - let accu: Accumulator = init; - M::vector_for_each(v, |elem: Element| accu: Accumulator = (f)(accu, elem)); - accu - } - } - private fun vector_for_each(v: vector,f: |Element|) { - vector::reverse(Borrow(Mutable)(v)); - loop { - if Not(vector::is_empty(Borrow(Immutable)(v))) { - { - let e: Element = vector::pop_back(Borrow(Mutable)(v)); - (f)(e); - Tuple() - } - } else { - break - } - }; - Tuple() - } -} // end 0x12391283::M - - -// -- Model dump after env processor check recursive struct definition: -module 0x12391283::M { - use std::vector; - private fun test_1(): u64 { - { - let gas_schedule_blob: vector = Vector(115, 115, 95, 112, 97, 99, 107, 101, 100, 32, 0, 0, 0, 0, 0, 0, 0); - M::vector_fold(gas_schedule_blob, Cast(0), |(sum: u64, addend: u8): (u64, u8)| Add(sum, Cast(addend))) - } - } - private fun test_2(): u64 { - { - let gas_schedule_blob: vector = Vector(115, 115, 95, 112, 97, 99, 107, 101, 100, 32, 0, 0, 0, 0, 0, 0, 0); - M::vector_fold(gas_schedule_blob, Cast(0), |(sum: u64, addend: u8): (u64, u8)| Add(sum, Cast(addend))) - } - } - private fun vector_fold(v: vector,init: Accumulator,f: |(Accumulator, Element)|Accumulator): Accumulator { - { - let accu: Accumulator = init; - M::vector_for_each(v, |elem: Element| accu: Accumulator = (f)(accu, elem)); - accu - } - } - private fun vector_for_each(v: vector,f: |Element|) { - vector::reverse(Borrow(Mutable)(v)); - loop { - if Not(vector::is_empty(Borrow(Immutable)(v))) { - { - let e: Element = vector::pop_back(Borrow(Mutable)(v)); - (f)(e); - Tuple() - } - } else { - break - } - }; - Tuple() - } -} // end 0x12391283::M - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x12391283::M { - use std::vector; - private fun test_1(): u64 { - { - let gas_schedule_blob: vector = Vector(115, 115, 95, 112, 97, 99, 107, 101, 100, 32, 0, 0, 0, 0, 0, 0, 0); - M::vector_fold(gas_schedule_blob, Cast(0), |(sum: u64, addend: u8): (u64, u8)| Add(sum, Cast(addend))) - } - } - private fun test_2(): u64 { - { - let gas_schedule_blob: vector = Vector(115, 115, 95, 112, 97, 99, 107, 101, 100, 32, 0, 0, 0, 0, 0, 0, 0); - M::vector_fold(gas_schedule_blob, Cast(0), |(sum: u64, addend: u8): (u64, u8)| Add(sum, Cast(addend))) - } - } - private fun vector_fold(v: vector,init: Accumulator,f: |(Accumulator, Element)|Accumulator): Accumulator { - { - let accu: Accumulator = init; - M::vector_for_each(v, |elem: Element| accu: Accumulator = (f)(accu, elem)); - accu - } - } - private fun vector_for_each(v: vector,f: |Element|) { - vector::reverse(Borrow(Mutable)(v)); - loop { - if Not(vector::is_empty(Borrow(Immutable)(v))) { - { - let e: Element = vector::pop_back(Borrow(Mutable)(v)); - (f)(e); - Tuple() - } - } else { - break - } - }; - Tuple() - } -} // end 0x12391283::M - - -// -- Model dump after env processor unused struct params check: -module 0x12391283::M { - use std::vector; - private fun test_1(): u64 { - { - let gas_schedule_blob: vector = Vector(115, 115, 95, 112, 97, 99, 107, 101, 100, 32, 0, 0, 0, 0, 0, 0, 0); - M::vector_fold(gas_schedule_blob, Cast(0), |(sum: u64, addend: u8): (u64, u8)| Add(sum, Cast(addend))) - } - } - private fun test_2(): u64 { - { - let gas_schedule_blob: vector = Vector(115, 115, 95, 112, 97, 99, 107, 101, 100, 32, 0, 0, 0, 0, 0, 0, 0); - M::vector_fold(gas_schedule_blob, Cast(0), |(sum: u64, addend: u8): (u64, u8)| Add(sum, Cast(addend))) - } - } - private fun vector_fold(v: vector,init: Accumulator,f: |(Accumulator, Element)|Accumulator): Accumulator { - { - let accu: Accumulator = init; - M::vector_for_each(v, |elem: Element| accu: Accumulator = (f)(accu, elem)); - accu - } - } - private fun vector_for_each(v: vector,f: |Element|) { - vector::reverse(Borrow(Mutable)(v)); - loop { - if Not(vector::is_empty(Borrow(Immutable)(v))) { - { - let e: Element = vector::pop_back(Borrow(Mutable)(v)); - (f)(e); - Tuple() - } - } else { - break - } - }; - Tuple() - } -} // end 0x12391283::M - - -// -- Model dump after env processor access and use check before inlining: -module 0x12391283::M { - use std::vector; - private fun test_1(): u64 { - { - let gas_schedule_blob: vector = Vector(115, 115, 95, 112, 97, 99, 107, 101, 100, 32, 0, 0, 0, 0, 0, 0, 0); - M::vector_fold(gas_schedule_blob, Cast(0), |(sum: u64, addend: u8): (u64, u8)| Add(sum, Cast(addend))) - } - } - private fun test_2(): u64 { - { - let gas_schedule_blob: vector = Vector(115, 115, 95, 112, 97, 99, 107, 101, 100, 32, 0, 0, 0, 0, 0, 0, 0); - M::vector_fold(gas_schedule_blob, Cast(0), |(sum: u64, addend: u8): (u64, u8)| Add(sum, Cast(addend))) - } - } - private fun vector_fold(v: vector,init: Accumulator,f: |(Accumulator, Element)|Accumulator): Accumulator { - { - let accu: Accumulator = init; - M::vector_for_each(v, |elem: Element| accu: Accumulator = (f)(accu, elem)); - accu - } - } - private fun vector_for_each(v: vector,f: |Element|) { - vector::reverse(Borrow(Mutable)(v)); - loop { - if Not(vector::is_empty(Borrow(Immutable)(v))) { - { - let e: Element = vector::pop_back(Borrow(Mutable)(v)); - (f)(e); - Tuple() - } - } else { - break - } - }; - Tuple() - } -} // end 0x12391283::M - - -// -- Model dump after env processor inlining: -module 0x12391283::M { - use std::vector; - private fun test_1(): u64 { - { - let gas_schedule_blob: vector = Vector(115, 115, 95, 112, 97, 99, 107, 101, 100, 32, 0, 0, 0, 0, 0, 0, 0); - M::vector_fold(gas_schedule_blob, Cast(0), |(sum: u64, addend: u8): (u64, u8)| Add(sum, Cast(addend))) - } - } - private fun test_2(): u64 { - { - let gas_schedule_blob: vector = Vector(115, 115, 95, 112, 97, 99, 107, 101, 100, 32, 0, 0, 0, 0, 0, 0, 0); - M::vector_fold(gas_schedule_blob, Cast(0), |(sum: u64, addend: u8): (u64, u8)| Add(sum, Cast(addend))) - } - } - private fun vector_fold(v: vector,init: Accumulator,f: |(Accumulator, Element)|Accumulator): Accumulator { - { - let accu: Accumulator = init; - M::vector_for_each(v, |elem: Element| accu: Accumulator = (f)(accu, elem)); - accu - } - } - private fun vector_for_each(v: vector,f: |Element|) { - vector::reverse(Borrow(Mutable)(v)); - loop { - if Not(vector::is_empty(Borrow(Immutable)(v))) { - { - let e: Element = vector::pop_back(Borrow(Mutable)(v)); - (f)(e); - Tuple() - } - } else { - break - } - }; - Tuple() - } -} // end 0x12391283::M - - -// -- Model dump after env processor access and use check after inlining: -module 0x12391283::M { - use std::vector; - private fun test_1(): u64 { - { - let gas_schedule_blob: vector = Vector(115, 115, 95, 112, 97, 99, 107, 101, 100, 32, 0, 0, 0, 0, 0, 0, 0); - M::vector_fold(gas_schedule_blob, Cast(0), |(sum: u64, addend: u8): (u64, u8)| Add(sum, Cast(addend))) - } - } - private fun test_2(): u64 { - { - let gas_schedule_blob: vector = Vector(115, 115, 95, 112, 97, 99, 107, 101, 100, 32, 0, 0, 0, 0, 0, 0, 0); - M::vector_fold(gas_schedule_blob, Cast(0), |(sum: u64, addend: u8): (u64, u8)| Add(sum, Cast(addend))) - } - } - private fun vector_fold(v: vector,init: Accumulator,f: |(Accumulator, Element)|Accumulator): Accumulator { - { - let accu: Accumulator = init; - M::vector_for_each(v, |elem: Element| accu: Accumulator = (f)(accu, elem)); - accu - } - } - private fun vector_for_each(v: vector,f: |Element|) { - vector::reverse(Borrow(Mutable)(v)); - loop { - if Not(vector::is_empty(Borrow(Immutable)(v))) { - { - let e: Element = vector::pop_back(Borrow(Mutable)(v)); - (f)(e); - Tuple() - } - } else { - break - } - }; - Tuple() - } -} // end 0x12391283::M - - -// -- Model dump after env processor acquires check: -module 0x12391283::M { - use std::vector; - private fun test_1(): u64 { - { - let gas_schedule_blob: vector = Vector(115, 115, 95, 112, 97, 99, 107, 101, 100, 32, 0, 0, 0, 0, 0, 0, 0); - M::vector_fold(gas_schedule_blob, Cast(0), |(sum: u64, addend: u8): (u64, u8)| Add(sum, Cast(addend))) - } - } - private fun test_2(): u64 { - { - let gas_schedule_blob: vector = Vector(115, 115, 95, 112, 97, 99, 107, 101, 100, 32, 0, 0, 0, 0, 0, 0, 0); - M::vector_fold(gas_schedule_blob, Cast(0), |(sum: u64, addend: u8): (u64, u8)| Add(sum, Cast(addend))) - } - } - private fun vector_fold(v: vector,init: Accumulator,f: |(Accumulator, Element)|Accumulator): Accumulator { - { - let accu: Accumulator = init; - M::vector_for_each(v, |elem: Element| accu: Accumulator = (f)(accu, elem)); - accu - } - } - private fun vector_for_each(v: vector,f: |Element|) { - vector::reverse(Borrow(Mutable)(v)); - loop { - if Not(vector::is_empty(Borrow(Immutable)(v))) { - { - let e: Element = vector::pop_back(Borrow(Mutable)(v)); - (f)(e); - Tuple() - } - } else { - break - } - }; - Tuple() - } -} // end 0x12391283::M - - -// -- Model dump after env processor simplifier: -module 0x12391283::M { - use std::vector; - private fun test_1(): u64 { - M::vector_fold([Number(115), Number(115), Number(95), Number(112), Number(97), Number(99), Number(107), Number(101), Number(100), Number(32), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0)], 0, |(sum: u64, addend: u8): (u64, u8)| Add(sum, Cast(addend))) - } - private fun test_2(): u64 { - M::vector_fold([Number(115), Number(115), Number(95), Number(112), Number(97), Number(99), Number(107), Number(101), Number(100), Number(32), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0), Number(0)], 0, |(sum: u64, addend: u8): (u64, u8)| Add(sum, Cast(addend))) - } - private fun vector_fold(v: vector,init: Accumulator,f: |(Accumulator, Element)|Accumulator): Accumulator { - { - let accu: Accumulator = init; - M::vector_for_each(v, |elem: Element| accu: Accumulator = (f)(accu, elem)); - accu - } - } - private fun vector_for_each(v: vector,f: |Element|) { - vector::reverse(Borrow(Mutable)(v)); - loop { - if Not(vector::is_empty(Borrow(Immutable)(v))) { - { - let e: Element = vector::pop_back(Borrow(Mutable)(v)); - (f)(e); - Tuple() - } - } else { - break - } - }; - Tuple() - } -} // end 0x12391283::M - - Diagnostics: -error: captured variable `accu` cannot be modified inside of a lambda - ┌─ tests/lambda/inline-parity/lambda_cast.move:18:35 +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. + ┌─ tests/lambda/inline-parity/lambda_cast.move:18:28 │ 18 │ vector_for_each(v, |elem| accu = f(accu, elem)); - │ ^^^^ + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. + ┌─ tests/lambda/inline-parity/lambda_cast.move:26:61 + │ +26 │ vector_fold(gas_schedule_blob, (0 as u64), |sum, addend| sum + (addend as u64)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. + ┌─ tests/lambda/inline-parity/lambda_cast.move:33:52 + │ +33 │ vector_fold(gas_schedule_blob, (0 as u64), |sum, addend| sum + (addend as u64)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/lambda_no_param.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/lambda_no_param.lambda.exp index eb23c97b263b2..979eb06b386bf 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/lambda_no_param.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/lambda_no_param.lambda.exp @@ -1,308 +1,12 @@ -// -- Model dump before env processor pipeline: -module 0xdecafbad::m { - private fun bar(f: |()|u64): u64 { - (f)() - } - private fun foo(f: |()|) { - (f)(); - Tuple() - } - public fun one() { - m::foo(|(): ()| Tuple()); - Tuple() - } - public fun two(x: u64): u64 { - m::bar(|(): ()| x) - } -} // end 0xdecafbad::m - - -// -- Model dump after env processor unused checks: -module 0xdecafbad::m { - private fun bar(f: |()|u64): u64 { - (f)() - } - private fun foo(f: |()|) { - (f)(); - Tuple() - } - public fun one() { - m::foo(|(): ()| Tuple()); - Tuple() - } - public fun two(x: u64): u64 { - m::bar(|(): ()| x) - } -} // end 0xdecafbad::m - - -// -- Model dump after env processor type parameter check: -module 0xdecafbad::m { - private fun bar(f: |()|u64): u64 { - (f)() - } - private fun foo(f: |()|) { - (f)(); - Tuple() - } - public fun one() { - m::foo(|(): ()| Tuple()); - Tuple() - } - public fun two(x: u64): u64 { - m::bar(|(): ()| x) - } -} // end 0xdecafbad::m - - -// -- Model dump after env processor check recursive struct definition: -module 0xdecafbad::m { - private fun bar(f: |()|u64): u64 { - (f)() - } - private fun foo(f: |()|) { - (f)(); - Tuple() - } - public fun one() { - m::foo(|(): ()| Tuple()); - Tuple() - } - public fun two(x: u64): u64 { - m::bar(|(): ()| x) - } -} // end 0xdecafbad::m - - -// -- Model dump after env processor check cyclic type instantiation: -module 0xdecafbad::m { - private fun bar(f: |()|u64): u64 { - (f)() - } - private fun foo(f: |()|) { - (f)(); - Tuple() - } - public fun one() { - m::foo(|(): ()| Tuple()); - Tuple() - } - public fun two(x: u64): u64 { - m::bar(|(): ()| x) - } -} // end 0xdecafbad::m - - -// -- Model dump after env processor unused struct params check: -module 0xdecafbad::m { - private fun bar(f: |()|u64): u64 { - (f)() - } - private fun foo(f: |()|) { - (f)(); - Tuple() - } - public fun one() { - m::foo(|(): ()| Tuple()); - Tuple() - } - public fun two(x: u64): u64 { - m::bar(|(): ()| x) - } -} // end 0xdecafbad::m - - -// -- Model dump after env processor access and use check before inlining: -module 0xdecafbad::m { - private fun bar(f: |()|u64): u64 { - (f)() - } - private fun foo(f: |()|) { - (f)(); - Tuple() - } - public fun one() { - m::foo(|(): ()| Tuple()); - Tuple() - } - public fun two(x: u64): u64 { - m::bar(|(): ()| x) - } -} // end 0xdecafbad::m - - -// -- Model dump after env processor inlining: -module 0xdecafbad::m { - private fun bar(f: |()|u64): u64 { - (f)() - } - private fun foo(f: |()|) { - (f)(); - Tuple() - } - public fun one() { - m::foo(|(): ()| Tuple()); - Tuple() - } - public fun two(x: u64): u64 { - m::bar(|(): ()| x) - } -} // end 0xdecafbad::m - - -// -- Model dump after env processor access and use check after inlining: -module 0xdecafbad::m { - private fun bar(f: |()|u64): u64 { - (f)() - } - private fun foo(f: |()|) { - (f)(); - Tuple() - } - public fun one() { - m::foo(|(): ()| Tuple()); - Tuple() - } - public fun two(x: u64): u64 { - m::bar(|(): ()| x) - } -} // end 0xdecafbad::m - - -// -- Model dump after env processor acquires check: -module 0xdecafbad::m { - private fun bar(f: |()|u64): u64 { - (f)() - } - private fun foo(f: |()|) { - (f)(); - Tuple() - } - public fun one() { - m::foo(|(): ()| Tuple()); - Tuple() - } - public fun two(x: u64): u64 { - m::bar(|(): ()| x) - } -} // end 0xdecafbad::m - - -// -- Model dump after env processor simplifier: -module 0xdecafbad::m { - private fun bar(f: |()|u64): u64 { - (f)() - } - private fun foo(f: |()|) { - (f)(); - Tuple() - } - public fun one() { - m::foo(|(): ()| Tuple()); - Tuple() - } - public fun two(x: u64): u64 { - m::bar(|(): ()| x) - } -} // end 0xdecafbad::m - - -// -- Model dump after env processor lambda-lifting: -module 0xdecafbad::m { - private fun bar(f: |()|u64): u64 { - (f)() - } - private fun foo(f: |()|) { - (f)(); - Tuple() - } - public fun one() { - m::foo(closure m::one$lambda$1()); - Tuple() - } - public fun two(x: u64): u64 { - m::bar(closure m::two$lambda$1(x)) - } - private fun one$lambda$1() { - Tuple() - } - private fun two$lambda$1(x: u64): u64 { - x - } -} // end 0xdecafbad::m - - -// -- Model dump after env processor specification checker: -module 0xdecafbad::m { - private fun bar(f: |()|u64): u64 { - (f)() - } - private fun foo(f: |()|) { - (f)(); - Tuple() - } - public fun one() { - m::foo(closure m::one$lambda$1()); - Tuple() - } - public fun two(x: u64): u64 { - m::bar(closure m::two$lambda$1(x)) - } - private fun one$lambda$1() { - Tuple() - } - private fun two$lambda$1(x: u64): u64 { - x - } -} // end 0xdecafbad::m - - -// -- Model dump after env processor specification rewriter: -module 0xdecafbad::m { - private fun bar(f: |()|u64): u64 { - (f)() - } - private fun foo(f: |()|) { - (f)(); - Tuple() - } - public fun one() { - m::foo(closure m::one$lambda$1()); - Tuple() - } - public fun two(x: u64): u64 { - m::bar(closure m::two$lambda$1(x)) - } - private fun one$lambda$1() { - Tuple() - } - private fun two$lambda$1(x: u64): u64 { - x - } -} // end 0xdecafbad::m - - Diagnostics: -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda/inline-parity/lambda_no_param.move:3:9 - │ -3 │ f(); - │ ^ - -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/lambda_no_param.move:7:13 │ 7 │ foo(|| {}); │ ^^^^^ -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda/inline-parity/lambda_no_param.move:11:9 - │ -11 │ f() - │ ^ - -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/lambda_no_param.move:15:13 │ 15 │ bar(||x) diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/lambda_param.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/lambda_param.lambda.exp index b3587c0f077ef..de65d3dcdf029 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/lambda_param.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/lambda_param.lambda.exp @@ -1,836 +1,24 @@ -// -- Model dump before env processor pipeline: -module 0x42::LambdaParam { - public fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public fun inline_apply2(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply(f, b) - } - public fun inline_apply3(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply4(f, b) - } - public fun inline_apply4(_f: |u64|u64,b: u64): u64 { - b - } - private fun test_lambda_symbol_param1() { - { - let a: u64 = LambdaParam::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - private fun test_lambda_symbol_param2() { - { - let a: u64 = LambdaParam::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply(|x: u64| x, 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply3(|x: u64| x, 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - } - } -} // end 0x42::LambdaParam - - -// -- Model dump after env processor unused checks: -module 0x42::LambdaParam { - public fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public fun inline_apply2(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply(f, b) - } - public fun inline_apply3(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply4(f, b) - } - public fun inline_apply4(_f: |u64|u64,b: u64): u64 { - b - } - private fun test_lambda_symbol_param1() { - { - let a: u64 = LambdaParam::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - private fun test_lambda_symbol_param2() { - { - let a: u64 = LambdaParam::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply(|x: u64| x, 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply3(|x: u64| x, 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - } - } -} // end 0x42::LambdaParam - - -// -- Model dump after env processor type parameter check: -module 0x42::LambdaParam { - public fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public fun inline_apply2(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply(f, b) - } - public fun inline_apply3(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply4(f, b) - } - public fun inline_apply4(_f: |u64|u64,b: u64): u64 { - b - } - private fun test_lambda_symbol_param1() { - { - let a: u64 = LambdaParam::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - private fun test_lambda_symbol_param2() { - { - let a: u64 = LambdaParam::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply(|x: u64| x, 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply3(|x: u64| x, 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - } - } -} // end 0x42::LambdaParam - - -// -- Model dump after env processor check recursive struct definition: -module 0x42::LambdaParam { - public fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public fun inline_apply2(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply(f, b) - } - public fun inline_apply3(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply4(f, b) - } - public fun inline_apply4(_f: |u64|u64,b: u64): u64 { - b - } - private fun test_lambda_symbol_param1() { - { - let a: u64 = LambdaParam::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - private fun test_lambda_symbol_param2() { - { - let a: u64 = LambdaParam::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply(|x: u64| x, 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply3(|x: u64| x, 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - } - } -} // end 0x42::LambdaParam - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x42::LambdaParam { - public fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public fun inline_apply2(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply(f, b) - } - public fun inline_apply3(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply4(f, b) - } - public fun inline_apply4(_f: |u64|u64,b: u64): u64 { - b - } - private fun test_lambda_symbol_param1() { - { - let a: u64 = LambdaParam::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - private fun test_lambda_symbol_param2() { - { - let a: u64 = LambdaParam::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply(|x: u64| x, 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply3(|x: u64| x, 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - } - } -} // end 0x42::LambdaParam - - -// -- Model dump after env processor unused struct params check: -module 0x42::LambdaParam { - public fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public fun inline_apply2(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply(f, b) - } - public fun inline_apply3(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply4(f, b) - } - public fun inline_apply4(_f: |u64|u64,b: u64): u64 { - b - } - private fun test_lambda_symbol_param1() { - { - let a: u64 = LambdaParam::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - private fun test_lambda_symbol_param2() { - { - let a: u64 = LambdaParam::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply(|x: u64| x, 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply3(|x: u64| x, 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - } - } -} // end 0x42::LambdaParam - - -// -- Model dump after env processor access and use check before inlining: -module 0x42::LambdaParam { - public fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public fun inline_apply2(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply(f, b) - } - public fun inline_apply3(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply4(f, b) - } - public fun inline_apply4(_f: |u64|u64,b: u64): u64 { - b - } - private fun test_lambda_symbol_param1() { - { - let a: u64 = LambdaParam::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - private fun test_lambda_symbol_param2() { - { - let a: u64 = LambdaParam::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply(|x: u64| x, 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply3(|x: u64| x, 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - } - } -} // end 0x42::LambdaParam - - -// -- Model dump after env processor inlining: -module 0x42::LambdaParam { - public fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public fun inline_apply2(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply(f, b) - } - public fun inline_apply3(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply4(f, b) - } - public fun inline_apply4(_f: |u64|u64,b: u64): u64 { - b - } - private fun test_lambda_symbol_param1() { - { - let a: u64 = LambdaParam::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - private fun test_lambda_symbol_param2() { - { - let a: u64 = LambdaParam::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply(|x: u64| x, 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply3(|x: u64| x, 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - } - } -} // end 0x42::LambdaParam - - -// -- Model dump after env processor access and use check after inlining: -module 0x42::LambdaParam { - public fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public fun inline_apply2(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply(f, b) - } - public fun inline_apply3(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply4(f, b) - } - public fun inline_apply4(_f: |u64|u64,b: u64): u64 { - b - } - private fun test_lambda_symbol_param1() { - { - let a: u64 = LambdaParam::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - private fun test_lambda_symbol_param2() { - { - let a: u64 = LambdaParam::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply(|x: u64| x, 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply3(|x: u64| x, 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - } - } -} // end 0x42::LambdaParam - - -// -- Model dump after env processor acquires check: -module 0x42::LambdaParam { - public fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public fun inline_apply2(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply(f, b) - } - public fun inline_apply3(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply4(f, b) - } - public fun inline_apply4(_f: |u64|u64,b: u64): u64 { - b - } - private fun test_lambda_symbol_param1() { - { - let a: u64 = LambdaParam::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - private fun test_lambda_symbol_param2() { - { - let a: u64 = LambdaParam::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply(|x: u64| x, 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply3(|x: u64| x, 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - } - } -} // end 0x42::LambdaParam - - -// -- Model dump after env processor simplifier: -module 0x42::LambdaParam { - public fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public fun inline_apply2(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply(f, b) - } - public fun inline_apply3(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply4(f, b) - } - public fun inline_apply4(_f: |u64|u64,b: u64): u64 { - b - } - private fun test_lambda_symbol_param1() { - { - let a: u64 = LambdaParam::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - private fun test_lambda_symbol_param2() { - { - let a: u64 = LambdaParam::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply(|x: u64| x, 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply3(|x: u64| x, 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - } - } -} // end 0x42::LambdaParam - - -// -- Model dump after env processor lambda-lifting: -module 0x42::LambdaParam { - public fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public fun inline_apply2(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply(f, b) - } - public fun inline_apply3(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply4(f, b) - } - public fun inline_apply4(_f: |u64|u64,b: u64): u64 { - b - } - private fun test_lambda_symbol_param1() { - { - let a: u64 = LambdaParam::inline_apply2(closure LambdaParam::test_lambda_symbol_param1$lambda$1(), 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - private fun test_lambda_symbol_param2() { - { - let a: u64 = LambdaParam::inline_apply2(closure LambdaParam::test_lambda_symbol_param2$lambda$1(), 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply(closure LambdaParam::test_lambda_symbol_param2$lambda$2(), 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply3(closure LambdaParam::test_lambda_symbol_param2$lambda$3(), 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - } - } - private fun test_lambda_symbol_param1$lambda$1(x: u64): u64 { - x - } - private fun test_lambda_symbol_param2$lambda$1(x: u64): u64 { - x - } - private fun test_lambda_symbol_param2$lambda$2(x: u64): u64 { - x - } - private fun test_lambda_symbol_param2$lambda$3(x: u64): u64 { - x - } -} // end 0x42::LambdaParam - - -// -- Model dump after env processor specification checker: -module 0x42::LambdaParam { - public fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public fun inline_apply2(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply(f, b) - } - public fun inline_apply3(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply4(f, b) - } - public fun inline_apply4(_f: |u64|u64,b: u64): u64 { - b - } - private fun test_lambda_symbol_param1() { - { - let a: u64 = LambdaParam::inline_apply2(closure LambdaParam::test_lambda_symbol_param1$lambda$1(), 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - private fun test_lambda_symbol_param2() { - { - let a: u64 = LambdaParam::inline_apply2(closure LambdaParam::test_lambda_symbol_param2$lambda$1(), 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply(closure LambdaParam::test_lambda_symbol_param2$lambda$2(), 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply3(closure LambdaParam::test_lambda_symbol_param2$lambda$3(), 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - } - } - private fun test_lambda_symbol_param1$lambda$1(x: u64): u64 { - x - } - private fun test_lambda_symbol_param2$lambda$1(x: u64): u64 { - x - } - private fun test_lambda_symbol_param2$lambda$2(x: u64): u64 { - x - } - private fun test_lambda_symbol_param2$lambda$3(x: u64): u64 { - x - } -} // end 0x42::LambdaParam - - -// -- Model dump after env processor specification rewriter: -module 0x42::LambdaParam { - public fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public fun inline_apply2(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply(f, b) - } - public fun inline_apply3(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply4(f, b) - } - public fun inline_apply4(_f: |u64|u64,b: u64): u64 { - b - } - private fun test_lambda_symbol_param1() { - { - let a: u64 = LambdaParam::inline_apply2(closure LambdaParam::test_lambda_symbol_param1$lambda$1(), 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - private fun test_lambda_symbol_param2() { - { - let a: u64 = LambdaParam::inline_apply2(closure LambdaParam::test_lambda_symbol_param2$lambda$1(), 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply(closure LambdaParam::test_lambda_symbol_param2$lambda$2(), 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply3(closure LambdaParam::test_lambda_symbol_param2$lambda$3(), 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - } - } - private fun test_lambda_symbol_param1$lambda$1(x: u64): u64 { - x - } - private fun test_lambda_symbol_param2$lambda$1(x: u64): u64 { - x - } - private fun test_lambda_symbol_param2$lambda$2(x: u64): u64 { - x - } - private fun test_lambda_symbol_param2$lambda$3(x: u64): u64 { - x - } -} // end 0x42::LambdaParam - - Diagnostics: -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda/inline-parity/lambda_param.move:3:2 - │ -3 │ f(b) - │ ^ - -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/lambda_param.move:19:24 │ 19 │ let a = inline_apply2(|x| x, 3); │ ^^^^^ -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/lambda_param.move:24:24 │ 24 │ let a = inline_apply2(|x| x, 3); │ ^^^^^ -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/lambda_param.move:26:23 │ 26 │ let b = inline_apply(|x| x, 3); │ ^^^^^ -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/lambda_param.move:28:24 │ 28 │ let b = inline_apply3(|x| x, 3); diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/lambda_param_typed.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/lambda_param_typed.lambda.exp index 06d68ac437dd4..aa45b4ca4179f 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/lambda_param_typed.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/lambda_param_typed.lambda.exp @@ -1,388 +1,3 @@ -// -- Model dump before env processor pipeline: -module 0x42::LambdaParam { - public inline fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public inline fun inline_apply2(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply(f, b) - } - public inline fun inline_apply3(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply4(f, b) - } - public inline fun inline_apply4(_f: |u64|u64,b: u64): u64 { - b - } - private fun test_lambda_symbol_param1() { - { - let a: u64 = LambdaParam::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - private fun test_lambda_symbol_param2() { - { - let a: u64 = LambdaParam::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply(|x: u64| x, 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply3(|x: u64| x, 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - } - } -} // end 0x42::LambdaParam - - -// -- Model dump after env processor unused checks: -module 0x42::LambdaParam { - public inline fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public inline fun inline_apply2(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply(f, b) - } - public inline fun inline_apply3(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply4(f, b) - } - public inline fun inline_apply4(_f: |u64|u64,b: u64): u64 { - b - } - private fun test_lambda_symbol_param1() { - { - let a: u64 = LambdaParam::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - private fun test_lambda_symbol_param2() { - { - let a: u64 = LambdaParam::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply(|x: u64| x, 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply3(|x: u64| x, 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - } - } -} // end 0x42::LambdaParam - - -// -- Model dump after env processor type parameter check: -module 0x42::LambdaParam { - public inline fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public inline fun inline_apply2(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply(f, b) - } - public inline fun inline_apply3(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply4(f, b) - } - public inline fun inline_apply4(_f: |u64|u64,b: u64): u64 { - b - } - private fun test_lambda_symbol_param1() { - { - let a: u64 = LambdaParam::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - private fun test_lambda_symbol_param2() { - { - let a: u64 = LambdaParam::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply(|x: u64| x, 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply3(|x: u64| x, 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - } - } -} // end 0x42::LambdaParam - - -// -- Model dump after env processor check recursive struct definition: -module 0x42::LambdaParam { - public inline fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public inline fun inline_apply2(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply(f, b) - } - public inline fun inline_apply3(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply4(f, b) - } - public inline fun inline_apply4(_f: |u64|u64,b: u64): u64 { - b - } - private fun test_lambda_symbol_param1() { - { - let a: u64 = LambdaParam::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - private fun test_lambda_symbol_param2() { - { - let a: u64 = LambdaParam::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply(|x: u64| x, 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply3(|x: u64| x, 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - } - } -} // end 0x42::LambdaParam - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x42::LambdaParam { - public inline fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public inline fun inline_apply2(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply(f, b) - } - public inline fun inline_apply3(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply4(f, b) - } - public inline fun inline_apply4(_f: |u64|u64,b: u64): u64 { - b - } - private fun test_lambda_symbol_param1() { - { - let a: u64 = LambdaParam::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - private fun test_lambda_symbol_param2() { - { - let a: u64 = LambdaParam::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply(|x: u64| x, 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply3(|x: u64| x, 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - } - } -} // end 0x42::LambdaParam - - -// -- Model dump after env processor unused struct params check: -module 0x42::LambdaParam { - public inline fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public inline fun inline_apply2(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply(f, b) - } - public inline fun inline_apply3(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply4(f, b) - } - public inline fun inline_apply4(_f: |u64|u64,b: u64): u64 { - b - } - private fun test_lambda_symbol_param1() { - { - let a: u64 = LambdaParam::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - private fun test_lambda_symbol_param2() { - { - let a: u64 = LambdaParam::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply(|x: u64| x, 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply3(|x: u64| x, 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - } - } -} // end 0x42::LambdaParam - - -// -- Model dump after env processor access and use check before inlining: -module 0x42::LambdaParam { - public inline fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public inline fun inline_apply2(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply(f, b) - } - public inline fun inline_apply3(f: |u64|u64,b: u64): u64 { - LambdaParam::inline_apply4(f, b) - } - public inline fun inline_apply4(_f: |u64|u64,b: u64): u64 { - b - } - private fun test_lambda_symbol_param1() { - { - let a: u64 = LambdaParam::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - private fun test_lambda_symbol_param2() { - { - let a: u64 = LambdaParam::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply(|x: u64| x, 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - { - let b: u64 = LambdaParam::inline_apply3(|x: u64| x, 3); - if Eq(b, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - } - } -} // end 0x42::LambdaParam - - Diagnostics: error: Currently, a function-typed parameter to an inline function must be a literal lambda expression diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/lambda_return.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/lambda_return.lambda.exp index 2b9ffb4ba4160..04e1efb4090d1 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/lambda_return.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/lambda_return.lambda.exp @@ -1,287 +1,6 @@ -// -- Model dump before env processor pipeline: -module 0x42::LambdaReturn { - public fun inline_apply2(f: |u64|u64,b: u64): u64 { - return (f)(b) - } - private fun test_lambda_symbol_param() { - { - let a: u64 = LambdaReturn::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaReturn - - -// -- Model dump after env processor unused checks: -module 0x42::LambdaReturn { - public fun inline_apply2(f: |u64|u64,b: u64): u64 { - return (f)(b) - } - private fun test_lambda_symbol_param() { - { - let a: u64 = LambdaReturn::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaReturn - - -// -- Model dump after env processor type parameter check: -module 0x42::LambdaReturn { - public fun inline_apply2(f: |u64|u64,b: u64): u64 { - return (f)(b) - } - private fun test_lambda_symbol_param() { - { - let a: u64 = LambdaReturn::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaReturn - - -// -- Model dump after env processor check recursive struct definition: -module 0x42::LambdaReturn { - public fun inline_apply2(f: |u64|u64,b: u64): u64 { - return (f)(b) - } - private fun test_lambda_symbol_param() { - { - let a: u64 = LambdaReturn::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaReturn - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x42::LambdaReturn { - public fun inline_apply2(f: |u64|u64,b: u64): u64 { - return (f)(b) - } - private fun test_lambda_symbol_param() { - { - let a: u64 = LambdaReturn::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaReturn - - -// -- Model dump after env processor unused struct params check: -module 0x42::LambdaReturn { - public fun inline_apply2(f: |u64|u64,b: u64): u64 { - return (f)(b) - } - private fun test_lambda_symbol_param() { - { - let a: u64 = LambdaReturn::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaReturn - - -// -- Model dump after env processor access and use check before inlining: -module 0x42::LambdaReturn { - public fun inline_apply2(f: |u64|u64,b: u64): u64 { - return (f)(b) - } - private fun test_lambda_symbol_param() { - { - let a: u64 = LambdaReturn::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaReturn - - -// -- Model dump after env processor inlining: -module 0x42::LambdaReturn { - public fun inline_apply2(f: |u64|u64,b: u64): u64 { - return (f)(b) - } - private fun test_lambda_symbol_param() { - { - let a: u64 = LambdaReturn::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaReturn - - -// -- Model dump after env processor access and use check after inlining: -module 0x42::LambdaReturn { - public fun inline_apply2(f: |u64|u64,b: u64): u64 { - return (f)(b) - } - private fun test_lambda_symbol_param() { - { - let a: u64 = LambdaReturn::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaReturn - - -// -- Model dump after env processor acquires check: -module 0x42::LambdaReturn { - public fun inline_apply2(f: |u64|u64,b: u64): u64 { - return (f)(b) - } - private fun test_lambda_symbol_param() { - { - let a: u64 = LambdaReturn::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaReturn - - -// -- Model dump after env processor simplifier: -module 0x42::LambdaReturn { - public fun inline_apply2(f: |u64|u64,b: u64): u64 { - return (f)(b) - } - private fun test_lambda_symbol_param() { - { - let a: u64 = LambdaReturn::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaReturn - - -// -- Model dump after env processor lambda-lifting: -module 0x42::LambdaReturn { - public fun inline_apply2(f: |u64|u64,b: u64): u64 { - return (f)(b) - } - private fun test_lambda_symbol_param() { - { - let a: u64 = LambdaReturn::inline_apply2(closure LambdaReturn::test_lambda_symbol_param$lambda$1(), 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - private fun test_lambda_symbol_param$lambda$1(x: u64): u64 { - x - } -} // end 0x42::LambdaReturn - - -// -- Model dump after env processor specification checker: -module 0x42::LambdaReturn { - public fun inline_apply2(f: |u64|u64,b: u64): u64 { - return (f)(b) - } - private fun test_lambda_symbol_param() { - { - let a: u64 = LambdaReturn::inline_apply2(closure LambdaReturn::test_lambda_symbol_param$lambda$1(), 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - private fun test_lambda_symbol_param$lambda$1(x: u64): u64 { - x - } -} // end 0x42::LambdaReturn - - -// -- Model dump after env processor specification rewriter: -module 0x42::LambdaReturn { - public fun inline_apply2(f: |u64|u64,b: u64): u64 { - return (f)(b) - } - private fun test_lambda_symbol_param() { - { - let a: u64 = LambdaReturn::inline_apply2(closure LambdaReturn::test_lambda_symbol_param$lambda$1(), 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } - private fun test_lambda_symbol_param$lambda$1(x: u64): u64 { - x - } -} // end 0x42::LambdaReturn - - Diagnostics: -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda/inline-parity/lambda_return.move:3:9 - │ -3 │ return f(b) - │ ^ - -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/lambda_return.move:7:24 │ 7 │ let a = inline_apply2(|x| { x }, 3); diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/lambda_return_typed.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/lambda_return_typed.lambda.exp index 5fd4d9134b3d0..441eefbd8cb9c 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/lambda_return_typed.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/lambda_return_typed.lambda.exp @@ -1,136 +1,3 @@ -// -- Model dump before env processor pipeline: -module 0x42::LambdaReturn { - public inline fun inline_apply2(f: |u64|u64,b: u64): u64 { - return (f)(b) - } - private fun test_lambda_symbol_param() { - { - let a: u64 = LambdaReturn::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaReturn - - -// -- Model dump after env processor unused checks: -module 0x42::LambdaReturn { - public inline fun inline_apply2(f: |u64|u64,b: u64): u64 { - return (f)(b) - } - private fun test_lambda_symbol_param() { - { - let a: u64 = LambdaReturn::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaReturn - - -// -- Model dump after env processor type parameter check: -module 0x42::LambdaReturn { - public inline fun inline_apply2(f: |u64|u64,b: u64): u64 { - return (f)(b) - } - private fun test_lambda_symbol_param() { - { - let a: u64 = LambdaReturn::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaReturn - - -// -- Model dump after env processor check recursive struct definition: -module 0x42::LambdaReturn { - public inline fun inline_apply2(f: |u64|u64,b: u64): u64 { - return (f)(b) - } - private fun test_lambda_symbol_param() { - { - let a: u64 = LambdaReturn::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaReturn - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x42::LambdaReturn { - public inline fun inline_apply2(f: |u64|u64,b: u64): u64 { - return (f)(b) - } - private fun test_lambda_symbol_param() { - { - let a: u64 = LambdaReturn::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaReturn - - -// -- Model dump after env processor unused struct params check: -module 0x42::LambdaReturn { - public inline fun inline_apply2(f: |u64|u64,b: u64): u64 { - return (f)(b) - } - private fun test_lambda_symbol_param() { - { - let a: u64 = LambdaReturn::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaReturn - - -// -- Model dump after env processor access and use check before inlining: -module 0x42::LambdaReturn { - public inline fun inline_apply2(f: |u64|u64,b: u64): u64 { - return (f)(b) - } - private fun test_lambda_symbol_param() { - { - let a: u64 = LambdaReturn::inline_apply2(|x: u64| x, 3); - if Eq(a, 3) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaReturn - - Diagnostics: error: Return not currently supported in inline functions diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/lambda_typed.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/lambda_typed.lambda.exp index 396fdaf35ada9..395bb5cc485d0 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/lambda_typed.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/lambda_typed.lambda.exp @@ -1,1609 +1,16 @@ -// -- Model dump before env processor pipeline: -module 0x42::LambdaTest1 { - public inline fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public inline fun inline_apply1(f: |u64|u64,b: u64): u64 { - LambdaTest1::inline_mul(Add((f)(b), 1), LambdaTest1::inline_mul(3, 4)) - } - public inline fun inline_mul(a: u64,b: u64): u64 { - Mul(a, b) - } -} // end 0x42::LambdaTest1 -module 0x42::LambdaTest2 { - use 0x42::LambdaTest1; // resolved as: 0x42::LambdaTest1 - use std::vector; - public inline fun foreach(v: &vector,action: |&T|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - (action)(vector::borrow(v, i)); - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - } - public inline fun inline_apply2(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(|z: u64| z, (g)(LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| x, 3)))), 2) - } - public inline fun inline_apply3(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(g, LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| LambdaTest1::inline_apply(|y: u64| y, x), 3))), 4) - } - public fun test_inline_lambda() { - { - let v: vector = Vector(1, 2, 3); - { - let product: u64 = 1; - LambdaTest2::foreach(Borrow(Immutable)(v), |e: &u64| product: u64 = LambdaTest1::inline_mul(product, Deref(e))); - Tuple() - } - } - } -} // end 0x42::LambdaTest2 -module 0x42::LambdaTest { - use 0x42::LambdaTest2; // resolved as: 0x42::LambdaTest2 - public inline fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public inline fun inline_apply_test(): u64 { - Add(LambdaTest2::inline_apply2(|x: u64| Add(x, 1), 3), LambdaTest2::inline_apply2(|x: u64| Mul(x, x), LambdaTest::inline_apply(|y: u64| y, 3))) - } - private fun test_lambda() { - { - let a: u64 = LambdaTest::inline_apply_test(); - if Eq(a, 1) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaTest - - -// -- Model dump after env processor unused checks: -module 0x42::LambdaTest1 { - public inline fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public inline fun inline_apply1(f: |u64|u64,b: u64): u64 { - LambdaTest1::inline_mul(Add((f)(b), 1), LambdaTest1::inline_mul(3, 4)) - } - public inline fun inline_mul(a: u64,b: u64): u64 { - Mul(a, b) - } -} // end 0x42::LambdaTest1 -module 0x42::LambdaTest2 { - use 0x42::LambdaTest1; // resolved as: 0x42::LambdaTest1 - use std::vector; - public inline fun foreach(v: &vector,action: |&T|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - (action)(vector::borrow(v, i)); - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - } - public inline fun inline_apply2(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(|z: u64| z, (g)(LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| x, 3)))), 2) - } - public inline fun inline_apply3(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(g, LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| LambdaTest1::inline_apply(|y: u64| y, x), 3))), 4) - } - public fun test_inline_lambda() { - { - let v: vector = Vector(1, 2, 3); - { - let product: u64 = 1; - LambdaTest2::foreach(Borrow(Immutable)(v), |e: &u64| product: u64 = LambdaTest1::inline_mul(product, Deref(e))); - Tuple() - } - } - } -} // end 0x42::LambdaTest2 -module 0x42::LambdaTest { - use 0x42::LambdaTest2; // resolved as: 0x42::LambdaTest2 - public inline fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public inline fun inline_apply_test(): u64 { - Add(LambdaTest2::inline_apply2(|x: u64| Add(x, 1), 3), LambdaTest2::inline_apply2(|x: u64| Mul(x, x), LambdaTest::inline_apply(|y: u64| y, 3))) - } - private fun test_lambda() { - { - let a: u64 = LambdaTest::inline_apply_test(); - if Eq(a, 1) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaTest - - -// -- Model dump after env processor type parameter check: -module 0x42::LambdaTest1 { - public inline fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public inline fun inline_apply1(f: |u64|u64,b: u64): u64 { - LambdaTest1::inline_mul(Add((f)(b), 1), LambdaTest1::inline_mul(3, 4)) - } - public inline fun inline_mul(a: u64,b: u64): u64 { - Mul(a, b) - } -} // end 0x42::LambdaTest1 -module 0x42::LambdaTest2 { - use 0x42::LambdaTest1; // resolved as: 0x42::LambdaTest1 - use std::vector; - public inline fun foreach(v: &vector,action: |&T|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - (action)(vector::borrow(v, i)); - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - } - public inline fun inline_apply2(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(|z: u64| z, (g)(LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| x, 3)))), 2) - } - public inline fun inline_apply3(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(g, LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| LambdaTest1::inline_apply(|y: u64| y, x), 3))), 4) - } - public fun test_inline_lambda() { - { - let v: vector = Vector(1, 2, 3); - { - let product: u64 = 1; - LambdaTest2::foreach(Borrow(Immutable)(v), |e: &u64| product: u64 = LambdaTest1::inline_mul(product, Deref(e))); - Tuple() - } - } - } -} // end 0x42::LambdaTest2 -module 0x42::LambdaTest { - use 0x42::LambdaTest2; // resolved as: 0x42::LambdaTest2 - public inline fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public inline fun inline_apply_test(): u64 { - Add(LambdaTest2::inline_apply2(|x: u64| Add(x, 1), 3), LambdaTest2::inline_apply2(|x: u64| Mul(x, x), LambdaTest::inline_apply(|y: u64| y, 3))) - } - private fun test_lambda() { - { - let a: u64 = LambdaTest::inline_apply_test(); - if Eq(a, 1) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaTest - - -// -- Model dump after env processor check recursive struct definition: -module 0x42::LambdaTest1 { - public inline fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public inline fun inline_apply1(f: |u64|u64,b: u64): u64 { - LambdaTest1::inline_mul(Add((f)(b), 1), LambdaTest1::inline_mul(3, 4)) - } - public inline fun inline_mul(a: u64,b: u64): u64 { - Mul(a, b) - } -} // end 0x42::LambdaTest1 -module 0x42::LambdaTest2 { - use 0x42::LambdaTest1; // resolved as: 0x42::LambdaTest1 - use std::vector; - public inline fun foreach(v: &vector,action: |&T|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - (action)(vector::borrow(v, i)); - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - } - public inline fun inline_apply2(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(|z: u64| z, (g)(LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| x, 3)))), 2) - } - public inline fun inline_apply3(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(g, LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| LambdaTest1::inline_apply(|y: u64| y, x), 3))), 4) - } - public fun test_inline_lambda() { - { - let v: vector = Vector(1, 2, 3); - { - let product: u64 = 1; - LambdaTest2::foreach(Borrow(Immutable)(v), |e: &u64| product: u64 = LambdaTest1::inline_mul(product, Deref(e))); - Tuple() - } - } - } -} // end 0x42::LambdaTest2 -module 0x42::LambdaTest { - use 0x42::LambdaTest2; // resolved as: 0x42::LambdaTest2 - public inline fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public inline fun inline_apply_test(): u64 { - Add(LambdaTest2::inline_apply2(|x: u64| Add(x, 1), 3), LambdaTest2::inline_apply2(|x: u64| Mul(x, x), LambdaTest::inline_apply(|y: u64| y, 3))) - } - private fun test_lambda() { - { - let a: u64 = LambdaTest::inline_apply_test(); - if Eq(a, 1) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaTest - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x42::LambdaTest1 { - public inline fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public inline fun inline_apply1(f: |u64|u64,b: u64): u64 { - LambdaTest1::inline_mul(Add((f)(b), 1), LambdaTest1::inline_mul(3, 4)) - } - public inline fun inline_mul(a: u64,b: u64): u64 { - Mul(a, b) - } -} // end 0x42::LambdaTest1 -module 0x42::LambdaTest2 { - use 0x42::LambdaTest1; // resolved as: 0x42::LambdaTest1 - use std::vector; - public inline fun foreach(v: &vector,action: |&T|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - (action)(vector::borrow(v, i)); - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - } - public inline fun inline_apply2(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(|z: u64| z, (g)(LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| x, 3)))), 2) - } - public inline fun inline_apply3(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(g, LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| LambdaTest1::inline_apply(|y: u64| y, x), 3))), 4) - } - public fun test_inline_lambda() { - { - let v: vector = Vector(1, 2, 3); - { - let product: u64 = 1; - LambdaTest2::foreach(Borrow(Immutable)(v), |e: &u64| product: u64 = LambdaTest1::inline_mul(product, Deref(e))); - Tuple() - } - } - } -} // end 0x42::LambdaTest2 -module 0x42::LambdaTest { - use 0x42::LambdaTest2; // resolved as: 0x42::LambdaTest2 - public inline fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public inline fun inline_apply_test(): u64 { - Add(LambdaTest2::inline_apply2(|x: u64| Add(x, 1), 3), LambdaTest2::inline_apply2(|x: u64| Mul(x, x), LambdaTest::inline_apply(|y: u64| y, 3))) - } - private fun test_lambda() { - { - let a: u64 = LambdaTest::inline_apply_test(); - if Eq(a, 1) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaTest - - -// -- Model dump after env processor unused struct params check: -module 0x42::LambdaTest1 { - public inline fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public inline fun inline_apply1(f: |u64|u64,b: u64): u64 { - LambdaTest1::inline_mul(Add((f)(b), 1), LambdaTest1::inline_mul(3, 4)) - } - public inline fun inline_mul(a: u64,b: u64): u64 { - Mul(a, b) - } -} // end 0x42::LambdaTest1 -module 0x42::LambdaTest2 { - use 0x42::LambdaTest1; // resolved as: 0x42::LambdaTest1 - use std::vector; - public inline fun foreach(v: &vector,action: |&T|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - (action)(vector::borrow(v, i)); - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - } - public inline fun inline_apply2(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(|z: u64| z, (g)(LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| x, 3)))), 2) - } - public inline fun inline_apply3(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(g, LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| LambdaTest1::inline_apply(|y: u64| y, x), 3))), 4) - } - public fun test_inline_lambda() { - { - let v: vector = Vector(1, 2, 3); - { - let product: u64 = 1; - LambdaTest2::foreach(Borrow(Immutable)(v), |e: &u64| product: u64 = LambdaTest1::inline_mul(product, Deref(e))); - Tuple() - } - } - } -} // end 0x42::LambdaTest2 -module 0x42::LambdaTest { - use 0x42::LambdaTest2; // resolved as: 0x42::LambdaTest2 - public inline fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public inline fun inline_apply_test(): u64 { - Add(LambdaTest2::inline_apply2(|x: u64| Add(x, 1), 3), LambdaTest2::inline_apply2(|x: u64| Mul(x, x), LambdaTest::inline_apply(|y: u64| y, 3))) - } - private fun test_lambda() { - { - let a: u64 = LambdaTest::inline_apply_test(); - if Eq(a, 1) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaTest - - -// -- Model dump after env processor access and use check before inlining: -module 0x42::LambdaTest1 { - public inline fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public inline fun inline_apply1(f: |u64|u64,b: u64): u64 { - LambdaTest1::inline_mul(Add((f)(b), 1), LambdaTest1::inline_mul(3, 4)) - } - public inline fun inline_mul(a: u64,b: u64): u64 { - Mul(a, b) - } -} // end 0x42::LambdaTest1 -module 0x42::LambdaTest2 { - use 0x42::LambdaTest1; // resolved as: 0x42::LambdaTest1 - use std::vector; - public inline fun foreach(v: &vector,action: |&T|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - (action)(vector::borrow(v, i)); - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - } - public inline fun inline_apply2(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(|z: u64| z, (g)(LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| x, 3)))), 2) - } - public inline fun inline_apply3(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(g, LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| LambdaTest1::inline_apply(|y: u64| y, x), 3))), 4) - } - public fun test_inline_lambda() { - { - let v: vector = Vector(1, 2, 3); - { - let product: u64 = 1; - LambdaTest2::foreach(Borrow(Immutable)(v), |e: &u64| product: u64 = LambdaTest1::inline_mul(product, Deref(e))); - Tuple() - } - } - } -} // end 0x42::LambdaTest2 -module 0x42::LambdaTest { - use 0x42::LambdaTest2; // resolved as: 0x42::LambdaTest2 - public inline fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public inline fun inline_apply_test(): u64 { - Add(LambdaTest2::inline_apply2(|x: u64| Add(x, 1), 3), LambdaTest2::inline_apply2(|x: u64| Mul(x, x), LambdaTest::inline_apply(|y: u64| y, 3))) - } - private fun test_lambda() { - { - let a: u64 = LambdaTest::inline_apply_test(); - if Eq(a, 1) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaTest - - -// -- Model dump after env processor inlining: -module 0x42::LambdaTest1 { - public inline fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public inline fun inline_apply1(f: |u64|u64,b: u64): u64 { - { - let (a: u64, b: u64): (u64, u64) = Tuple(Add((f)(b), 1), { - let (a: u64, b: u64): (u64, u64) = Tuple(3, 4); - Mul(a, b) - }); - Mul(a, b) - } - } - public inline fun inline_mul(a: u64,b: u64): u64 { - Mul(a, b) - } -} // end 0x42::LambdaTest1 -module 0x42::LambdaTest2 { - use 0x42::LambdaTest1; // resolved as: 0x42::LambdaTest1 - use std::vector; - public inline fun foreach(v: &vector,action: |&T|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - (action)(vector::borrow(v, i)); - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - } - public inline fun inline_apply2(g: |u64|u64,c: u64): u64 { - Add({ - let (b: u64): (u64) = Tuple((g)({ - let (a: u64, b: u64): (u64, u64) = Tuple(c, { - let (b: u64): (u64) = Tuple(3); - { - let (x: u64): (u64) = Tuple(b); - x - } - }); - Mul(a, b) - })); - { - let (a: u64, b: u64): (u64, u64) = Tuple(Add({ - let (z: u64): (u64) = Tuple(b); - z - }, 1), { - let (a: u64, b: u64): (u64, u64) = Tuple(3, 4); - Mul(a, b) - }); - Mul(a, b) - } - }, 2) - } - public inline fun inline_apply3(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(g, LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| LambdaTest1::inline_apply(|y: u64| y, x), 3))), 4) - } - public fun test_inline_lambda() { - { - let v: vector = Vector(1, 2, 3); - { - let product: u64 = 1; - { - let (v: &vector): (&vector) = Tuple(Borrow(Immutable)(v)); - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - { - let (e: &u64): (&u64) = Tuple(vector::borrow(v, i)); - product: u64 = { - let (a: u64, b: u64): (u64, u64) = Tuple(product, Deref(e)); - Mul(a, b) - } - }; - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - }; - Tuple() - } - } - } -} // end 0x42::LambdaTest2 -module 0x42::LambdaTest { - use 0x42::LambdaTest2; // resolved as: 0x42::LambdaTest2 - public inline fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public inline fun inline_apply_test(): u64 { - Add({ - let (c: u64): (u64) = Tuple(3); - Add({ - let (b: u64): (u64) = Tuple({ - let (x: u64): (u64) = Tuple({ - let (a: u64, b: u64): (u64, u64) = Tuple(c, { - let (b: u64): (u64) = Tuple(3); - { - let (x: u64): (u64) = Tuple(b); - x - } - }); - Mul(a, b) - }); - Add(x, 1) - }); - { - let (a: u64, b: u64): (u64, u64) = Tuple(Add({ - let (z: u64): (u64) = Tuple(b); - z - }, 1), { - let (a: u64, b: u64): (u64, u64) = Tuple(3, 4); - Mul(a, b) - }); - Mul(a, b) - } - }, 2) - }, { - let (c: u64): (u64) = Tuple({ - let (b: u64): (u64) = Tuple(3); - { - let (y: u64): (u64) = Tuple(b); - y - } - }); - Add({ - let (b: u64): (u64) = Tuple({ - let (x: u64): (u64) = Tuple({ - let (a: u64, b: u64): (u64, u64) = Tuple(c, { - let (b: u64): (u64) = Tuple(3); - { - let (x: u64): (u64) = Tuple(b); - x - } - }); - Mul(a, b) - }); - Mul(x, x) - }); - { - let (a: u64, b: u64): (u64, u64) = Tuple(Add({ - let (z: u64): (u64) = Tuple(b); - z - }, 1), { - let (a: u64, b: u64): (u64, u64) = Tuple(3, 4); - Mul(a, b) - }); - Mul(a, b) - } - }, 2) - }) - } - private fun test_lambda() { - { - let a: u64 = { - let (): (); - Add({ - let (c: u64): (u64) = Tuple(3); - Add({ - let (b: u64): (u64) = Tuple({ - let (x: u64): (u64) = Tuple({ - let (a: u64, b: u64): (u64, u64) = Tuple(c, { - let (b: u64): (u64) = Tuple(3); - { - let (x: u64): (u64) = Tuple(b); - x - } - }); - Mul(a, b) - }); - Add(x, 1) - }); - { - let (a: u64, b: u64): (u64, u64) = Tuple(Add({ - let (z: u64): (u64) = Tuple(b); - z - }, 1), { - let (a: u64, b: u64): (u64, u64) = Tuple(3, 4); - Mul(a, b) - }); - Mul(a, b) - } - }, 2) - }, { - let (c: u64): (u64) = Tuple({ - let (b: u64): (u64) = Tuple(3); - { - let (y: u64): (u64) = Tuple(b); - y - } - }); - Add({ - let (b: u64): (u64) = Tuple({ - let (x: u64): (u64) = Tuple({ - let (a: u64, b: u64): (u64, u64) = Tuple(c, { - let (b: u64): (u64) = Tuple(3); - { - let (x: u64): (u64) = Tuple(b); - x - } - }); - Mul(a, b) - }); - Mul(x, x) - }); - { - let (a: u64, b: u64): (u64, u64) = Tuple(Add({ - let (z: u64): (u64) = Tuple(b); - z - }, 1), { - let (a: u64, b: u64): (u64, u64) = Tuple(3, 4); - Mul(a, b) - }); - Mul(a, b) - } - }, 2) - }) - }; - if Eq(a, 1) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaTest - - -// -- Model dump after env processor access and use check after inlining: -module 0x42::LambdaTest1 { - public inline fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public inline fun inline_apply1(f: |u64|u64,b: u64): u64 { - { - let (a: u64, b: u64): (u64, u64) = Tuple(Add((f)(b), 1), { - let (a: u64, b: u64): (u64, u64) = Tuple(3, 4); - Mul(a, b) - }); - Mul(a, b) - } - } - public inline fun inline_mul(a: u64,b: u64): u64 { - Mul(a, b) - } -} // end 0x42::LambdaTest1 -module 0x42::LambdaTest2 { - use 0x42::LambdaTest1; // resolved as: 0x42::LambdaTest1 - use std::vector; - public inline fun foreach(v: &vector,action: |&T|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - (action)(vector::borrow(v, i)); - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - } - public inline fun inline_apply2(g: |u64|u64,c: u64): u64 { - Add({ - let (b: u64): (u64) = Tuple((g)({ - let (a: u64, b: u64): (u64, u64) = Tuple(c, { - let (b: u64): (u64) = Tuple(3); - { - let (x: u64): (u64) = Tuple(b); - x - } - }); - Mul(a, b) - })); - { - let (a: u64, b: u64): (u64, u64) = Tuple(Add({ - let (z: u64): (u64) = Tuple(b); - z - }, 1), { - let (a: u64, b: u64): (u64, u64) = Tuple(3, 4); - Mul(a, b) - }); - Mul(a, b) - } - }, 2) - } - public inline fun inline_apply3(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(g, LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| LambdaTest1::inline_apply(|y: u64| y, x), 3))), 4) - } - public fun test_inline_lambda() { - { - let v: vector = Vector(1, 2, 3); - { - let product: u64 = 1; - { - let (v: &vector): (&vector) = Tuple(Borrow(Immutable)(v)); - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - { - let (e: &u64): (&u64) = Tuple(vector::borrow(v, i)); - product: u64 = { - let (a: u64, b: u64): (u64, u64) = Tuple(product, Deref(e)); - Mul(a, b) - } - }; - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - }; - Tuple() - } - } - } -} // end 0x42::LambdaTest2 -module 0x42::LambdaTest { - use 0x42::LambdaTest2; // resolved as: 0x42::LambdaTest2 - public inline fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public inline fun inline_apply_test(): u64 { - Add({ - let (c: u64): (u64) = Tuple(3); - Add({ - let (b: u64): (u64) = Tuple({ - let (x: u64): (u64) = Tuple({ - let (a: u64, b: u64): (u64, u64) = Tuple(c, { - let (b: u64): (u64) = Tuple(3); - { - let (x: u64): (u64) = Tuple(b); - x - } - }); - Mul(a, b) - }); - Add(x, 1) - }); - { - let (a: u64, b: u64): (u64, u64) = Tuple(Add({ - let (z: u64): (u64) = Tuple(b); - z - }, 1), { - let (a: u64, b: u64): (u64, u64) = Tuple(3, 4); - Mul(a, b) - }); - Mul(a, b) - } - }, 2) - }, { - let (c: u64): (u64) = Tuple({ - let (b: u64): (u64) = Tuple(3); - { - let (y: u64): (u64) = Tuple(b); - y - } - }); - Add({ - let (b: u64): (u64) = Tuple({ - let (x: u64): (u64) = Tuple({ - let (a: u64, b: u64): (u64, u64) = Tuple(c, { - let (b: u64): (u64) = Tuple(3); - { - let (x: u64): (u64) = Tuple(b); - x - } - }); - Mul(a, b) - }); - Mul(x, x) - }); - { - let (a: u64, b: u64): (u64, u64) = Tuple(Add({ - let (z: u64): (u64) = Tuple(b); - z - }, 1), { - let (a: u64, b: u64): (u64, u64) = Tuple(3, 4); - Mul(a, b) - }); - Mul(a, b) - } - }, 2) - }) - } - private fun test_lambda() { - { - let a: u64 = { - let (): (); - Add({ - let (c: u64): (u64) = Tuple(3); - Add({ - let (b: u64): (u64) = Tuple({ - let (x: u64): (u64) = Tuple({ - let (a: u64, b: u64): (u64, u64) = Tuple(c, { - let (b: u64): (u64) = Tuple(3); - { - let (x: u64): (u64) = Tuple(b); - x - } - }); - Mul(a, b) - }); - Add(x, 1) - }); - { - let (a: u64, b: u64): (u64, u64) = Tuple(Add({ - let (z: u64): (u64) = Tuple(b); - z - }, 1), { - let (a: u64, b: u64): (u64, u64) = Tuple(3, 4); - Mul(a, b) - }); - Mul(a, b) - } - }, 2) - }, { - let (c: u64): (u64) = Tuple({ - let (b: u64): (u64) = Tuple(3); - { - let (y: u64): (u64) = Tuple(b); - y - } - }); - Add({ - let (b: u64): (u64) = Tuple({ - let (x: u64): (u64) = Tuple({ - let (a: u64, b: u64): (u64, u64) = Tuple(c, { - let (b: u64): (u64) = Tuple(3); - { - let (x: u64): (u64) = Tuple(b); - x - } - }); - Mul(a, b) - }); - Mul(x, x) - }); - { - let (a: u64, b: u64): (u64, u64) = Tuple(Add({ - let (z: u64): (u64) = Tuple(b); - z - }, 1), { - let (a: u64, b: u64): (u64, u64) = Tuple(3, 4); - Mul(a, b) - }); - Mul(a, b) - } - }, 2) - }) - }; - if Eq(a, 1) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaTest - - -// -- Model dump after env processor acquires check: -module 0x42::LambdaTest1 { - public inline fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public inline fun inline_apply1(f: |u64|u64,b: u64): u64 { - { - let (a: u64, b: u64): (u64, u64) = Tuple(Add((f)(b), 1), { - let (a: u64, b: u64): (u64, u64) = Tuple(3, 4); - Mul(a, b) - }); - Mul(a, b) - } - } - public inline fun inline_mul(a: u64,b: u64): u64 { - Mul(a, b) - } -} // end 0x42::LambdaTest1 -module 0x42::LambdaTest2 { - use 0x42::LambdaTest1; // resolved as: 0x42::LambdaTest1 - use std::vector; - public inline fun foreach(v: &vector,action: |&T|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - (action)(vector::borrow(v, i)); - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - } - public inline fun inline_apply2(g: |u64|u64,c: u64): u64 { - Add({ - let (b: u64): (u64) = Tuple((g)({ - let (a: u64, b: u64): (u64, u64) = Tuple(c, { - let (b: u64): (u64) = Tuple(3); - { - let (x: u64): (u64) = Tuple(b); - x - } - }); - Mul(a, b) - })); - { - let (a: u64, b: u64): (u64, u64) = Tuple(Add({ - let (z: u64): (u64) = Tuple(b); - z - }, 1), { - let (a: u64, b: u64): (u64, u64) = Tuple(3, 4); - Mul(a, b) - }); - Mul(a, b) - } - }, 2) - } - public inline fun inline_apply3(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(g, LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| LambdaTest1::inline_apply(|y: u64| y, x), 3))), 4) - } - public fun test_inline_lambda() { - { - let v: vector = Vector(1, 2, 3); - { - let product: u64 = 1; - { - let (v: &vector): (&vector) = Tuple(Borrow(Immutable)(v)); - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - { - let (e: &u64): (&u64) = Tuple(vector::borrow(v, i)); - product: u64 = { - let (a: u64, b: u64): (u64, u64) = Tuple(product, Deref(e)); - Mul(a, b) - } - }; - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - }; - Tuple() - } - } - } -} // end 0x42::LambdaTest2 -module 0x42::LambdaTest { - use 0x42::LambdaTest2; // resolved as: 0x42::LambdaTest2 - public inline fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public inline fun inline_apply_test(): u64 { - Add({ - let (c: u64): (u64) = Tuple(3); - Add({ - let (b: u64): (u64) = Tuple({ - let (x: u64): (u64) = Tuple({ - let (a: u64, b: u64): (u64, u64) = Tuple(c, { - let (b: u64): (u64) = Tuple(3); - { - let (x: u64): (u64) = Tuple(b); - x - } - }); - Mul(a, b) - }); - Add(x, 1) - }); - { - let (a: u64, b: u64): (u64, u64) = Tuple(Add({ - let (z: u64): (u64) = Tuple(b); - z - }, 1), { - let (a: u64, b: u64): (u64, u64) = Tuple(3, 4); - Mul(a, b) - }); - Mul(a, b) - } - }, 2) - }, { - let (c: u64): (u64) = Tuple({ - let (b: u64): (u64) = Tuple(3); - { - let (y: u64): (u64) = Tuple(b); - y - } - }); - Add({ - let (b: u64): (u64) = Tuple({ - let (x: u64): (u64) = Tuple({ - let (a: u64, b: u64): (u64, u64) = Tuple(c, { - let (b: u64): (u64) = Tuple(3); - { - let (x: u64): (u64) = Tuple(b); - x - } - }); - Mul(a, b) - }); - Mul(x, x) - }); - { - let (a: u64, b: u64): (u64, u64) = Tuple(Add({ - let (z: u64): (u64) = Tuple(b); - z - }, 1), { - let (a: u64, b: u64): (u64, u64) = Tuple(3, 4); - Mul(a, b) - }); - Mul(a, b) - } - }, 2) - }) - } - private fun test_lambda() { - { - let a: u64 = { - let (): (); - Add({ - let (c: u64): (u64) = Tuple(3); - Add({ - let (b: u64): (u64) = Tuple({ - let (x: u64): (u64) = Tuple({ - let (a: u64, b: u64): (u64, u64) = Tuple(c, { - let (b: u64): (u64) = Tuple(3); - { - let (x: u64): (u64) = Tuple(b); - x - } - }); - Mul(a, b) - }); - Add(x, 1) - }); - { - let (a: u64, b: u64): (u64, u64) = Tuple(Add({ - let (z: u64): (u64) = Tuple(b); - z - }, 1), { - let (a: u64, b: u64): (u64, u64) = Tuple(3, 4); - Mul(a, b) - }); - Mul(a, b) - } - }, 2) - }, { - let (c: u64): (u64) = Tuple({ - let (b: u64): (u64) = Tuple(3); - { - let (y: u64): (u64) = Tuple(b); - y - } - }); - Add({ - let (b: u64): (u64) = Tuple({ - let (x: u64): (u64) = Tuple({ - let (a: u64, b: u64): (u64, u64) = Tuple(c, { - let (b: u64): (u64) = Tuple(3); - { - let (x: u64): (u64) = Tuple(b); - x - } - }); - Mul(a, b) - }); - Mul(x, x) - }); - { - let (a: u64, b: u64): (u64, u64) = Tuple(Add({ - let (z: u64): (u64) = Tuple(b); - z - }, 1), { - let (a: u64, b: u64): (u64, u64) = Tuple(3, 4); - Mul(a, b) - }); - Mul(a, b) - } - }, 2) - }) - }; - if Eq(a, 1) { - Tuple() - } else { - Abort(0) - }; - Tuple() - } - } -} // end 0x42::LambdaTest - - -// -- Model dump after env processor simplifier: -module 0x42::LambdaTest1 { - public inline fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public inline fun inline_apply1(f: |u64|u64,b: u64): u64 { - { - let (a: u64, b: u64): (u64, u64) = Tuple(Add((f)(b), 1), 12); - Mul(a, 12) - } - } - public inline fun inline_mul(a: u64,b: u64): u64 { - Mul(a, b) - } -} // end 0x42::LambdaTest1 -module 0x42::LambdaTest2 { - use 0x42::LambdaTest1; // resolved as: 0x42::LambdaTest1 - use std::vector; - public inline fun foreach(v: &vector,action: |&T|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - (action)(vector::borrow(v, i)); - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - } - public inline fun inline_apply2(g: |u64|u64,c: u64): u64 { - Add({ - let (b: u64): (u64) = Tuple((g)({ - let (a: u64, b: u64): (u64, u64) = Tuple(c, 3); - Mul(a, 3) - })); - { - let (a: u64, b: u64): (u64, u64) = Tuple(Add({ - let (z: u64): (u64) = Tuple(b); - z - }, 1), 12); - Mul(a, 12) - } - }, 2) - } - public inline fun inline_apply3(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(g, LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x: u64| LambdaTest1::inline_apply(|y: u64| y, x), 3))), 4) - } - public fun test_inline_lambda() { - { - let product: u64 = 1; - { - let (v: &vector): (&vector) = Tuple(Borrow(Immutable)([Number(1), Number(2), Number(3)])); - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - { - let (e: &u64): (&u64) = Tuple(vector::borrow(v, i)); - product: u64 = { - let (a: u64, b: u64): (u64, u64) = Tuple(product, Deref(e)); - Mul(a, b) - } - }; - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - }; - Tuple() - } - } -} // end 0x42::LambdaTest2 -module 0x42::LambdaTest { - use 0x42::LambdaTest2; // resolved as: 0x42::LambdaTest2 - public inline fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public inline fun inline_apply_test(): u64 { - 1120 - } - private fun test_lambda() { - if false { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::LambdaTest - - -// -- Model dump after env processor lambda-lifting: -module 0x42::LambdaTest1 { - public inline fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public inline fun inline_apply1(f: |u64|u64,b: u64): u64 { - { - let (a: u64, b: u64): (u64, u64) = Tuple(Add((f)(b), 1), 12); - Mul(a, 12) - } - } - public inline fun inline_mul(a: u64,b: u64): u64 { - Mul(a, b) - } -} // end 0x42::LambdaTest1 -module 0x42::LambdaTest2 { - use 0x42::LambdaTest1; // resolved as: 0x42::LambdaTest1 - use std::vector; - public inline fun foreach(v: &vector,action: |&T|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - (action)(vector::borrow(v, i)); - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - } - public inline fun inline_apply2(g: |u64|u64,c: u64): u64 { - Add({ - let (b: u64): (u64) = Tuple((g)({ - let (a: u64, b: u64): (u64, u64) = Tuple(c, 3); - Mul(a, 3) - })); - { - let (a: u64, b: u64): (u64, u64) = Tuple(Add({ - let (z: u64): (u64) = Tuple(b); - z - }, 1), 12); - Mul(a, 12) - } - }, 2) - } - public inline fun inline_apply3(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(g, LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(closure LambdaTest2::inline_apply3$lambda$2(), 3))), 4) - } - public fun test_inline_lambda() { - { - let product: u64 = 1; - { - let (v: &vector): (&vector) = Tuple(Borrow(Immutable)([Number(1), Number(2), Number(3)])); - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - { - let (e: &u64): (&u64) = Tuple(vector::borrow(v, i)); - product: u64 = { - let (a: u64, b: u64): (u64, u64) = Tuple(product, Deref(e)); - Mul(a, b) - } - }; - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - }; - Tuple() - } - } - private fun inline_apply3$lambda$1(y: u64): u64 { - y - } - private fun inline_apply3$lambda$2(x: u64): u64 { - LambdaTest1::inline_apply(closure LambdaTest2::inline_apply3$lambda$1(), x) - } -} // end 0x42::LambdaTest2 -module 0x42::LambdaTest { - use 0x42::LambdaTest2; // resolved as: 0x42::LambdaTest2 - public inline fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public inline fun inline_apply_test(): u64 { - 1120 - } - private fun test_lambda() { - if false { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::LambdaTest - - -// -- Model dump after env processor specification checker: -module 0x42::LambdaTest1 { - public inline fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public inline fun inline_apply1(f: |u64|u64,b: u64): u64 { - { - let (a: u64, b: u64): (u64, u64) = Tuple(Add((f)(b), 1), 12); - Mul(a, 12) - } - } - public inline fun inline_mul(a: u64,b: u64): u64 { - Mul(a, b) - } -} // end 0x42::LambdaTest1 -module 0x42::LambdaTest2 { - use 0x42::LambdaTest1; // resolved as: 0x42::LambdaTest1 - use std::vector; - public inline fun foreach(v: &vector,action: |&T|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - (action)(vector::borrow(v, i)); - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - } - public inline fun inline_apply2(g: |u64|u64,c: u64): u64 { - Add({ - let (b: u64): (u64) = Tuple((g)({ - let (a: u64, b: u64): (u64, u64) = Tuple(c, 3); - Mul(a, 3) - })); - { - let (a: u64, b: u64): (u64, u64) = Tuple(Add({ - let (z: u64): (u64) = Tuple(b); - z - }, 1), 12); - Mul(a, 12) - } - }, 2) - } - public inline fun inline_apply3(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(g, LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(closure LambdaTest2::inline_apply3$lambda$2(), 3))), 4) - } - public fun test_inline_lambda() { - { - let product: u64 = 1; - { - let (v: &vector): (&vector) = Tuple(Borrow(Immutable)([Number(1), Number(2), Number(3)])); - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - { - let (e: &u64): (&u64) = Tuple(vector::borrow(v, i)); - product: u64 = { - let (a: u64, b: u64): (u64, u64) = Tuple(product, Deref(e)); - Mul(a, b) - } - }; - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - }; - Tuple() - } - } - private fun inline_apply3$lambda$1(y: u64): u64 { - y - } - private fun inline_apply3$lambda$2(x: u64): u64 { - LambdaTest1::inline_apply(closure LambdaTest2::inline_apply3$lambda$1(), x) - } -} // end 0x42::LambdaTest2 -module 0x42::LambdaTest { - use 0x42::LambdaTest2; // resolved as: 0x42::LambdaTest2 - public inline fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public inline fun inline_apply_test(): u64 { - 1120 - } - private fun test_lambda() { - if false { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::LambdaTest - - -// -- Model dump after env processor specification rewriter: -module 0x42::LambdaTest1 { - public inline fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public inline fun inline_apply1(f: |u64|u64,b: u64): u64 { - { - let (a: u64, b: u64): (u64, u64) = Tuple(Add((f)(b), 1), 12); - Mul(a, 12) - } - } - public inline fun inline_mul(a: u64,b: u64): u64 { - Mul(a, b) - } -} // end 0x42::LambdaTest1 -module 0x42::LambdaTest2 { - use 0x42::LambdaTest1; // resolved as: 0x42::LambdaTest1 - use std::vector; - public inline fun foreach(v: &vector,action: |&T|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - (action)(vector::borrow(v, i)); - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - } - public inline fun inline_apply2(g: |u64|u64,c: u64): u64 { - Add({ - let (b: u64): (u64) = Tuple((g)({ - let (a: u64, b: u64): (u64, u64) = Tuple(c, 3); - Mul(a, 3) - })); - { - let (a: u64, b: u64): (u64, u64) = Tuple(Add({ - let (z: u64): (u64) = Tuple(b); - z - }, 1), 12); - Mul(a, 12) - } - }, 2) - } - public inline fun inline_apply3(g: |u64|u64,c: u64): u64 { - Add(LambdaTest1::inline_apply1(g, LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(closure LambdaTest2::inline_apply3$lambda$2(), 3))), 4) - } - public fun test_inline_lambda() { - { - let product: u64 = 1; - { - let (v: &vector): (&vector) = Tuple(Borrow(Immutable)([Number(1), Number(2), Number(3)])); - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(v)) { - { - let (e: &u64): (&u64) = Tuple(vector::borrow(v, i)); - product: u64 = { - let (a: u64, b: u64): (u64, u64) = Tuple(product, Deref(e)); - Mul(a, b) - } - }; - i: u64 = Add(i, 1); - Tuple() - } else { - break - } - } - } - }; - Tuple() - } - } - private fun inline_apply3$lambda$1(y: u64): u64 { - y - } - private fun inline_apply3$lambda$2(x: u64): u64 { - LambdaTest1::inline_apply(closure LambdaTest2::inline_apply3$lambda$1(), x) - } -} // end 0x42::LambdaTest2 -module 0x42::LambdaTest { - use 0x42::LambdaTest2; // resolved as: 0x42::LambdaTest2 - public inline fun inline_apply(f: |u64|u64,b: u64): u64 { - (f)(b) - } - public inline fun inline_apply_test(): u64 { - 1120 - } - private fun test_lambda() { - if false { - Tuple() - } else { - Abort(0) - }; - Tuple() - } -} // end 0x42::LambdaTest - - Diagnostics: -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda/inline-parity/lambda_typed.move:11:2 - │ -11 │ f(b) - │ ^ - -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/lambda_typed.move:40:29 │ 40 │ LambdaTest1::inline_apply(|y: u64|y, x) │ ^^^^^^^^^ + +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. + ┌─ tests/lambda/inline-parity/lambda_typed.move:39:59 + │ +39 │ LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x:u64| { + │ ╭──────────────────────────────────────────────────────────────^ +40 │ │ LambdaTest1::inline_apply(|y: u64|y, x) +41 │ │ }, + │ ╰─────────^ diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/masking.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/masking.lambda.exp index a89c6271195d1..a04af3b3503d0 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/masking.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/masking.lambda.exp @@ -1,214 +1,12 @@ -// -- Model dump before env processor pipeline: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun main(): u64 { - Test::foo(|(x: u64, _: u64): (u64, u64)| x, |(_: u64, y: u64): (u64, u64)| y, 10, 100) - } -} // end 0x42::Test - - -// -- Model dump after env processor unused checks: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun main(): u64 { - Test::foo(|(x: u64, _: u64): (u64, u64)| x, |(_: u64, y: u64): (u64, u64)| y, 10, 100) - } -} // end 0x42::Test - - -// -- Model dump after env processor type parameter check: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun main(): u64 { - Test::foo(|(x: u64, _: u64): (u64, u64)| x, |(_: u64, y: u64): (u64, u64)| y, 10, 100) - } -} // end 0x42::Test - - -// -- Model dump after env processor check recursive struct definition: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun main(): u64 { - Test::foo(|(x: u64, _: u64): (u64, u64)| x, |(_: u64, y: u64): (u64, u64)| y, 10, 100) - } -} // end 0x42::Test - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun main(): u64 { - Test::foo(|(x: u64, _: u64): (u64, u64)| x, |(_: u64, y: u64): (u64, u64)| y, 10, 100) - } -} // end 0x42::Test - - -// -- Model dump after env processor unused struct params check: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun main(): u64 { - Test::foo(|(x: u64, _: u64): (u64, u64)| x, |(_: u64, y: u64): (u64, u64)| y, 10, 100) - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check before inlining: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun main(): u64 { - Test::foo(|(x: u64, _: u64): (u64, u64)| x, |(_: u64, y: u64): (u64, u64)| y, 10, 100) - } -} // end 0x42::Test - - -// -- Model dump after env processor inlining: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun main(): u64 { - Test::foo(|(x: u64, _: u64): (u64, u64)| x, |(_: u64, y: u64): (u64, u64)| y, 10, 100) - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check after inlining: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun main(): u64 { - Test::foo(|(x: u64, _: u64): (u64, u64)| x, |(_: u64, y: u64): (u64, u64)| y, 10, 100) - } -} // end 0x42::Test - - -// -- Model dump after env processor acquires check: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun main(): u64 { - Test::foo(|(x: u64, _: u64): (u64, u64)| x, |(_: u64, y: u64): (u64, u64)| y, 10, 100) - } -} // end 0x42::Test - - -// -- Model dump after env processor simplifier: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun main(): u64 { - Test::foo(|(x: u64, _: u64): (u64, u64)| x, |(_: u64, y: u64): (u64, u64)| y, 10, 100) - } -} // end 0x42::Test - - -// -- Model dump after env processor lambda-lifting: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun main(): u64 { - Test::foo(closure Test::main$lambda$1(), closure Test::main$lambda$2(), 10, 100) - } - private fun main$lambda$1(x: u64,param$1: u64): u64 { - { - let _: u64 = param$1; - x - } - } - private fun main$lambda$2(param$0: u64,y: u64): u64 { - { - let _: u64 = param$0; - y - } - } -} // end 0x42::Test - - -// -- Model dump after env processor specification checker: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun main(): u64 { - Test::foo(closure Test::main$lambda$1(), closure Test::main$lambda$2(), 10, 100) - } - private fun main$lambda$1(x: u64,param$1: u64): u64 { - { - let _: u64 = param$1; - x - } - } - private fun main$lambda$2(param$0: u64,y: u64): u64 { - { - let _: u64 = param$0; - y - } - } -} // end 0x42::Test - - -// -- Model dump after env processor specification rewriter: -module 0x42::Test { - private fun foo(f: |(u64, u64)|u64,g: |(u64, u64)|u64,x: u64,_y: u64): u64 { - Add((f)(x, _y), (g)(x, _y)) - } - public fun main(): u64 { - Test::foo(closure Test::main$lambda$1(), closure Test::main$lambda$2(), 10, 100) - } - private fun main$lambda$1(x: u64,param$1: u64): u64 { - { - let _: u64 = param$1; - x - } - } - private fun main$lambda$2(param$0: u64,y: u64): u64 { - { - let _: u64 = param$0; - y - } - } -} // end 0x42::Test - - Diagnostics: -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda/inline-parity/masking.move:4:9 - │ -4 │ f(x, _y) + g(x, _y) - │ ^ - -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda/inline-parity/masking.move:4:20 - │ -4 │ f(x, _y) + g(x, _y) - │ ^ - -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/masking.move:8:13 │ 8 │ foo(|x, _| x, |_, y| y, 10, 100) │ ^^^^^^^^ -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/masking.move:8:23 │ 8 │ foo(|x, _| x, |_, y| y, 10, 100) diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/multi_param.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/multi_param.lambda.exp index 79df5cae6a545..9d43fb272fead 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/multi_param.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/multi_param.lambda.exp @@ -1,458 +1,17 @@ -// -- Model dump before env processor pipeline: -module 0x42::Test { - use 0x1::vector as V; // resolved as: 0x1::vector - struct Elem { - k: K, - v: V, - } - public fun elem_for_each_ref(v: &mut vector>,f: |(&K, &mut V)|u64): u64 { - { - let result: u64 = 0; - Test::for_each_ref_mut>(v, |elem: &mut Elem| { - let elem: &mut Elem = elem; - result: u64 = Add(result, (f)(Borrow(Immutable)(select Test::Elem.k<&mut Elem>(elem)), Borrow(Mutable)(select Test::Elem.v<&mut Elem>(elem)))); - Tuple() - }); - result - } - } - public fun for_each_ref_mut(v: &mut vector,f: |&mut Element|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(Freeze(false)(v))) { - (f)(vector::borrow_mut(v, i)); - i: u64 = Add(i, 1) - } else { - break - } - } - } - } - public fun test() { - if Eq(Test::elem_for_each_ref(Borrow(Mutable)(Vector>(pack Test::Elem(1, 2))), |(x: &u64, y: &mut u64): (&u64, &mut u64)| Add(Deref(x), Deref(y))), 3) { - Tuple() - } else { - Abort(0) - } - } -} // end 0x42::Test - - -// -- Model dump after env processor unused checks: -module 0x42::Test { - use 0x1::vector as V; // resolved as: 0x1::vector - struct Elem { - k: K, - v: V, - } - public fun elem_for_each_ref(v: &mut vector>,f: |(&K, &mut V)|u64): u64 { - { - let result: u64 = 0; - Test::for_each_ref_mut>(v, |elem: &mut Elem| { - let elem: &mut Elem = elem; - result: u64 = Add(result, (f)(Borrow(Immutable)(select Test::Elem.k<&mut Elem>(elem)), Borrow(Mutable)(select Test::Elem.v<&mut Elem>(elem)))); - Tuple() - }); - result - } - } - public fun for_each_ref_mut(v: &mut vector,f: |&mut Element|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(Freeze(false)(v))) { - (f)(vector::borrow_mut(v, i)); - i: u64 = Add(i, 1) - } else { - break - } - } - } - } - public fun test() { - if Eq(Test::elem_for_each_ref(Borrow(Mutable)(Vector>(pack Test::Elem(1, 2))), |(x: &u64, y: &mut u64): (&u64, &mut u64)| Add(Deref(x), Deref(y))), 3) { - Tuple() - } else { - Abort(0) - } - } -} // end 0x42::Test - - -// -- Model dump after env processor type parameter check: -module 0x42::Test { - use 0x1::vector as V; // resolved as: 0x1::vector - struct Elem { - k: K, - v: V, - } - public fun elem_for_each_ref(v: &mut vector>,f: |(&K, &mut V)|u64): u64 { - { - let result: u64 = 0; - Test::for_each_ref_mut>(v, |elem: &mut Elem| { - let elem: &mut Elem = elem; - result: u64 = Add(result, (f)(Borrow(Immutable)(select Test::Elem.k<&mut Elem>(elem)), Borrow(Mutable)(select Test::Elem.v<&mut Elem>(elem)))); - Tuple() - }); - result - } - } - public fun for_each_ref_mut(v: &mut vector,f: |&mut Element|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(Freeze(false)(v))) { - (f)(vector::borrow_mut(v, i)); - i: u64 = Add(i, 1) - } else { - break - } - } - } - } - public fun test() { - if Eq(Test::elem_for_each_ref(Borrow(Mutable)(Vector>(pack Test::Elem(1, 2))), |(x: &u64, y: &mut u64): (&u64, &mut u64)| Add(Deref(x), Deref(y))), 3) { - Tuple() - } else { - Abort(0) - } - } -} // end 0x42::Test - - -// -- Model dump after env processor check recursive struct definition: -module 0x42::Test { - use 0x1::vector as V; // resolved as: 0x1::vector - struct Elem { - k: K, - v: V, - } - public fun elem_for_each_ref(v: &mut vector>,f: |(&K, &mut V)|u64): u64 { - { - let result: u64 = 0; - Test::for_each_ref_mut>(v, |elem: &mut Elem| { - let elem: &mut Elem = elem; - result: u64 = Add(result, (f)(Borrow(Immutable)(select Test::Elem.k<&mut Elem>(elem)), Borrow(Mutable)(select Test::Elem.v<&mut Elem>(elem)))); - Tuple() - }); - result - } - } - public fun for_each_ref_mut(v: &mut vector,f: |&mut Element|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(Freeze(false)(v))) { - (f)(vector::borrow_mut(v, i)); - i: u64 = Add(i, 1) - } else { - break - } - } - } - } - public fun test() { - if Eq(Test::elem_for_each_ref(Borrow(Mutable)(Vector>(pack Test::Elem(1, 2))), |(x: &u64, y: &mut u64): (&u64, &mut u64)| Add(Deref(x), Deref(y))), 3) { - Tuple() - } else { - Abort(0) - } - } -} // end 0x42::Test - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x42::Test { - use 0x1::vector as V; // resolved as: 0x1::vector - struct Elem { - k: K, - v: V, - } - public fun elem_for_each_ref(v: &mut vector>,f: |(&K, &mut V)|u64): u64 { - { - let result: u64 = 0; - Test::for_each_ref_mut>(v, |elem: &mut Elem| { - let elem: &mut Elem = elem; - result: u64 = Add(result, (f)(Borrow(Immutable)(select Test::Elem.k<&mut Elem>(elem)), Borrow(Mutable)(select Test::Elem.v<&mut Elem>(elem)))); - Tuple() - }); - result - } - } - public fun for_each_ref_mut(v: &mut vector,f: |&mut Element|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(Freeze(false)(v))) { - (f)(vector::borrow_mut(v, i)); - i: u64 = Add(i, 1) - } else { - break - } - } - } - } - public fun test() { - if Eq(Test::elem_for_each_ref(Borrow(Mutable)(Vector>(pack Test::Elem(1, 2))), |(x: &u64, y: &mut u64): (&u64, &mut u64)| Add(Deref(x), Deref(y))), 3) { - Tuple() - } else { - Abort(0) - } - } -} // end 0x42::Test - - -// -- Model dump after env processor unused struct params check: -module 0x42::Test { - use 0x1::vector as V; // resolved as: 0x1::vector - struct Elem { - k: K, - v: V, - } - public fun elem_for_each_ref(v: &mut vector>,f: |(&K, &mut V)|u64): u64 { - { - let result: u64 = 0; - Test::for_each_ref_mut>(v, |elem: &mut Elem| { - let elem: &mut Elem = elem; - result: u64 = Add(result, (f)(Borrow(Immutable)(select Test::Elem.k<&mut Elem>(elem)), Borrow(Mutable)(select Test::Elem.v<&mut Elem>(elem)))); - Tuple() - }); - result - } - } - public fun for_each_ref_mut(v: &mut vector,f: |&mut Element|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(Freeze(false)(v))) { - (f)(vector::borrow_mut(v, i)); - i: u64 = Add(i, 1) - } else { - break - } - } - } - } - public fun test() { - if Eq(Test::elem_for_each_ref(Borrow(Mutable)(Vector>(pack Test::Elem(1, 2))), |(x: &u64, y: &mut u64): (&u64, &mut u64)| Add(Deref(x), Deref(y))), 3) { - Tuple() - } else { - Abort(0) - } - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check before inlining: -module 0x42::Test { - use 0x1::vector as V; // resolved as: 0x1::vector - struct Elem { - k: K, - v: V, - } - public fun elem_for_each_ref(v: &mut vector>,f: |(&K, &mut V)|u64): u64 { - { - let result: u64 = 0; - Test::for_each_ref_mut>(v, |elem: &mut Elem| { - let elem: &mut Elem = elem; - result: u64 = Add(result, (f)(Borrow(Immutable)(select Test::Elem.k<&mut Elem>(elem)), Borrow(Mutable)(select Test::Elem.v<&mut Elem>(elem)))); - Tuple() - }); - result - } - } - public fun for_each_ref_mut(v: &mut vector,f: |&mut Element|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(Freeze(false)(v))) { - (f)(vector::borrow_mut(v, i)); - i: u64 = Add(i, 1) - } else { - break - } - } - } - } - public fun test() { - if Eq(Test::elem_for_each_ref(Borrow(Mutable)(Vector>(pack Test::Elem(1, 2))), |(x: &u64, y: &mut u64): (&u64, &mut u64)| Add(Deref(x), Deref(y))), 3) { - Tuple() - } else { - Abort(0) - } - } -} // end 0x42::Test - - -// -- Model dump after env processor inlining: -module 0x42::Test { - use 0x1::vector as V; // resolved as: 0x1::vector - struct Elem { - k: K, - v: V, - } - public fun elem_for_each_ref(v: &mut vector>,f: |(&K, &mut V)|u64): u64 { - { - let result: u64 = 0; - Test::for_each_ref_mut>(v, |elem: &mut Elem| { - let elem: &mut Elem = elem; - result: u64 = Add(result, (f)(Borrow(Immutable)(select Test::Elem.k<&mut Elem>(elem)), Borrow(Mutable)(select Test::Elem.v<&mut Elem>(elem)))); - Tuple() - }); - result - } - } - public fun for_each_ref_mut(v: &mut vector,f: |&mut Element|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(Freeze(false)(v))) { - (f)(vector::borrow_mut(v, i)); - i: u64 = Add(i, 1) - } else { - break - } - } - } - } - public fun test() { - if Eq(Test::elem_for_each_ref(Borrow(Mutable)(Vector>(pack Test::Elem(1, 2))), |(x: &u64, y: &mut u64): (&u64, &mut u64)| Add(Deref(x), Deref(y))), 3) { - Tuple() - } else { - Abort(0) - } - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check after inlining: -module 0x42::Test { - use 0x1::vector as V; // resolved as: 0x1::vector - struct Elem { - k: K, - v: V, - } - public fun elem_for_each_ref(v: &mut vector>,f: |(&K, &mut V)|u64): u64 { - { - let result: u64 = 0; - Test::for_each_ref_mut>(v, |elem: &mut Elem| { - let elem: &mut Elem = elem; - result: u64 = Add(result, (f)(Borrow(Immutable)(select Test::Elem.k<&mut Elem>(elem)), Borrow(Mutable)(select Test::Elem.v<&mut Elem>(elem)))); - Tuple() - }); - result - } - } - public fun for_each_ref_mut(v: &mut vector,f: |&mut Element|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(Freeze(false)(v))) { - (f)(vector::borrow_mut(v, i)); - i: u64 = Add(i, 1) - } else { - break - } - } - } - } - public fun test() { - if Eq(Test::elem_for_each_ref(Borrow(Mutable)(Vector>(pack Test::Elem(1, 2))), |(x: &u64, y: &mut u64): (&u64, &mut u64)| Add(Deref(x), Deref(y))), 3) { - Tuple() - } else { - Abort(0) - } - } -} // end 0x42::Test - - -// -- Model dump after env processor acquires check: -module 0x42::Test { - use 0x1::vector as V; // resolved as: 0x1::vector - struct Elem { - k: K, - v: V, - } - public fun elem_for_each_ref(v: &mut vector>,f: |(&K, &mut V)|u64): u64 { - { - let result: u64 = 0; - Test::for_each_ref_mut>(v, |elem: &mut Elem| { - let elem: &mut Elem = elem; - result: u64 = Add(result, (f)(Borrow(Immutable)(select Test::Elem.k<&mut Elem>(elem)), Borrow(Mutable)(select Test::Elem.v<&mut Elem>(elem)))); - Tuple() - }); - result - } - } - public fun for_each_ref_mut(v: &mut vector,f: |&mut Element|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(Freeze(false)(v))) { - (f)(vector::borrow_mut(v, i)); - i: u64 = Add(i, 1) - } else { - break - } - } - } - } - public fun test() { - if Eq(Test::elem_for_each_ref(Borrow(Mutable)(Vector>(pack Test::Elem(1, 2))), |(x: &u64, y: &mut u64): (&u64, &mut u64)| Add(Deref(x), Deref(y))), 3) { - Tuple() - } else { - Abort(0) - } - } -} // end 0x42::Test - - -// -- Model dump after env processor simplifier: -module 0x42::Test { - use 0x1::vector as V; // resolved as: 0x1::vector - struct Elem { - k: K, - v: V, - } - public fun elem_for_each_ref(v: &mut vector>,f: |(&K, &mut V)|u64): u64 { - { - let result: u64 = 0; - Test::for_each_ref_mut>(v, |elem: &mut Elem| { - let elem: &mut Elem = elem; - result: u64 = Add(result, (f)(Borrow(Immutable)(select Test::Elem.k<&mut Elem>(elem)), Borrow(Mutable)(select Test::Elem.v<&mut Elem>(elem)))); - Tuple() - }); - result - } - } - public fun for_each_ref_mut(v: &mut vector,f: |&mut Element|) { - { - let i: u64 = 0; - loop { - if Lt(i, vector::length(Freeze(false)(v))) { - (f)(vector::borrow_mut(v, i)); - i: u64 = Add(i, 1) - } else { - break - } - } - } - } - public fun test() { - if Eq(Test::elem_for_each_ref(Borrow(Mutable)(Vector>(pack Test::Elem(1, 2))), |(x: &u64, y: &mut u64): (&u64, &mut u64)| Add(Deref(x), Deref(y))), 3) { - Tuple() - } else { - Abort(0) - } - } -} // end 0x42::Test - - Diagnostics: -error: captured variable `result` cannot be modified inside of a lambda - ┌─ tests/lambda/inline-parity/multi_param.move:21:13 +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. + ┌─ tests/lambda/inline-parity/multi_param.move:19:29 + │ +19 │ for_each_ref_mut(v, |elem| { + │ ╭─────────────────────────────^ +20 │ │ let elem: &mut Elem = elem; // Checks whether scoping is fine +21 │ │ result = result + f(&elem.k, &mut elem.v); +22 │ │ }); + │ ╰─────────^ + +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. + ┌─ tests/lambda/inline-parity/multi_param.move:27:64 │ -21 │ result = result + f(&elem.k, &mut elem.v); - │ ^^^^^^ +27 │ assert!(elem_for_each_ref(&mut vector[Elem{k:1, v:2}], |x,y| *x + *y) == 3, 0) + │ ^^^^^^^^^^^^^ diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/nested_lambda.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/nested_lambda.lambda.exp index 019feaaebebc4..5c79e56c2797b 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/nested_lambda.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/nested_lambda.lambda.exp @@ -1,190 +1,12 @@ -// -- Model dump before env processor pipeline: -module 0x42::Test { - public fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } - public fun test(): u64 { - Test::apply(|(x: u64, y: u64): (u64, u64)| Add(x, y), 1, Test::apply(|(x: u64, y: u64): (u64, u64)| Mul(x, y), 2, 1)) - } -} // end 0x42::Test - - -// -- Model dump after env processor unused checks: -module 0x42::Test { - public fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } - public fun test(): u64 { - Test::apply(|(x: u64, y: u64): (u64, u64)| Add(x, y), 1, Test::apply(|(x: u64, y: u64): (u64, u64)| Mul(x, y), 2, 1)) - } -} // end 0x42::Test - - -// -- Model dump after env processor type parameter check: -module 0x42::Test { - public fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } - public fun test(): u64 { - Test::apply(|(x: u64, y: u64): (u64, u64)| Add(x, y), 1, Test::apply(|(x: u64, y: u64): (u64, u64)| Mul(x, y), 2, 1)) - } -} // end 0x42::Test - - -// -- Model dump after env processor check recursive struct definition: -module 0x42::Test { - public fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } - public fun test(): u64 { - Test::apply(|(x: u64, y: u64): (u64, u64)| Add(x, y), 1, Test::apply(|(x: u64, y: u64): (u64, u64)| Mul(x, y), 2, 1)) - } -} // end 0x42::Test - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x42::Test { - public fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } - public fun test(): u64 { - Test::apply(|(x: u64, y: u64): (u64, u64)| Add(x, y), 1, Test::apply(|(x: u64, y: u64): (u64, u64)| Mul(x, y), 2, 1)) - } -} // end 0x42::Test - - -// -- Model dump after env processor unused struct params check: -module 0x42::Test { - public fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } - public fun test(): u64 { - Test::apply(|(x: u64, y: u64): (u64, u64)| Add(x, y), 1, Test::apply(|(x: u64, y: u64): (u64, u64)| Mul(x, y), 2, 1)) - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check before inlining: -module 0x42::Test { - public fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } - public fun test(): u64 { - Test::apply(|(x: u64, y: u64): (u64, u64)| Add(x, y), 1, Test::apply(|(x: u64, y: u64): (u64, u64)| Mul(x, y), 2, 1)) - } -} // end 0x42::Test - - -// -- Model dump after env processor inlining: -module 0x42::Test { - public fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } - public fun test(): u64 { - Test::apply(|(x: u64, y: u64): (u64, u64)| Add(x, y), 1, Test::apply(|(x: u64, y: u64): (u64, u64)| Mul(x, y), 2, 1)) - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check after inlining: -module 0x42::Test { - public fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } - public fun test(): u64 { - Test::apply(|(x: u64, y: u64): (u64, u64)| Add(x, y), 1, Test::apply(|(x: u64, y: u64): (u64, u64)| Mul(x, y), 2, 1)) - } -} // end 0x42::Test - - -// -- Model dump after env processor acquires check: -module 0x42::Test { - public fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } - public fun test(): u64 { - Test::apply(|(x: u64, y: u64): (u64, u64)| Add(x, y), 1, Test::apply(|(x: u64, y: u64): (u64, u64)| Mul(x, y), 2, 1)) - } -} // end 0x42::Test - - -// -- Model dump after env processor simplifier: -module 0x42::Test { - public fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } - public fun test(): u64 { - Test::apply(|(x: u64, y: u64): (u64, u64)| Add(x, y), 1, Test::apply(|(x: u64, y: u64): (u64, u64)| Mul(x, y), 2, 1)) - } -} // end 0x42::Test - - -// -- Model dump after env processor lambda-lifting: -module 0x42::Test { - public fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } - public fun test(): u64 { - Test::apply(closure Test::test$lambda$1(), 1, Test::apply(closure Test::test$lambda$2(), 2, 1)) - } - private fun test$lambda$1(x: u64,y: u64): u64 { - Add(x, y) - } - private fun test$lambda$2(x: u64,y: u64): u64 { - Mul(x, y) - } -} // end 0x42::Test - - -// -- Model dump after env processor specification checker: -module 0x42::Test { - public fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } - public fun test(): u64 { - Test::apply(closure Test::test$lambda$1(), 1, Test::apply(closure Test::test$lambda$2(), 2, 1)) - } - private fun test$lambda$1(x: u64,y: u64): u64 { - Add(x, y) - } - private fun test$lambda$2(x: u64,y: u64): u64 { - Mul(x, y) - } -} // end 0x42::Test - - -// -- Model dump after env processor specification rewriter: -module 0x42::Test { - public fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } - public fun test(): u64 { - Test::apply(closure Test::test$lambda$1(), 1, Test::apply(closure Test::test$lambda$2(), 2, 1)) - } - private fun test$lambda$1(x: u64,y: u64): u64 { - Add(x, y) - } - private fun test$lambda$2(x: u64,y: u64): u64 { - Mul(x, y) - } -} // end 0x42::Test - - Diagnostics: -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda/inline-parity/nested_lambda.move:5:9 - │ -5 │ f(x, y) - │ ^ - -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/nested_lambda.move:9:15 │ 9 │ apply(|x, y| x + y, 1, apply(|x, y| x * y, 2, 1)) │ ^^^^^^^^^^^^ -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/nested_lambda.move:9:38 │ 9 │ apply(|x, y| x + y, 1, apply(|x, y| x * y, 2, 1)) diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/nested_lambda_module.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/nested_lambda_module.lambda.exp index f5ed4cea4f283..1159a7553cfe5 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/nested_lambda_module.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/nested_lambda_module.lambda.exp @@ -1,232 +1,12 @@ -// -- Model dump before env processor pipeline: -module 0x42::Test1 { - public fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } -} // end 0x42::Test1 -module 0x42::Test { - use 0x42::Test1; // resolved as: 0x42::Test1 - public fun test(): u64 { - Test1::apply(|(x: u64, y: u64): (u64, u64)| Add(x, y), 1, Test1::apply(|(x: u64, y: u64): (u64, u64)| Mul(x, y), 2, 1)) - } -} // end 0x42::Test - - -// -- Model dump after env processor unused checks: -module 0x42::Test1 { - public fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } -} // end 0x42::Test1 -module 0x42::Test { - use 0x42::Test1; // resolved as: 0x42::Test1 - public fun test(): u64 { - Test1::apply(|(x: u64, y: u64): (u64, u64)| Add(x, y), 1, Test1::apply(|(x: u64, y: u64): (u64, u64)| Mul(x, y), 2, 1)) - } -} // end 0x42::Test - - -// -- Model dump after env processor type parameter check: -module 0x42::Test1 { - public fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } -} // end 0x42::Test1 -module 0x42::Test { - use 0x42::Test1; // resolved as: 0x42::Test1 - public fun test(): u64 { - Test1::apply(|(x: u64, y: u64): (u64, u64)| Add(x, y), 1, Test1::apply(|(x: u64, y: u64): (u64, u64)| Mul(x, y), 2, 1)) - } -} // end 0x42::Test - - -// -- Model dump after env processor check recursive struct definition: -module 0x42::Test1 { - public fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } -} // end 0x42::Test1 -module 0x42::Test { - use 0x42::Test1; // resolved as: 0x42::Test1 - public fun test(): u64 { - Test1::apply(|(x: u64, y: u64): (u64, u64)| Add(x, y), 1, Test1::apply(|(x: u64, y: u64): (u64, u64)| Mul(x, y), 2, 1)) - } -} // end 0x42::Test - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x42::Test1 { - public fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } -} // end 0x42::Test1 -module 0x42::Test { - use 0x42::Test1; // resolved as: 0x42::Test1 - public fun test(): u64 { - Test1::apply(|(x: u64, y: u64): (u64, u64)| Add(x, y), 1, Test1::apply(|(x: u64, y: u64): (u64, u64)| Mul(x, y), 2, 1)) - } -} // end 0x42::Test - - -// -- Model dump after env processor unused struct params check: -module 0x42::Test1 { - public fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } -} // end 0x42::Test1 -module 0x42::Test { - use 0x42::Test1; // resolved as: 0x42::Test1 - public fun test(): u64 { - Test1::apply(|(x: u64, y: u64): (u64, u64)| Add(x, y), 1, Test1::apply(|(x: u64, y: u64): (u64, u64)| Mul(x, y), 2, 1)) - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check before inlining: -module 0x42::Test1 { - public fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } -} // end 0x42::Test1 -module 0x42::Test { - use 0x42::Test1; // resolved as: 0x42::Test1 - public fun test(): u64 { - Test1::apply(|(x: u64, y: u64): (u64, u64)| Add(x, y), 1, Test1::apply(|(x: u64, y: u64): (u64, u64)| Mul(x, y), 2, 1)) - } -} // end 0x42::Test - - -// -- Model dump after env processor inlining: -module 0x42::Test1 { - public fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } -} // end 0x42::Test1 -module 0x42::Test { - use 0x42::Test1; // resolved as: 0x42::Test1 - public fun test(): u64 { - Test1::apply(|(x: u64, y: u64): (u64, u64)| Add(x, y), 1, Test1::apply(|(x: u64, y: u64): (u64, u64)| Mul(x, y), 2, 1)) - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check after inlining: -module 0x42::Test1 { - public fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } -} // end 0x42::Test1 -module 0x42::Test { - use 0x42::Test1; // resolved as: 0x42::Test1 - public fun test(): u64 { - Test1::apply(|(x: u64, y: u64): (u64, u64)| Add(x, y), 1, Test1::apply(|(x: u64, y: u64): (u64, u64)| Mul(x, y), 2, 1)) - } -} // end 0x42::Test - - -// -- Model dump after env processor acquires check: -module 0x42::Test1 { - public fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } -} // end 0x42::Test1 -module 0x42::Test { - use 0x42::Test1; // resolved as: 0x42::Test1 - public fun test(): u64 { - Test1::apply(|(x: u64, y: u64): (u64, u64)| Add(x, y), 1, Test1::apply(|(x: u64, y: u64): (u64, u64)| Mul(x, y), 2, 1)) - } -} // end 0x42::Test - - -// -- Model dump after env processor simplifier: -module 0x42::Test1 { - public fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } -} // end 0x42::Test1 -module 0x42::Test { - use 0x42::Test1; // resolved as: 0x42::Test1 - public fun test(): u64 { - Test1::apply(|(x: u64, y: u64): (u64, u64)| Add(x, y), 1, Test1::apply(|(x: u64, y: u64): (u64, u64)| Mul(x, y), 2, 1)) - } -} // end 0x42::Test - - -// -- Model dump after env processor lambda-lifting: -module 0x42::Test1 { - public fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } -} // end 0x42::Test1 -module 0x42::Test { - use 0x42::Test1; // resolved as: 0x42::Test1 - public fun test(): u64 { - Test1::apply(closure Test::test$lambda$1(), 1, Test1::apply(closure Test::test$lambda$2(), 2, 1)) - } - private fun test$lambda$1(x: u64,y: u64): u64 { - Add(x, y) - } - private fun test$lambda$2(x: u64,y: u64): u64 { - Mul(x, y) - } -} // end 0x42::Test - - -// -- Model dump after env processor specification checker: -module 0x42::Test1 { - public fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } -} // end 0x42::Test1 -module 0x42::Test { - use 0x42::Test1; // resolved as: 0x42::Test1 - public fun test(): u64 { - Test1::apply(closure Test::test$lambda$1(), 1, Test1::apply(closure Test::test$lambda$2(), 2, 1)) - } - private fun test$lambda$1(x: u64,y: u64): u64 { - Add(x, y) - } - private fun test$lambda$2(x: u64,y: u64): u64 { - Mul(x, y) - } -} // end 0x42::Test - - -// -- Model dump after env processor specification rewriter: -module 0x42::Test1 { - public fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } -} // end 0x42::Test1 -module 0x42::Test { - use 0x42::Test1; // resolved as: 0x42::Test1 - public fun test(): u64 { - Test1::apply(closure Test::test$lambda$1(), 1, Test1::apply(closure Test::test$lambda$2(), 2, 1)) - } - private fun test$lambda$1(x: u64,y: u64): u64 { - Add(x, y) - } - private fun test$lambda$2(x: u64,y: u64): u64 { - Mul(x, y) - } -} // end 0x42::Test - - Diagnostics: -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda/inline-parity/nested_lambda_module.move:4:9 - │ -4 │ f(x, y) - │ ^ - -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/nested_lambda_module.move:13:22 │ 13 │ Test1::apply(|x, y| x + y, 1, Test1::apply(|x, y| x * y, 2, 1)) │ ^^^^^^^^^^^^ -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/nested_lambda_module.move:13:52 │ 13 │ Test1::apply(|x, y| x + y, 1, Test1::apply(|x, y| x * y, 2, 1)) diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/non_lambda_arg.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/non_lambda_arg.lambda.exp index 1095994a02a62..2735e6c41b5c0 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/non_lambda_arg.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/non_lambda_arg.lambda.exp @@ -1,4 +1,4 @@ -// -- Model dump before env processor pipeline: +// -- Model dump before bytecode pipeline module 0x42::sort { use std::vector; public fun incorrect_sort(arr: &mut vector,a_less_b: |(T, T)|bool) { @@ -22,331 +22,20 @@ module 0x42::sort { } } // end 0x42::sort - -// -- Model dump after env processor unused checks: -module 0x42::sort { - use std::vector; - public fun incorrect_sort(arr: &mut vector,a_less_b: |(T, T)|bool) { - { - let n: u64 = vector::length(Freeze(false)(arr)); - sort::incorrect_sort_recursive(arr, 0, Sub(n, 1), a_less_b) - } - } - public fun incorrect_sort_recursive(arr: &mut vector,low: u64,high: u64,a_less_b: |(T, T)|bool) { - if Lt(low, high) { - { - let pi: u64 = Add(low, Div(high, 2)); - sort::incorrect_sort_recursive(arr, low, Sub(pi, 1), a_less_b); - sort::incorrect_sort_recursive(arr, Add(pi, 1), high, a_less_b); - Tuple() - } - } else { - Tuple() - }; - Tuple() - } -} // end 0x42::sort - - -// -- Model dump after env processor type parameter check: -module 0x42::sort { - use std::vector; - public fun incorrect_sort(arr: &mut vector,a_less_b: |(T, T)|bool) { - { - let n: u64 = vector::length(Freeze(false)(arr)); - sort::incorrect_sort_recursive(arr, 0, Sub(n, 1), a_less_b) - } - } - public fun incorrect_sort_recursive(arr: &mut vector,low: u64,high: u64,a_less_b: |(T, T)|bool) { - if Lt(low, high) { - { - let pi: u64 = Add(low, Div(high, 2)); - sort::incorrect_sort_recursive(arr, low, Sub(pi, 1), a_less_b); - sort::incorrect_sort_recursive(arr, Add(pi, 1), high, a_less_b); - Tuple() - } - } else { - Tuple() - }; - Tuple() - } -} // end 0x42::sort - - -// -- Model dump after env processor check recursive struct definition: -module 0x42::sort { - use std::vector; - public fun incorrect_sort(arr: &mut vector,a_less_b: |(T, T)|bool) { - { - let n: u64 = vector::length(Freeze(false)(arr)); - sort::incorrect_sort_recursive(arr, 0, Sub(n, 1), a_less_b) - } - } - public fun incorrect_sort_recursive(arr: &mut vector,low: u64,high: u64,a_less_b: |(T, T)|bool) { - if Lt(low, high) { - { - let pi: u64 = Add(low, Div(high, 2)); - sort::incorrect_sort_recursive(arr, low, Sub(pi, 1), a_less_b); - sort::incorrect_sort_recursive(arr, Add(pi, 1), high, a_less_b); - Tuple() - } - } else { - Tuple() - }; - Tuple() - } -} // end 0x42::sort - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x42::sort { - use std::vector; - public fun incorrect_sort(arr: &mut vector,a_less_b: |(T, T)|bool) { - { - let n: u64 = vector::length(Freeze(false)(arr)); - sort::incorrect_sort_recursive(arr, 0, Sub(n, 1), a_less_b) - } - } - public fun incorrect_sort_recursive(arr: &mut vector,low: u64,high: u64,a_less_b: |(T, T)|bool) { - if Lt(low, high) { - { - let pi: u64 = Add(low, Div(high, 2)); - sort::incorrect_sort_recursive(arr, low, Sub(pi, 1), a_less_b); - sort::incorrect_sort_recursive(arr, Add(pi, 1), high, a_less_b); - Tuple() - } - } else { - Tuple() - }; - Tuple() - } -} // end 0x42::sort - - -// -- Model dump after env processor unused struct params check: -module 0x42::sort { - use std::vector; - public fun incorrect_sort(arr: &mut vector,a_less_b: |(T, T)|bool) { - { - let n: u64 = vector::length(Freeze(false)(arr)); - sort::incorrect_sort_recursive(arr, 0, Sub(n, 1), a_less_b) - } - } - public fun incorrect_sort_recursive(arr: &mut vector,low: u64,high: u64,a_less_b: |(T, T)|bool) { - if Lt(low, high) { - { - let pi: u64 = Add(low, Div(high, 2)); - sort::incorrect_sort_recursive(arr, low, Sub(pi, 1), a_less_b); - sort::incorrect_sort_recursive(arr, Add(pi, 1), high, a_less_b); - Tuple() - } - } else { - Tuple() - }; - Tuple() - } -} // end 0x42::sort - - -// -- Model dump after env processor access and use check before inlining: -module 0x42::sort { - use std::vector; - public fun incorrect_sort(arr: &mut vector,a_less_b: |(T, T)|bool) { - { - let n: u64 = vector::length(Freeze(false)(arr)); - sort::incorrect_sort_recursive(arr, 0, Sub(n, 1), a_less_b) - } - } - public fun incorrect_sort_recursive(arr: &mut vector,low: u64,high: u64,a_less_b: |(T, T)|bool) { - if Lt(low, high) { - { - let pi: u64 = Add(low, Div(high, 2)); - sort::incorrect_sort_recursive(arr, low, Sub(pi, 1), a_less_b); - sort::incorrect_sort_recursive(arr, Add(pi, 1), high, a_less_b); - Tuple() - } - } else { - Tuple() - }; - Tuple() - } -} // end 0x42::sort - - -// -- Model dump after env processor inlining: -module 0x42::sort { - use std::vector; - public fun incorrect_sort(arr: &mut vector,a_less_b: |(T, T)|bool) { - { - let n: u64 = vector::length(Freeze(false)(arr)); - sort::incorrect_sort_recursive(arr, 0, Sub(n, 1), a_less_b) - } - } - public fun incorrect_sort_recursive(arr: &mut vector,low: u64,high: u64,a_less_b: |(T, T)|bool) { - if Lt(low, high) { - { - let pi: u64 = Add(low, Div(high, 2)); - sort::incorrect_sort_recursive(arr, low, Sub(pi, 1), a_less_b); - sort::incorrect_sort_recursive(arr, Add(pi, 1), high, a_less_b); - Tuple() - } - } else { - Tuple() - }; - Tuple() - } -} // end 0x42::sort - - -// -- Model dump after env processor access and use check after inlining: +// -- Sourcified model before bytecode pipeline module 0x42::sort { - use std::vector; - public fun incorrect_sort(arr: &mut vector,a_less_b: |(T, T)|bool) { - { - let n: u64 = vector::length(Freeze(false)(arr)); - sort::incorrect_sort_recursive(arr, 0, Sub(n, 1), a_less_b) - } - } - public fun incorrect_sort_recursive(arr: &mut vector,low: u64,high: u64,a_less_b: |(T, T)|bool) { - if Lt(low, high) { - { - let pi: u64 = Add(low, Div(high, 2)); - sort::incorrect_sort_recursive(arr, low, Sub(pi, 1), a_less_b); - sort::incorrect_sort_recursive(arr, Add(pi, 1), high, a_less_b); - Tuple() - } - } else { - Tuple() - }; - Tuple() - } -} // end 0x42::sort - - -// -- Model dump after env processor acquires check: -module 0x42::sort { - use std::vector; - public fun incorrect_sort(arr: &mut vector,a_less_b: |(T, T)|bool) { - { - let n: u64 = vector::length(Freeze(false)(arr)); - sort::incorrect_sort_recursive(arr, 0, Sub(n, 1), a_less_b) - } - } - public fun incorrect_sort_recursive(arr: &mut vector,low: u64,high: u64,a_less_b: |(T, T)|bool) { - if Lt(low, high) { - { - let pi: u64 = Add(low, Div(high, 2)); - sort::incorrect_sort_recursive(arr, low, Sub(pi, 1), a_less_b); - sort::incorrect_sort_recursive(arr, Add(pi, 1), high, a_less_b); - Tuple() - } - } else { - Tuple() + public fun incorrect_sort(arr: &mut vector, a_less_b: |(T, T)|bool) { + let n = 0x1::vector::length(/*freeze*/arr); + incorrect_sort_recursive(arr, 0, n - 1, a_less_b) + } + public fun incorrect_sort_recursive(arr: &mut vector, low: u64, high: u64, a_less_b: |(T, T)|bool) { + if (low < high) { + let pi = low + high / 2; + incorrect_sort_recursive(arr, low, pi - 1, a_less_b); + incorrect_sort_recursive(arr, pi + 1, high, a_less_b); }; - Tuple() } -} // end 0x42::sort - - -// -- Model dump after env processor simplifier: -module 0x42::sort { - use std::vector; - public fun incorrect_sort(arr: &mut vector,a_less_b: |(T, T)|bool) { - { - let n: u64 = vector::length(Freeze(false)(arr)); - sort::incorrect_sort_recursive(arr, 0, Sub(n, 1), a_less_b) - } - } - public fun incorrect_sort_recursive(arr: &mut vector,low: u64,high: u64,a_less_b: |(T, T)|bool) { - if Lt(low, high) { - { - let pi: u64 = Add(low, Div(high, 2)); - sort::incorrect_sort_recursive(arr, low, Sub(pi, 1), a_less_b); - sort::incorrect_sort_recursive(arr, Add(pi, 1), high, a_less_b); - Tuple() - } - } else { - Tuple() - }; - Tuple() - } -} // end 0x42::sort - - -// -- Model dump after env processor lambda-lifting: -module 0x42::sort { - use std::vector; - public fun incorrect_sort(arr: &mut vector,a_less_b: |(T, T)|bool) { - { - let n: u64 = vector::length(Freeze(false)(arr)); - sort::incorrect_sort_recursive(arr, 0, Sub(n, 1), a_less_b) - } - } - public fun incorrect_sort_recursive(arr: &mut vector,low: u64,high: u64,a_less_b: |(T, T)|bool) { - if Lt(low, high) { - { - let pi: u64 = Add(low, Div(high, 2)); - sort::incorrect_sort_recursive(arr, low, Sub(pi, 1), a_less_b); - sort::incorrect_sort_recursive(arr, Add(pi, 1), high, a_less_b); - Tuple() - } - } else { - Tuple() - }; - Tuple() - } -} // end 0x42::sort - - -// -- Model dump after env processor specification checker: -module 0x42::sort { - use std::vector; - public fun incorrect_sort(arr: &mut vector,a_less_b: |(T, T)|bool) { - { - let n: u64 = vector::length(Freeze(false)(arr)); - sort::incorrect_sort_recursive(arr, 0, Sub(n, 1), a_less_b) - } - } - public fun incorrect_sort_recursive(arr: &mut vector,low: u64,high: u64,a_less_b: |(T, T)|bool) { - if Lt(low, high) { - { - let pi: u64 = Add(low, Div(high, 2)); - sort::incorrect_sort_recursive(arr, low, Sub(pi, 1), a_less_b); - sort::incorrect_sort_recursive(arr, Add(pi, 1), high, a_less_b); - Tuple() - } - } else { - Tuple() - }; - Tuple() - } -} // end 0x42::sort - - -// -- Model dump after env processor specification rewriter: -module 0x42::sort { - use std::vector; - public fun incorrect_sort(arr: &mut vector,a_less_b: |(T, T)|bool) { - { - let n: u64 = vector::length(Freeze(false)(arr)); - sort::incorrect_sort_recursive(arr, 0, Sub(n, 1), a_less_b) - } - } - public fun incorrect_sort_recursive(arr: &mut vector,low: u64,high: u64,a_less_b: |(T, T)|bool) { - if Lt(low, high) { - { - let pi: u64 = Add(low, Div(high, 2)); - sort::incorrect_sort_recursive(arr, low, Sub(pi, 1), a_less_b); - sort::incorrect_sort_recursive(arr, Add(pi, 1), high, a_less_b); - Tuple() - } - } else { - Tuple() - }; - Tuple() - } -} // end 0x42::sort - +} ============ initial bytecode ================ diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/op_with_side_effect_49.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/op_with_side_effect_49.lambda.exp index a9a1dc063d69f..0a095be2e685d 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/op_with_side_effect_49.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/op_with_side_effect_49.lambda.exp @@ -1,189 +1,13 @@ -// -- Model dump before env processor pipeline: -module 0xc0ffee::m { - private fun call(f: |()|u64): u64 { - (f)() - } - public fun test(): u64 { - { - let x: u64 = 1; - Add(Add(x, m::call(|(): ()| x: u64 = Add(x, 1); - x)), m::call(|(): ()| x: u64 = Add(x, 7); - x)) - } - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor unused checks: -module 0xc0ffee::m { - private fun call(f: |()|u64): u64 { - (f)() - } - public fun test(): u64 { - { - let x: u64 = 1; - Add(Add(x, m::call(|(): ()| x: u64 = Add(x, 1); - x)), m::call(|(): ()| x: u64 = Add(x, 7); - x)) - } - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor type parameter check: -module 0xc0ffee::m { - private fun call(f: |()|u64): u64 { - (f)() - } - public fun test(): u64 { - { - let x: u64 = 1; - Add(Add(x, m::call(|(): ()| x: u64 = Add(x, 1); - x)), m::call(|(): ()| x: u64 = Add(x, 7); - x)) - } - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor check recursive struct definition: -module 0xc0ffee::m { - private fun call(f: |()|u64): u64 { - (f)() - } - public fun test(): u64 { - { - let x: u64 = 1; - Add(Add(x, m::call(|(): ()| x: u64 = Add(x, 1); - x)), m::call(|(): ()| x: u64 = Add(x, 7); - x)) - } - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor check cyclic type instantiation: -module 0xc0ffee::m { - private fun call(f: |()|u64): u64 { - (f)() - } - public fun test(): u64 { - { - let x: u64 = 1; - Add(Add(x, m::call(|(): ()| x: u64 = Add(x, 1); - x)), m::call(|(): ()| x: u64 = Add(x, 7); - x)) - } - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor unused struct params check: -module 0xc0ffee::m { - private fun call(f: |()|u64): u64 { - (f)() - } - public fun test(): u64 { - { - let x: u64 = 1; - Add(Add(x, m::call(|(): ()| x: u64 = Add(x, 1); - x)), m::call(|(): ()| x: u64 = Add(x, 7); - x)) - } - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor access and use check before inlining: -module 0xc0ffee::m { - private fun call(f: |()|u64): u64 { - (f)() - } - public fun test(): u64 { - { - let x: u64 = 1; - Add(Add(x, m::call(|(): ()| x: u64 = Add(x, 1); - x)), m::call(|(): ()| x: u64 = Add(x, 7); - x)) - } - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor inlining: -module 0xc0ffee::m { - private fun call(f: |()|u64): u64 { - (f)() - } - public fun test(): u64 { - { - let x: u64 = 1; - Add(Add(x, m::call(|(): ()| x: u64 = Add(x, 1); - x)), m::call(|(): ()| x: u64 = Add(x, 7); - x)) - } - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor access and use check after inlining: -module 0xc0ffee::m { - private fun call(f: |()|u64): u64 { - (f)() - } - public fun test(): u64 { - { - let x: u64 = 1; - Add(Add(x, m::call(|(): ()| x: u64 = Add(x, 1); - x)), m::call(|(): ()| x: u64 = Add(x, 7); - x)) - } - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor acquires check: -module 0xc0ffee::m { - private fun call(f: |()|u64): u64 { - (f)() - } - public fun test(): u64 { - { - let x: u64 = 1; - Add(Add(x, m::call(|(): ()| x: u64 = Add(x, 1); - x)), m::call(|(): ()| x: u64 = Add(x, 7); - x)) - } - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor simplifier: -module 0xc0ffee::m { - private fun call(f: |()|u64): u64 { - (f)() - } - public fun test(): u64 { - { - let x: u64 = 1; - Add(Add(x, m::call(|(): ()| x: u64 = Add(x, 1); - x)), m::call(|(): ()| x: u64 = Add(x, 7); - x)) - } - } -} // end 0xc0ffee::m - - Diagnostics: -error: captured variable `x` cannot be modified inside of a lambda - ┌─ tests/lambda/inline-parity/op_with_side_effect_49.move:9:22 +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. + ┌─ tests/lambda/inline-parity/op_with_side_effect_49.move:9:18 │ 9 │ x + call(|| {x = x + 1; x}) + call(|| {x = x + 7; x}) - │ ^ + │ ^^^^^^^^^^^^^^^^^ -error: captured variable `x` cannot be modified inside of a lambda - ┌─ tests/lambda/inline-parity/op_with_side_effect_49.move:9:48 +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. + ┌─ tests/lambda/inline-parity/op_with_side_effect_49.move:9:44 │ 9 │ x + call(|| {x = x + 1; x}) + call(|| {x = x + 7; x}) - │ ^ + │ ^^^^^^^^^^^^^^^^^ diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/options.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/options.lambda.exp index 01a7a59635ddc..85fe772d802ff 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/options.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/options.lambda.exp @@ -1,385 +1,6 @@ -// -- Model dump before env processor pipeline: -module 0x42::map_opt { - use std::option; - public fun map(t: 0x1::option::Option,f: |Element|OtherElement): 0x1::option::Option { - if option::is_some(Borrow(Immutable)(t)) { - option::some((f)(option::extract(Borrow(Mutable)(t)))) - } else { - option::none() - } - } -} // end 0x42::map_opt -module 0x42::Test { - use std::option; - use 0x42::map_opt; // resolved as: 0x42::map_opt - public fun test(): u64 { - { - let t: 0x1::option::Option = option::some(1); - { - let x: 0x1::option::Option = map_opt::map(t, |e: u64| Add(e, 1)); - option::extract(Borrow(Mutable)(x)) - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor unused checks: -module 0x42::map_opt { - use std::option; - public fun map(t: 0x1::option::Option,f: |Element|OtherElement): 0x1::option::Option { - if option::is_some(Borrow(Immutable)(t)) { - option::some((f)(option::extract(Borrow(Mutable)(t)))) - } else { - option::none() - } - } -} // end 0x42::map_opt -module 0x42::Test { - use std::option; - use 0x42::map_opt; // resolved as: 0x42::map_opt - public fun test(): u64 { - { - let t: 0x1::option::Option = option::some(1); - { - let x: 0x1::option::Option = map_opt::map(t, |e: u64| Add(e, 1)); - option::extract(Borrow(Mutable)(x)) - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor type parameter check: -module 0x42::map_opt { - use std::option; - public fun map(t: 0x1::option::Option,f: |Element|OtherElement): 0x1::option::Option { - if option::is_some(Borrow(Immutable)(t)) { - option::some((f)(option::extract(Borrow(Mutable)(t)))) - } else { - option::none() - } - } -} // end 0x42::map_opt -module 0x42::Test { - use std::option; - use 0x42::map_opt; // resolved as: 0x42::map_opt - public fun test(): u64 { - { - let t: 0x1::option::Option = option::some(1); - { - let x: 0x1::option::Option = map_opt::map(t, |e: u64| Add(e, 1)); - option::extract(Borrow(Mutable)(x)) - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor check recursive struct definition: -module 0x42::map_opt { - use std::option; - public fun map(t: 0x1::option::Option,f: |Element|OtherElement): 0x1::option::Option { - if option::is_some(Borrow(Immutable)(t)) { - option::some((f)(option::extract(Borrow(Mutable)(t)))) - } else { - option::none() - } - } -} // end 0x42::map_opt -module 0x42::Test { - use std::option; - use 0x42::map_opt; // resolved as: 0x42::map_opt - public fun test(): u64 { - { - let t: 0x1::option::Option = option::some(1); - { - let x: 0x1::option::Option = map_opt::map(t, |e: u64| Add(e, 1)); - option::extract(Borrow(Mutable)(x)) - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x42::map_opt { - use std::option; - public fun map(t: 0x1::option::Option,f: |Element|OtherElement): 0x1::option::Option { - if option::is_some(Borrow(Immutable)(t)) { - option::some((f)(option::extract(Borrow(Mutable)(t)))) - } else { - option::none() - } - } -} // end 0x42::map_opt -module 0x42::Test { - use std::option; - use 0x42::map_opt; // resolved as: 0x42::map_opt - public fun test(): u64 { - { - let t: 0x1::option::Option = option::some(1); - { - let x: 0x1::option::Option = map_opt::map(t, |e: u64| Add(e, 1)); - option::extract(Borrow(Mutable)(x)) - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor unused struct params check: -module 0x42::map_opt { - use std::option; - public fun map(t: 0x1::option::Option,f: |Element|OtherElement): 0x1::option::Option { - if option::is_some(Borrow(Immutable)(t)) { - option::some((f)(option::extract(Borrow(Mutable)(t)))) - } else { - option::none() - } - } -} // end 0x42::map_opt -module 0x42::Test { - use std::option; - use 0x42::map_opt; // resolved as: 0x42::map_opt - public fun test(): u64 { - { - let t: 0x1::option::Option = option::some(1); - { - let x: 0x1::option::Option = map_opt::map(t, |e: u64| Add(e, 1)); - option::extract(Borrow(Mutable)(x)) - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check before inlining: -module 0x42::map_opt { - use std::option; - public fun map(t: 0x1::option::Option,f: |Element|OtherElement): 0x1::option::Option { - if option::is_some(Borrow(Immutable)(t)) { - option::some((f)(option::extract(Borrow(Mutable)(t)))) - } else { - option::none() - } - } -} // end 0x42::map_opt -module 0x42::Test { - use std::option; - use 0x42::map_opt; // resolved as: 0x42::map_opt - public fun test(): u64 { - { - let t: 0x1::option::Option = option::some(1); - { - let x: 0x1::option::Option = map_opt::map(t, |e: u64| Add(e, 1)); - option::extract(Borrow(Mutable)(x)) - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor inlining: -module 0x42::map_opt { - use std::option; - public fun map(t: 0x1::option::Option,f: |Element|OtherElement): 0x1::option::Option { - if option::is_some(Borrow(Immutable)(t)) { - option::some((f)(option::extract(Borrow(Mutable)(t)))) - } else { - option::none() - } - } -} // end 0x42::map_opt -module 0x42::Test { - use std::option; - use 0x42::map_opt; // resolved as: 0x42::map_opt - public fun test(): u64 { - { - let t: 0x1::option::Option = option::some(1); - { - let x: 0x1::option::Option = map_opt::map(t, |e: u64| Add(e, 1)); - option::extract(Borrow(Mutable)(x)) - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check after inlining: -module 0x42::map_opt { - use std::option; - public fun map(t: 0x1::option::Option,f: |Element|OtherElement): 0x1::option::Option { - if option::is_some(Borrow(Immutable)(t)) { - option::some((f)(option::extract(Borrow(Mutable)(t)))) - } else { - option::none() - } - } -} // end 0x42::map_opt -module 0x42::Test { - use std::option; - use 0x42::map_opt; // resolved as: 0x42::map_opt - public fun test(): u64 { - { - let t: 0x1::option::Option = option::some(1); - { - let x: 0x1::option::Option = map_opt::map(t, |e: u64| Add(e, 1)); - option::extract(Borrow(Mutable)(x)) - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor acquires check: -module 0x42::map_opt { - use std::option; - public fun map(t: 0x1::option::Option,f: |Element|OtherElement): 0x1::option::Option { - if option::is_some(Borrow(Immutable)(t)) { - option::some((f)(option::extract(Borrow(Mutable)(t)))) - } else { - option::none() - } - } -} // end 0x42::map_opt -module 0x42::Test { - use std::option; - use 0x42::map_opt; // resolved as: 0x42::map_opt - public fun test(): u64 { - { - let t: 0x1::option::Option = option::some(1); - { - let x: 0x1::option::Option = map_opt::map(t, |e: u64| Add(e, 1)); - option::extract(Borrow(Mutable)(x)) - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor simplifier: -module 0x42::map_opt { - use std::option; - public fun map(t: 0x1::option::Option,f: |Element|OtherElement): 0x1::option::Option { - if option::is_some(Borrow(Immutable)(t)) { - option::some((f)(option::extract(Borrow(Mutable)(t)))) - } else { - option::none() - } - } -} // end 0x42::map_opt -module 0x42::Test { - use std::option; - use 0x42::map_opt; // resolved as: 0x42::map_opt - public fun test(): u64 { - { - let t: 0x1::option::Option = option::some(1); - { - let x: 0x1::option::Option = map_opt::map(t, |e: u64| Add(e, 1)); - option::extract(Borrow(Mutable)(x)) - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor lambda-lifting: -module 0x42::map_opt { - use std::option; - public fun map(t: 0x1::option::Option,f: |Element|OtherElement): 0x1::option::Option { - if option::is_some(Borrow(Immutable)(t)) { - option::some((f)(option::extract(Borrow(Mutable)(t)))) - } else { - option::none() - } - } -} // end 0x42::map_opt -module 0x42::Test { - use std::option; - use 0x42::map_opt; // resolved as: 0x42::map_opt - public fun test(): u64 { - { - let t: 0x1::option::Option = option::some(1); - { - let x: 0x1::option::Option = map_opt::map(t, closure Test::test$lambda$1()); - option::extract(Borrow(Mutable)(x)) - } - } - } - private fun test$lambda$1(e: u64): u64 { - Add(e, 1) - } -} // end 0x42::Test - - -// -- Model dump after env processor specification checker: -module 0x42::map_opt { - use std::option; - public fun map(t: 0x1::option::Option,f: |Element|OtherElement): 0x1::option::Option { - if option::is_some(Borrow(Immutable)(t)) { - option::some((f)(option::extract(Borrow(Mutable)(t)))) - } else { - option::none() - } - } -} // end 0x42::map_opt -module 0x42::Test { - use std::option; - use 0x42::map_opt; // resolved as: 0x42::map_opt - public fun test(): u64 { - { - let t: 0x1::option::Option = option::some(1); - { - let x: 0x1::option::Option = map_opt::map(t, closure Test::test$lambda$1()); - option::extract(Borrow(Mutable)(x)) - } - } - } - private fun test$lambda$1(e: u64): u64 { - Add(e, 1) - } -} // end 0x42::Test - - -// -- Model dump after env processor specification rewriter: -module 0x42::map_opt { - use std::option; - public fun map(t: 0x1::option::Option,f: |Element|OtherElement): 0x1::option::Option { - if option::is_some(Borrow(Immutable)(t)) { - option::some((f)(option::extract(Borrow(Mutable)(t)))) - } else { - option::none() - } - } -} // end 0x42::map_opt -module 0x42::Test { - use std::option; - use 0x42::map_opt; // resolved as: 0x42::map_opt - public fun test(): u64 { - { - let t: 0x1::option::Option = option::some(1); - { - let x: 0x1::option::Option = map_opt::map(t, closure Test::test$lambda$1()); - option::extract(Borrow(Mutable)(x)) - } - } - } - private fun test$lambda$1(e: u64): u64 { - Add(e, 1) - } -} // end 0x42::Test - - Diagnostics: -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda/inline-parity/options.move:7:26 - │ -7 │ option::some(f(option::extract(&mut t))) - │ ^ - -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/options.move:22:33 │ 22 │ let x = map_opt::map(t, |e| e + 1); diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/return_in_lambda.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/return_in_lambda.lambda.exp index bf94c6a9de653..4f0fc04132ffa 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/return_in_lambda.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/return_in_lambda.lambda.exp @@ -1,217 +1,6 @@ -// -- Model dump before env processor pipeline: -module 0x42::Test { - private fun adder(x: u64,y: u64): u64 { - Add(x, y) - } - private fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } - public fun main(): u64 { - Test::apply(|(x: u64, y: u64): (u64, u64)| return Test::adder(x, y), 10, 100) - } -} // end 0x42::Test - - -// -- Model dump after env processor unused checks: -module 0x42::Test { - private fun adder(x: u64,y: u64): u64 { - Add(x, y) - } - private fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } - public fun main(): u64 { - Test::apply(|(x: u64, y: u64): (u64, u64)| return Test::adder(x, y), 10, 100) - } -} // end 0x42::Test - - -// -- Model dump after env processor type parameter check: -module 0x42::Test { - private fun adder(x: u64,y: u64): u64 { - Add(x, y) - } - private fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } - public fun main(): u64 { - Test::apply(|(x: u64, y: u64): (u64, u64)| return Test::adder(x, y), 10, 100) - } -} // end 0x42::Test - - -// -- Model dump after env processor check recursive struct definition: -module 0x42::Test { - private fun adder(x: u64,y: u64): u64 { - Add(x, y) - } - private fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } - public fun main(): u64 { - Test::apply(|(x: u64, y: u64): (u64, u64)| return Test::adder(x, y), 10, 100) - } -} // end 0x42::Test - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x42::Test { - private fun adder(x: u64,y: u64): u64 { - Add(x, y) - } - private fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } - public fun main(): u64 { - Test::apply(|(x: u64, y: u64): (u64, u64)| return Test::adder(x, y), 10, 100) - } -} // end 0x42::Test - - -// -- Model dump after env processor unused struct params check: -module 0x42::Test { - private fun adder(x: u64,y: u64): u64 { - Add(x, y) - } - private fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } - public fun main(): u64 { - Test::apply(|(x: u64, y: u64): (u64, u64)| return Test::adder(x, y), 10, 100) - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check before inlining: -module 0x42::Test { - private fun adder(x: u64,y: u64): u64 { - Add(x, y) - } - private fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } - public fun main(): u64 { - Test::apply(|(x: u64, y: u64): (u64, u64)| return Test::adder(x, y), 10, 100) - } -} // end 0x42::Test - - -// -- Model dump after env processor inlining: -module 0x42::Test { - private fun adder(x: u64,y: u64): u64 { - Add(x, y) - } - private fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } - public fun main(): u64 { - Test::apply(|(x: u64, y: u64): (u64, u64)| return Test::adder(x, y), 10, 100) - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check after inlining: -module 0x42::Test { - private fun adder(x: u64,y: u64): u64 { - Add(x, y) - } - private fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } - public fun main(): u64 { - Test::apply(|(x: u64, y: u64): (u64, u64)| return Test::adder(x, y), 10, 100) - } -} // end 0x42::Test - - -// -- Model dump after env processor acquires check: -module 0x42::Test { - private fun adder(x: u64,y: u64): u64 { - Add(x, y) - } - private fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } - public fun main(): u64 { - Test::apply(|(x: u64, y: u64): (u64, u64)| return Test::adder(x, y), 10, 100) - } -} // end 0x42::Test - - -// -- Model dump after env processor simplifier: -module 0x42::Test { - private fun adder(x: u64,y: u64): u64 { - Add(x, y) - } - private fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } - public fun main(): u64 { - Test::apply(|(x: u64, y: u64): (u64, u64)| return Test::adder(x, y), 10, 100) - } -} // end 0x42::Test - - -// -- Model dump after env processor lambda-lifting: -module 0x42::Test { - private fun adder(x: u64,y: u64): u64 { - Add(x, y) - } - private fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } - public fun main(): u64 { - Test::apply(closure Test::main$lambda$1(), 10, 100) - } - private fun main$lambda$1(x: u64,y: u64): u64 { - return Test::adder(x, y) - } -} // end 0x42::Test - - -// -- Model dump after env processor specification checker: -module 0x42::Test { - private fun adder(x: u64,y: u64): u64 { - Add(x, y) - } - private fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } - public fun main(): u64 { - Test::apply(closure Test::main$lambda$1(), 10, 100) - } - private fun main$lambda$1(x: u64,y: u64): u64 { - return Test::adder(x, y) - } -} // end 0x42::Test - - -// -- Model dump after env processor specification rewriter: -module 0x42::Test { - private fun adder(x: u64,y: u64): u64 { - Add(x, y) - } - private fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } - public fun main(): u64 { - Test::apply(closure Test::main$lambda$1(), 10, 100) - } - private fun main$lambda$1(x: u64,y: u64): u64 { - return Test::adder(x, y) - } -} // end 0x42::Test - - Diagnostics: -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda/inline-parity/return_in_lambda.move:4:9 - │ -4 │ f(x, y) - │ ^ - -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/return_in_lambda.move:12:15 │ 12 │ apply(|x, y| { diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/return_in_lambda_typed.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/return_in_lambda_typed.lambda.exp index 1b2616f347de8..b73d94965e844 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/return_in_lambda_typed.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/return_in_lambda_typed.lambda.exp @@ -1,115 +1,3 @@ -// -- Model dump before env processor pipeline: -module 0x42::Test { - private inline fun adder(x: u64,y: u64): u64 { - Add(x, y) - } - private inline fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } - public fun main(): u64 { - Test::apply(|(x: u64, y: u64): (u64, u64)| return Test::adder(x, y), 10, 100); - Test::apply(|(x: u64, y: u64): (u64, u64)| return Test::adder(x, y), 10, 100); - Test::apply(|(x: u64, y: u64): (u64, u64)| return Test::adder(x, y), 10, 100) - } -} // end 0x42::Test - - -// -- Model dump after env processor unused checks: -module 0x42::Test { - private inline fun adder(x: u64,y: u64): u64 { - Add(x, y) - } - private inline fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } - public fun main(): u64 { - Test::apply(|(x: u64, y: u64): (u64, u64)| return Test::adder(x, y), 10, 100); - Test::apply(|(x: u64, y: u64): (u64, u64)| return Test::adder(x, y), 10, 100); - Test::apply(|(x: u64, y: u64): (u64, u64)| return Test::adder(x, y), 10, 100) - } -} // end 0x42::Test - - -// -- Model dump after env processor type parameter check: -module 0x42::Test { - private inline fun adder(x: u64,y: u64): u64 { - Add(x, y) - } - private inline fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } - public fun main(): u64 { - Test::apply(|(x: u64, y: u64): (u64, u64)| return Test::adder(x, y), 10, 100); - Test::apply(|(x: u64, y: u64): (u64, u64)| return Test::adder(x, y), 10, 100); - Test::apply(|(x: u64, y: u64): (u64, u64)| return Test::adder(x, y), 10, 100) - } -} // end 0x42::Test - - -// -- Model dump after env processor check recursive struct definition: -module 0x42::Test { - private inline fun adder(x: u64,y: u64): u64 { - Add(x, y) - } - private inline fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } - public fun main(): u64 { - Test::apply(|(x: u64, y: u64): (u64, u64)| return Test::adder(x, y), 10, 100); - Test::apply(|(x: u64, y: u64): (u64, u64)| return Test::adder(x, y), 10, 100); - Test::apply(|(x: u64, y: u64): (u64, u64)| return Test::adder(x, y), 10, 100) - } -} // end 0x42::Test - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x42::Test { - private inline fun adder(x: u64,y: u64): u64 { - Add(x, y) - } - private inline fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } - public fun main(): u64 { - Test::apply(|(x: u64, y: u64): (u64, u64)| return Test::adder(x, y), 10, 100); - Test::apply(|(x: u64, y: u64): (u64, u64)| return Test::adder(x, y), 10, 100); - Test::apply(|(x: u64, y: u64): (u64, u64)| return Test::adder(x, y), 10, 100) - } -} // end 0x42::Test - - -// -- Model dump after env processor unused struct params check: -module 0x42::Test { - private inline fun adder(x: u64,y: u64): u64 { - Add(x, y) - } - private inline fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } - public fun main(): u64 { - Test::apply(|(x: u64, y: u64): (u64, u64)| return Test::adder(x, y), 10, 100); - Test::apply(|(x: u64, y: u64): (u64, u64)| return Test::adder(x, y), 10, 100); - Test::apply(|(x: u64, y: u64): (u64, u64)| return Test::adder(x, y), 10, 100) - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check before inlining: -module 0x42::Test { - private inline fun adder(x: u64,y: u64): u64 { - Add(x, y) - } - private inline fun apply(f: |(u64, u64)|u64,x: u64,y: u64): u64 { - (f)(x, y) - } - public fun main(): u64 { - Test::apply(|(x: u64, y: u64): (u64, u64)| return Test::adder(x, y), 10, 100); - Test::apply(|(x: u64, y: u64): (u64, u64)| return Test::adder(x, y), 10, 100); - Test::apply(|(x: u64, y: u64): (u64, u64)| return Test::adder(x, y), 10, 100) - } -} // end 0x42::Test - - Diagnostics: error: Return not currently supported in function-typed arguments (lambda expressions) diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/same_names.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/same_names.lambda.exp index c473f81866042..f7959b9d9ae89 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/same_names.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/same_names.lambda.exp @@ -1,483 +1,6 @@ -// -- Model dump before env processor pipeline: -module 0x42::b { - struct MyOtherList { - len: u64, - } - public fun len(self: &MyOtherList): u64 { - select b::MyOtherList.len<&MyOtherList>(self) - } -} // end 0x42::b -module 0x42::a { - struct MyList { - len: u64, - } - public fun len(self: &MyList): u64 { - select a::MyList.len<&MyList>(self) - } -} // end 0x42::a -module 0x42::c { - use 0x42::a; // resolved as: 0x42::a - use 0x42::b; // resolved as: 0x42::b - private fun foo(f: |(a::MyList, b::MyOtherList)|,x: a::MyList,y: b::MyOtherList) { - (f)(x, y) - } - private fun test(x: a::MyList,y: b::MyOtherList) { - c::foo(|(x: a::MyList, y: b::MyOtherList): (a::MyList, b::MyOtherList)| if Eq(Add(a::len(Borrow(Immutable)(x)), b::len(Borrow(Immutable)(y))), 1) { - Tuple() - } else { - Abort(1) - }, x, y) - } -} // end 0x42::c - - -// -- Model dump after env processor unused checks: -module 0x42::b { - struct MyOtherList { - len: u64, - } - public fun len(self: &MyOtherList): u64 { - select b::MyOtherList.len<&MyOtherList>(self) - } -} // end 0x42::b -module 0x42::a { - struct MyList { - len: u64, - } - public fun len(self: &MyList): u64 { - select a::MyList.len<&MyList>(self) - } -} // end 0x42::a -module 0x42::c { - use 0x42::a; // resolved as: 0x42::a - use 0x42::b; // resolved as: 0x42::b - private fun foo(f: |(a::MyList, b::MyOtherList)|,x: a::MyList,y: b::MyOtherList) { - (f)(x, y) - } - private fun test(x: a::MyList,y: b::MyOtherList) { - c::foo(|(x: a::MyList, y: b::MyOtherList): (a::MyList, b::MyOtherList)| if Eq(Add(a::len(Borrow(Immutable)(x)), b::len(Borrow(Immutable)(y))), 1) { - Tuple() - } else { - Abort(1) - }, x, y) - } -} // end 0x42::c - - -// -- Model dump after env processor type parameter check: -module 0x42::b { - struct MyOtherList { - len: u64, - } - public fun len(self: &MyOtherList): u64 { - select b::MyOtherList.len<&MyOtherList>(self) - } -} // end 0x42::b -module 0x42::a { - struct MyList { - len: u64, - } - public fun len(self: &MyList): u64 { - select a::MyList.len<&MyList>(self) - } -} // end 0x42::a -module 0x42::c { - use 0x42::a; // resolved as: 0x42::a - use 0x42::b; // resolved as: 0x42::b - private fun foo(f: |(a::MyList, b::MyOtherList)|,x: a::MyList,y: b::MyOtherList) { - (f)(x, y) - } - private fun test(x: a::MyList,y: b::MyOtherList) { - c::foo(|(x: a::MyList, y: b::MyOtherList): (a::MyList, b::MyOtherList)| if Eq(Add(a::len(Borrow(Immutable)(x)), b::len(Borrow(Immutable)(y))), 1) { - Tuple() - } else { - Abort(1) - }, x, y) - } -} // end 0x42::c - - -// -- Model dump after env processor check recursive struct definition: -module 0x42::b { - struct MyOtherList { - len: u64, - } - public fun len(self: &MyOtherList): u64 { - select b::MyOtherList.len<&MyOtherList>(self) - } -} // end 0x42::b -module 0x42::a { - struct MyList { - len: u64, - } - public fun len(self: &MyList): u64 { - select a::MyList.len<&MyList>(self) - } -} // end 0x42::a -module 0x42::c { - use 0x42::a; // resolved as: 0x42::a - use 0x42::b; // resolved as: 0x42::b - private fun foo(f: |(a::MyList, b::MyOtherList)|,x: a::MyList,y: b::MyOtherList) { - (f)(x, y) - } - private fun test(x: a::MyList,y: b::MyOtherList) { - c::foo(|(x: a::MyList, y: b::MyOtherList): (a::MyList, b::MyOtherList)| if Eq(Add(a::len(Borrow(Immutable)(x)), b::len(Borrow(Immutable)(y))), 1) { - Tuple() - } else { - Abort(1) - }, x, y) - } -} // end 0x42::c - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x42::b { - struct MyOtherList { - len: u64, - } - public fun len(self: &MyOtherList): u64 { - select b::MyOtherList.len<&MyOtherList>(self) - } -} // end 0x42::b -module 0x42::a { - struct MyList { - len: u64, - } - public fun len(self: &MyList): u64 { - select a::MyList.len<&MyList>(self) - } -} // end 0x42::a -module 0x42::c { - use 0x42::a; // resolved as: 0x42::a - use 0x42::b; // resolved as: 0x42::b - private fun foo(f: |(a::MyList, b::MyOtherList)|,x: a::MyList,y: b::MyOtherList) { - (f)(x, y) - } - private fun test(x: a::MyList,y: b::MyOtherList) { - c::foo(|(x: a::MyList, y: b::MyOtherList): (a::MyList, b::MyOtherList)| if Eq(Add(a::len(Borrow(Immutable)(x)), b::len(Borrow(Immutable)(y))), 1) { - Tuple() - } else { - Abort(1) - }, x, y) - } -} // end 0x42::c - - -// -- Model dump after env processor unused struct params check: -module 0x42::b { - struct MyOtherList { - len: u64, - } - public fun len(self: &MyOtherList): u64 { - select b::MyOtherList.len<&MyOtherList>(self) - } -} // end 0x42::b -module 0x42::a { - struct MyList { - len: u64, - } - public fun len(self: &MyList): u64 { - select a::MyList.len<&MyList>(self) - } -} // end 0x42::a -module 0x42::c { - use 0x42::a; // resolved as: 0x42::a - use 0x42::b; // resolved as: 0x42::b - private fun foo(f: |(a::MyList, b::MyOtherList)|,x: a::MyList,y: b::MyOtherList) { - (f)(x, y) - } - private fun test(x: a::MyList,y: b::MyOtherList) { - c::foo(|(x: a::MyList, y: b::MyOtherList): (a::MyList, b::MyOtherList)| if Eq(Add(a::len(Borrow(Immutable)(x)), b::len(Borrow(Immutable)(y))), 1) { - Tuple() - } else { - Abort(1) - }, x, y) - } -} // end 0x42::c - - -// -- Model dump after env processor access and use check before inlining: -module 0x42::b { - struct MyOtherList { - len: u64, - } - public fun len(self: &MyOtherList): u64 { - select b::MyOtherList.len<&MyOtherList>(self) - } -} // end 0x42::b -module 0x42::a { - struct MyList { - len: u64, - } - public fun len(self: &MyList): u64 { - select a::MyList.len<&MyList>(self) - } -} // end 0x42::a -module 0x42::c { - use 0x42::a; // resolved as: 0x42::a - use 0x42::b; // resolved as: 0x42::b - private fun foo(f: |(a::MyList, b::MyOtherList)|,x: a::MyList,y: b::MyOtherList) { - (f)(x, y) - } - private fun test(x: a::MyList,y: b::MyOtherList) { - c::foo(|(x: a::MyList, y: b::MyOtherList): (a::MyList, b::MyOtherList)| if Eq(Add(a::len(Borrow(Immutable)(x)), b::len(Borrow(Immutable)(y))), 1) { - Tuple() - } else { - Abort(1) - }, x, y) - } -} // end 0x42::c - - -// -- Model dump after env processor inlining: -module 0x42::b { - struct MyOtherList { - len: u64, - } - public fun len(self: &MyOtherList): u64 { - select b::MyOtherList.len<&MyOtherList>(self) - } -} // end 0x42::b -module 0x42::a { - struct MyList { - len: u64, - } - public fun len(self: &MyList): u64 { - select a::MyList.len<&MyList>(self) - } -} // end 0x42::a -module 0x42::c { - use 0x42::a; // resolved as: 0x42::a - use 0x42::b; // resolved as: 0x42::b - private fun foo(f: |(a::MyList, b::MyOtherList)|,x: a::MyList,y: b::MyOtherList) { - (f)(x, y) - } - private fun test(x: a::MyList,y: b::MyOtherList) { - c::foo(|(x: a::MyList, y: b::MyOtherList): (a::MyList, b::MyOtherList)| if Eq(Add(a::len(Borrow(Immutable)(x)), b::len(Borrow(Immutable)(y))), 1) { - Tuple() - } else { - Abort(1) - }, x, y) - } -} // end 0x42::c - - -// -- Model dump after env processor access and use check after inlining: -module 0x42::b { - struct MyOtherList { - len: u64, - } - public fun len(self: &MyOtherList): u64 { - select b::MyOtherList.len<&MyOtherList>(self) - } -} // end 0x42::b -module 0x42::a { - struct MyList { - len: u64, - } - public fun len(self: &MyList): u64 { - select a::MyList.len<&MyList>(self) - } -} // end 0x42::a -module 0x42::c { - use 0x42::a; // resolved as: 0x42::a - use 0x42::b; // resolved as: 0x42::b - private fun foo(f: |(a::MyList, b::MyOtherList)|,x: a::MyList,y: b::MyOtherList) { - (f)(x, y) - } - private fun test(x: a::MyList,y: b::MyOtherList) { - c::foo(|(x: a::MyList, y: b::MyOtherList): (a::MyList, b::MyOtherList)| if Eq(Add(a::len(Borrow(Immutable)(x)), b::len(Borrow(Immutable)(y))), 1) { - Tuple() - } else { - Abort(1) - }, x, y) - } -} // end 0x42::c - - -// -- Model dump after env processor acquires check: -module 0x42::b { - struct MyOtherList { - len: u64, - } - public fun len(self: &MyOtherList): u64 { - select b::MyOtherList.len<&MyOtherList>(self) - } -} // end 0x42::b -module 0x42::a { - struct MyList { - len: u64, - } - public fun len(self: &MyList): u64 { - select a::MyList.len<&MyList>(self) - } -} // end 0x42::a -module 0x42::c { - use 0x42::a; // resolved as: 0x42::a - use 0x42::b; // resolved as: 0x42::b - private fun foo(f: |(a::MyList, b::MyOtherList)|,x: a::MyList,y: b::MyOtherList) { - (f)(x, y) - } - private fun test(x: a::MyList,y: b::MyOtherList) { - c::foo(|(x: a::MyList, y: b::MyOtherList): (a::MyList, b::MyOtherList)| if Eq(Add(a::len(Borrow(Immutable)(x)), b::len(Borrow(Immutable)(y))), 1) { - Tuple() - } else { - Abort(1) - }, x, y) - } -} // end 0x42::c - - -// -- Model dump after env processor simplifier: -module 0x42::b { - struct MyOtherList { - len: u64, - } - public fun len(self: &MyOtherList): u64 { - select b::MyOtherList.len<&MyOtherList>(self) - } -} // end 0x42::b -module 0x42::a { - struct MyList { - len: u64, - } - public fun len(self: &MyList): u64 { - select a::MyList.len<&MyList>(self) - } -} // end 0x42::a -module 0x42::c { - use 0x42::a; // resolved as: 0x42::a - use 0x42::b; // resolved as: 0x42::b - private fun foo(f: |(a::MyList, b::MyOtherList)|,x: a::MyList,y: b::MyOtherList) { - (f)(x, y) - } - private fun test(x: a::MyList,y: b::MyOtherList) { - c::foo(|(x: a::MyList, y: b::MyOtherList): (a::MyList, b::MyOtherList)| if Eq(Add(a::len(Borrow(Immutable)(x)), b::len(Borrow(Immutable)(y))), 1) { - Tuple() - } else { - Abort(1) - }, x, y) - } -} // end 0x42::c - - -// -- Model dump after env processor lambda-lifting: -module 0x42::b { - struct MyOtherList { - len: u64, - } - public fun len(self: &MyOtherList): u64 { - select b::MyOtherList.len<&MyOtherList>(self) - } -} // end 0x42::b -module 0x42::a { - struct MyList { - len: u64, - } - public fun len(self: &MyList): u64 { - select a::MyList.len<&MyList>(self) - } -} // end 0x42::a -module 0x42::c { - use 0x42::a; // resolved as: 0x42::a - use 0x42::b; // resolved as: 0x42::b - private fun foo(f: |(a::MyList, b::MyOtherList)|,x: a::MyList,y: b::MyOtherList) { - (f)(x, y) - } - private fun test(x: a::MyList,y: b::MyOtherList) { - c::foo(closure c::test$lambda$1(), x, y) - } - private fun test$lambda$1(x: a::MyList,y: b::MyOtherList) { - if Eq(Add(a::len(Borrow(Immutable)(x)), b::len(Borrow(Immutable)(y))), 1) { - Tuple() - } else { - Abort(1) - } - } -} // end 0x42::c - - -// -- Model dump after env processor specification checker: -module 0x42::b { - struct MyOtherList { - len: u64, - } - public fun len(self: &MyOtherList): u64 { - select b::MyOtherList.len<&MyOtherList>(self) - } -} // end 0x42::b -module 0x42::a { - struct MyList { - len: u64, - } - public fun len(self: &MyList): u64 { - select a::MyList.len<&MyList>(self) - } -} // end 0x42::a -module 0x42::c { - use 0x42::a; // resolved as: 0x42::a - use 0x42::b; // resolved as: 0x42::b - private fun foo(f: |(a::MyList, b::MyOtherList)|,x: a::MyList,y: b::MyOtherList) { - (f)(x, y) - } - private fun test(x: a::MyList,y: b::MyOtherList) { - c::foo(closure c::test$lambda$1(), x, y) - } - private fun test$lambda$1(x: a::MyList,y: b::MyOtherList) { - if Eq(Add(a::len(Borrow(Immutable)(x)), b::len(Borrow(Immutable)(y))), 1) { - Tuple() - } else { - Abort(1) - } - } -} // end 0x42::c - - -// -- Model dump after env processor specification rewriter: -module 0x42::b { - struct MyOtherList { - len: u64, - } - public fun len(self: &MyOtherList): u64 { - select b::MyOtherList.len<&MyOtherList>(self) - } -} // end 0x42::b -module 0x42::a { - struct MyList { - len: u64, - } - public fun len(self: &MyList): u64 { - select a::MyList.len<&MyList>(self) - } -} // end 0x42::a -module 0x42::c { - use 0x42::a; // resolved as: 0x42::a - use 0x42::b; // resolved as: 0x42::b - private fun foo(f: |(a::MyList, b::MyOtherList)|,x: a::MyList,y: b::MyOtherList) { - (f)(x, y) - } - private fun test(x: a::MyList,y: b::MyOtherList) { - c::foo(closure c::test$lambda$1(), x, y) - } - private fun test$lambda$1(x: a::MyList,y: b::MyOtherList) { - if Eq(Add(a::len(Borrow(Immutable)(x)), b::len(Borrow(Immutable)(y))), 1) { - Tuple() - } else { - Abort(1) - } - } -} // end 0x42::c - - Diagnostics: -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda/inline-parity/same_names.move:24:9 - │ -24 │ f(x, y) - │ ^ - -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/same_names.move:30:13 │ 30 │ foo(|x, y| { assert!(x.len() + y.len() == 1, 1) }, x, y) diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/shadowing.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/shadowing.lambda.exp index 813306a5f3a94..f2328c460e9b3 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/shadowing.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/shadowing.lambda.exp @@ -1,257 +1,11 @@ -// -- Model dump before env processor pipeline: -module 0x42::Test { - public fun foo(f: |u64|) { - { - let _x: u64 = 3; - (f)(_x); - Tuple() - } - } - public fun test_shadowing() { - { - let _x: u64 = 1; - Test::foo(|y: u64| _x: u64 = y); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor unused checks: -module 0x42::Test { - public fun foo(f: |u64|) { - { - let _x: u64 = 3; - (f)(_x); - Tuple() - } - } - public fun test_shadowing() { - { - let _x: u64 = 1; - Test::foo(|y: u64| _x: u64 = y); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor type parameter check: -module 0x42::Test { - public fun foo(f: |u64|) { - { - let _x: u64 = 3; - (f)(_x); - Tuple() - } - } - public fun test_shadowing() { - { - let _x: u64 = 1; - Test::foo(|y: u64| _x: u64 = y); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor check recursive struct definition: -module 0x42::Test { - public fun foo(f: |u64|) { - { - let _x: u64 = 3; - (f)(_x); - Tuple() - } - } - public fun test_shadowing() { - { - let _x: u64 = 1; - Test::foo(|y: u64| _x: u64 = y); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x42::Test { - public fun foo(f: |u64|) { - { - let _x: u64 = 3; - (f)(_x); - Tuple() - } - } - public fun test_shadowing() { - { - let _x: u64 = 1; - Test::foo(|y: u64| _x: u64 = y); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor unused struct params check: -module 0x42::Test { - public fun foo(f: |u64|) { - { - let _x: u64 = 3; - (f)(_x); - Tuple() - } - } - public fun test_shadowing() { - { - let _x: u64 = 1; - Test::foo(|y: u64| _x: u64 = y); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check before inlining: -module 0x42::Test { - public fun foo(f: |u64|) { - { - let _x: u64 = 3; - (f)(_x); - Tuple() - } - } - public fun test_shadowing() { - { - let _x: u64 = 1; - Test::foo(|y: u64| _x: u64 = y); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor inlining: -module 0x42::Test { - public fun foo(f: |u64|) { - { - let _x: u64 = 3; - (f)(_x); - Tuple() - } - } - public fun test_shadowing() { - { - let _x: u64 = 1; - Test::foo(|y: u64| _x: u64 = y); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check after inlining: -module 0x42::Test { - public fun foo(f: |u64|) { - { - let _x: u64 = 3; - (f)(_x); - Tuple() - } - } - public fun test_shadowing() { - { - let _x: u64 = 1; - Test::foo(|y: u64| _x: u64 = y); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor acquires check: -module 0x42::Test { - public fun foo(f: |u64|) { - { - let _x: u64 = 3; - (f)(_x); - Tuple() - } - } - public fun test_shadowing() { - { - let _x: u64 = 1; - Test::foo(|y: u64| _x: u64 = y); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor simplifier: -module 0x42::Test { - public fun foo(f: |u64|) { - (f)(3); - Tuple() - } - public fun test_shadowing() { - { - let _x: u64 = 1; - Test::foo(|y: u64| _x: u64 = y); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } -} // end 0x42::Test - - Diagnostics: -error: captured variable `_x` cannot be modified inside of a lambda - ┌─ tests/lambda/inline-parity/shadowing.move:12:13 +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. + ┌─ tests/lambda/inline-parity/shadowing.move:11:13 │ -12 │ _x = y // We expect this to assign 3 via foo if renaming works correctly. If not it would - │ ^^ +11 │ foo(|y| { + │ ╭─────────────^ +12 │ │ _x = y // We expect this to assign 3 via foo if renaming works correctly. If not it would +13 │ │ // have the value 1. +14 │ │ }); + │ ╰─────────^ diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/shadowing_renamed.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/shadowing_renamed.lambda.exp index 57fbdb400d002..602fc43a520ea 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/shadowing_renamed.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/shadowing_renamed.lambda.exp @@ -1,257 +1,11 @@ -// -- Model dump before env processor pipeline: -module 0x42::Test { - public fun foo(f: |u64|) { - { - let x: u64 = 3; - (f)(x); - Tuple() - } - } - public fun test_shadowing() { - { - let x: u64 = 1; - Test::foo(|y: u64| x: u64 = y); - if Eq(x, 3) { - Tuple() - } else { - Abort(0) - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor unused checks: -module 0x42::Test { - public fun foo(f: |u64|) { - { - let x: u64 = 3; - (f)(x); - Tuple() - } - } - public fun test_shadowing() { - { - let x: u64 = 1; - Test::foo(|y: u64| x: u64 = y); - if Eq(x, 3) { - Tuple() - } else { - Abort(0) - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor type parameter check: -module 0x42::Test { - public fun foo(f: |u64|) { - { - let x: u64 = 3; - (f)(x); - Tuple() - } - } - public fun test_shadowing() { - { - let x: u64 = 1; - Test::foo(|y: u64| x: u64 = y); - if Eq(x, 3) { - Tuple() - } else { - Abort(0) - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor check recursive struct definition: -module 0x42::Test { - public fun foo(f: |u64|) { - { - let x: u64 = 3; - (f)(x); - Tuple() - } - } - public fun test_shadowing() { - { - let x: u64 = 1; - Test::foo(|y: u64| x: u64 = y); - if Eq(x, 3) { - Tuple() - } else { - Abort(0) - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x42::Test { - public fun foo(f: |u64|) { - { - let x: u64 = 3; - (f)(x); - Tuple() - } - } - public fun test_shadowing() { - { - let x: u64 = 1; - Test::foo(|y: u64| x: u64 = y); - if Eq(x, 3) { - Tuple() - } else { - Abort(0) - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor unused struct params check: -module 0x42::Test { - public fun foo(f: |u64|) { - { - let x: u64 = 3; - (f)(x); - Tuple() - } - } - public fun test_shadowing() { - { - let x: u64 = 1; - Test::foo(|y: u64| x: u64 = y); - if Eq(x, 3) { - Tuple() - } else { - Abort(0) - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check before inlining: -module 0x42::Test { - public fun foo(f: |u64|) { - { - let x: u64 = 3; - (f)(x); - Tuple() - } - } - public fun test_shadowing() { - { - let x: u64 = 1; - Test::foo(|y: u64| x: u64 = y); - if Eq(x, 3) { - Tuple() - } else { - Abort(0) - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor inlining: -module 0x42::Test { - public fun foo(f: |u64|) { - { - let x: u64 = 3; - (f)(x); - Tuple() - } - } - public fun test_shadowing() { - { - let x: u64 = 1; - Test::foo(|y: u64| x: u64 = y); - if Eq(x, 3) { - Tuple() - } else { - Abort(0) - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check after inlining: -module 0x42::Test { - public fun foo(f: |u64|) { - { - let x: u64 = 3; - (f)(x); - Tuple() - } - } - public fun test_shadowing() { - { - let x: u64 = 1; - Test::foo(|y: u64| x: u64 = y); - if Eq(x, 3) { - Tuple() - } else { - Abort(0) - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor acquires check: -module 0x42::Test { - public fun foo(f: |u64|) { - { - let x: u64 = 3; - (f)(x); - Tuple() - } - } - public fun test_shadowing() { - { - let x: u64 = 1; - Test::foo(|y: u64| x: u64 = y); - if Eq(x, 3) { - Tuple() - } else { - Abort(0) - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor simplifier: -module 0x42::Test { - public fun foo(f: |u64|) { - (f)(3); - Tuple() - } - public fun test_shadowing() { - { - let x: u64 = 1; - Test::foo(|y: u64| x: u64 = y); - if Eq(x, 3) { - Tuple() - } else { - Abort(0) - } - } - } -} // end 0x42::Test - - Diagnostics: -error: captured variable `x` cannot be modified inside of a lambda - ┌─ tests/lambda/inline-parity/shadowing_renamed.move:12:13 +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. + ┌─ tests/lambda/inline-parity/shadowing_renamed.move:11:13 │ -12 │ x = y // We expect this to assign 3 via foo if renaming works correctly. If not it would - │ ^ +11 │ foo(|y| { + │ ╭─────────────^ +12 │ │ x = y // We expect this to assign 3 via foo if renaming works correctly. If not it would +13 │ │ // have the value 1. +14 │ │ }); + │ ╰─────────^ diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/shadowing_renamed_param.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/shadowing_renamed_param.lambda.exp index bf8fa10008821..a0267b472800a 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/shadowing_renamed_param.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/shadowing_renamed_param.lambda.exp @@ -1,586 +1,41 @@ -// -- Model dump before env processor pipeline: -module 0x42::Test { - public fun foo(f: |u64|,x: u64) { - (f)(x); - Tuple() - } - public fun foo2(f: |u64|,x: u64) { - { - let x: u64 = x; - (f)(x); - Tuple() - } - } - public fun test_shadowing(x: u64) { - Test::foo(|y: u64| x: u64 = y, 3); - if Eq(x, 3) { - Tuple() - } else { - Abort(0) - }; - Test::foo2(|y: u64| x: u64 = y, 5); - if Eq(x, 5) { - Tuple() - } else { - Abort(0) - } - } - public fun test_shadowing2(q: u64) { - { - let x: u64 = q; - Test::foo(|y: u64| x: u64 = y, 3); - if Eq(x, 3) { - Tuple() - } else { - Abort(0) - }; - Test::foo2(|y: u64| x: u64 = y, 5); - if Eq(x, 5) { - Tuple() - } else { - Abort(0) - } - } - } - private fun test_shadowing_entry() { - Test::test_shadowing(1); - Test::test_shadowing2(1) - } -} // end 0x42::Test - - -// -- Model dump after env processor unused checks: -module 0x42::Test { - public fun foo(f: |u64|,x: u64) { - (f)(x); - Tuple() - } - public fun foo2(f: |u64|,x: u64) { - { - let x: u64 = x; - (f)(x); - Tuple() - } - } - public fun test_shadowing(x: u64) { - Test::foo(|y: u64| x: u64 = y, 3); - if Eq(x, 3) { - Tuple() - } else { - Abort(0) - }; - Test::foo2(|y: u64| x: u64 = y, 5); - if Eq(x, 5) { - Tuple() - } else { - Abort(0) - } - } - public fun test_shadowing2(q: u64) { - { - let x: u64 = q; - Test::foo(|y: u64| x: u64 = y, 3); - if Eq(x, 3) { - Tuple() - } else { - Abort(0) - }; - Test::foo2(|y: u64| x: u64 = y, 5); - if Eq(x, 5) { - Tuple() - } else { - Abort(0) - } - } - } - private fun test_shadowing_entry() { - Test::test_shadowing(1); - Test::test_shadowing2(1) - } -} // end 0x42::Test - - -// -- Model dump after env processor type parameter check: -module 0x42::Test { - public fun foo(f: |u64|,x: u64) { - (f)(x); - Tuple() - } - public fun foo2(f: |u64|,x: u64) { - { - let x: u64 = x; - (f)(x); - Tuple() - } - } - public fun test_shadowing(x: u64) { - Test::foo(|y: u64| x: u64 = y, 3); - if Eq(x, 3) { - Tuple() - } else { - Abort(0) - }; - Test::foo2(|y: u64| x: u64 = y, 5); - if Eq(x, 5) { - Tuple() - } else { - Abort(0) - } - } - public fun test_shadowing2(q: u64) { - { - let x: u64 = q; - Test::foo(|y: u64| x: u64 = y, 3); - if Eq(x, 3) { - Tuple() - } else { - Abort(0) - }; - Test::foo2(|y: u64| x: u64 = y, 5); - if Eq(x, 5) { - Tuple() - } else { - Abort(0) - } - } - } - private fun test_shadowing_entry() { - Test::test_shadowing(1); - Test::test_shadowing2(1) - } -} // end 0x42::Test - - -// -- Model dump after env processor check recursive struct definition: -module 0x42::Test { - public fun foo(f: |u64|,x: u64) { - (f)(x); - Tuple() - } - public fun foo2(f: |u64|,x: u64) { - { - let x: u64 = x; - (f)(x); - Tuple() - } - } - public fun test_shadowing(x: u64) { - Test::foo(|y: u64| x: u64 = y, 3); - if Eq(x, 3) { - Tuple() - } else { - Abort(0) - }; - Test::foo2(|y: u64| x: u64 = y, 5); - if Eq(x, 5) { - Tuple() - } else { - Abort(0) - } - } - public fun test_shadowing2(q: u64) { - { - let x: u64 = q; - Test::foo(|y: u64| x: u64 = y, 3); - if Eq(x, 3) { - Tuple() - } else { - Abort(0) - }; - Test::foo2(|y: u64| x: u64 = y, 5); - if Eq(x, 5) { - Tuple() - } else { - Abort(0) - } - } - } - private fun test_shadowing_entry() { - Test::test_shadowing(1); - Test::test_shadowing2(1) - } -} // end 0x42::Test - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x42::Test { - public fun foo(f: |u64|,x: u64) { - (f)(x); - Tuple() - } - public fun foo2(f: |u64|,x: u64) { - { - let x: u64 = x; - (f)(x); - Tuple() - } - } - public fun test_shadowing(x: u64) { - Test::foo(|y: u64| x: u64 = y, 3); - if Eq(x, 3) { - Tuple() - } else { - Abort(0) - }; - Test::foo2(|y: u64| x: u64 = y, 5); - if Eq(x, 5) { - Tuple() - } else { - Abort(0) - } - } - public fun test_shadowing2(q: u64) { - { - let x: u64 = q; - Test::foo(|y: u64| x: u64 = y, 3); - if Eq(x, 3) { - Tuple() - } else { - Abort(0) - }; - Test::foo2(|y: u64| x: u64 = y, 5); - if Eq(x, 5) { - Tuple() - } else { - Abort(0) - } - } - } - private fun test_shadowing_entry() { - Test::test_shadowing(1); - Test::test_shadowing2(1) - } -} // end 0x42::Test - - -// -- Model dump after env processor unused struct params check: -module 0x42::Test { - public fun foo(f: |u64|,x: u64) { - (f)(x); - Tuple() - } - public fun foo2(f: |u64|,x: u64) { - { - let x: u64 = x; - (f)(x); - Tuple() - } - } - public fun test_shadowing(x: u64) { - Test::foo(|y: u64| x: u64 = y, 3); - if Eq(x, 3) { - Tuple() - } else { - Abort(0) - }; - Test::foo2(|y: u64| x: u64 = y, 5); - if Eq(x, 5) { - Tuple() - } else { - Abort(0) - } - } - public fun test_shadowing2(q: u64) { - { - let x: u64 = q; - Test::foo(|y: u64| x: u64 = y, 3); - if Eq(x, 3) { - Tuple() - } else { - Abort(0) - }; - Test::foo2(|y: u64| x: u64 = y, 5); - if Eq(x, 5) { - Tuple() - } else { - Abort(0) - } - } - } - private fun test_shadowing_entry() { - Test::test_shadowing(1); - Test::test_shadowing2(1) - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check before inlining: -module 0x42::Test { - public fun foo(f: |u64|,x: u64) { - (f)(x); - Tuple() - } - public fun foo2(f: |u64|,x: u64) { - { - let x: u64 = x; - (f)(x); - Tuple() - } - } - public fun test_shadowing(x: u64) { - Test::foo(|y: u64| x: u64 = y, 3); - if Eq(x, 3) { - Tuple() - } else { - Abort(0) - }; - Test::foo2(|y: u64| x: u64 = y, 5); - if Eq(x, 5) { - Tuple() - } else { - Abort(0) - } - } - public fun test_shadowing2(q: u64) { - { - let x: u64 = q; - Test::foo(|y: u64| x: u64 = y, 3); - if Eq(x, 3) { - Tuple() - } else { - Abort(0) - }; - Test::foo2(|y: u64| x: u64 = y, 5); - if Eq(x, 5) { - Tuple() - } else { - Abort(0) - } - } - } - private fun test_shadowing_entry() { - Test::test_shadowing(1); - Test::test_shadowing2(1) - } -} // end 0x42::Test - - -// -- Model dump after env processor inlining: -module 0x42::Test { - public fun foo(f: |u64|,x: u64) { - (f)(x); - Tuple() - } - public fun foo2(f: |u64|,x: u64) { - { - let x: u64 = x; - (f)(x); - Tuple() - } - } - public fun test_shadowing(x: u64) { - Test::foo(|y: u64| x: u64 = y, 3); - if Eq(x, 3) { - Tuple() - } else { - Abort(0) - }; - Test::foo2(|y: u64| x: u64 = y, 5); - if Eq(x, 5) { - Tuple() - } else { - Abort(0) - } - } - public fun test_shadowing2(q: u64) { - { - let x: u64 = q; - Test::foo(|y: u64| x: u64 = y, 3); - if Eq(x, 3) { - Tuple() - } else { - Abort(0) - }; - Test::foo2(|y: u64| x: u64 = y, 5); - if Eq(x, 5) { - Tuple() - } else { - Abort(0) - } - } - } - private fun test_shadowing_entry() { - Test::test_shadowing(1); - Test::test_shadowing2(1) - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check after inlining: -module 0x42::Test { - public fun foo(f: |u64|,x: u64) { - (f)(x); - Tuple() - } - public fun foo2(f: |u64|,x: u64) { - { - let x: u64 = x; - (f)(x); - Tuple() - } - } - public fun test_shadowing(x: u64) { - Test::foo(|y: u64| x: u64 = y, 3); - if Eq(x, 3) { - Tuple() - } else { - Abort(0) - }; - Test::foo2(|y: u64| x: u64 = y, 5); - if Eq(x, 5) { - Tuple() - } else { - Abort(0) - } - } - public fun test_shadowing2(q: u64) { - { - let x: u64 = q; - Test::foo(|y: u64| x: u64 = y, 3); - if Eq(x, 3) { - Tuple() - } else { - Abort(0) - }; - Test::foo2(|y: u64| x: u64 = y, 5); - if Eq(x, 5) { - Tuple() - } else { - Abort(0) - } - } - } - private fun test_shadowing_entry() { - Test::test_shadowing(1); - Test::test_shadowing2(1) - } -} // end 0x42::Test - - -// -- Model dump after env processor acquires check: -module 0x42::Test { - public fun foo(f: |u64|,x: u64) { - (f)(x); - Tuple() - } - public fun foo2(f: |u64|,x: u64) { - { - let x: u64 = x; - (f)(x); - Tuple() - } - } - public fun test_shadowing(x: u64) { - Test::foo(|y: u64| x: u64 = y, 3); - if Eq(x, 3) { - Tuple() - } else { - Abort(0) - }; - Test::foo2(|y: u64| x: u64 = y, 5); - if Eq(x, 5) { - Tuple() - } else { - Abort(0) - } - } - public fun test_shadowing2(q: u64) { - { - let x: u64 = q; - Test::foo(|y: u64| x: u64 = y, 3); - if Eq(x, 3) { - Tuple() - } else { - Abort(0) - }; - Test::foo2(|y: u64| x: u64 = y, 5); - if Eq(x, 5) { - Tuple() - } else { - Abort(0) - } - } - } - private fun test_shadowing_entry() { - Test::test_shadowing(1); - Test::test_shadowing2(1) - } -} // end 0x42::Test - - -// -- Model dump after env processor simplifier: -module 0x42::Test { - public fun foo(f: |u64|,x: u64) { - (f)(x); - Tuple() - } - public fun foo2(f: |u64|,x: u64) { - { - let x: u64 = x; - (f)(x); - Tuple() - } - } - public fun test_shadowing(x: u64) { - Test::foo(|y: u64| x: u64 = y, 3); - if Eq(x, 3) { - Tuple() - } else { - Abort(0) - }; - Test::foo2(|y: u64| x: u64 = y, 5); - if Eq(x, 5) { - Tuple() - } else { - Abort(0) - } - } - public fun test_shadowing2(q: u64) { - { - let x: u64 = q; - Test::foo(|y: u64| x: u64 = y, 3); - if Eq(x, 3) { - Tuple() - } else { - Abort(0) - }; - Test::foo2(|y: u64| x: u64 = y, 5); - if Eq(x, 5) { - Tuple() - } else { - Abort(0) - } - } - } - private fun test_shadowing_entry() { - Test::test_shadowing(1); - Test::test_shadowing2(1) - } -} // end 0x42::Test - - Diagnostics: -error: captured variable `x` cannot be modified inside of a lambda - ┌─ tests/lambda/inline-parity/shadowing_renamed_param.move:15:13 +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. + ┌─ tests/lambda/inline-parity/shadowing_renamed_param.move:14:13 │ -15 │ x = y // We expect this to assign 3 via foo if renaming works correctly. If not it would - │ ^ - -error: captured variable `x` cannot be modified inside of a lambda - ┌─ tests/lambda/inline-parity/shadowing_renamed_param.move:21:13 +14 │ foo(|y| { + │ ╭─────────────^ +15 │ │ x = y // We expect this to assign 3 via foo if renaming works correctly. If not it would +16 │ │ // have the value 1. +17 │ │ }, 3); + │ ╰─────────^ + +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. + ┌─ tests/lambda/inline-parity/shadowing_renamed_param.move:20:14 │ -21 │ x = y // We expect this to assign 3 via foo if renaming works correctly. If not it would - │ ^ - -error: captured variable `x` cannot be modified inside of a lambda - ┌─ tests/lambda/inline-parity/shadowing_renamed_param.move:30:13 +20 │ foo2(|y| { + │ ╭──────────────^ +21 │ │ x = y // We expect this to assign 3 via foo if renaming works correctly. If not it would +22 │ │ // have the value 1. +23 │ │ }, 5); + │ ╰─────────^ + +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. + ┌─ tests/lambda/inline-parity/shadowing_renamed_param.move:29:13 │ -30 │ x = y // We expect this to assign 3 via foo if renaming works correctly. If not it would - │ ^ - -error: captured variable `x` cannot be modified inside of a lambda - ┌─ tests/lambda/inline-parity/shadowing_renamed_param.move:36:13 +29 │ foo(|y| { + │ ╭─────────────^ +30 │ │ x = y // We expect this to assign 3 via foo if renaming works correctly. If not it would +31 │ │ // have the value 1. +32 │ │ }, 3); + │ ╰─────────^ + +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. + ┌─ tests/lambda/inline-parity/shadowing_renamed_param.move:35:14 │ -36 │ x = y // We expect this to assign 3 via foo if renaming works correctly. If not it would - │ ^ +35 │ foo2(|y| { + │ ╭──────────────^ +36 │ │ x = y // We expect this to assign 3 via foo if renaming works correctly. If not it would +37 │ │ // have the value 1. +38 │ │ }, 5); + │ ╰─────────^ diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/shadowing_unused.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/shadowing_unused.lambda.exp index 7c4b85b3b4291..d5a3155e69c14 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/shadowing_unused.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/shadowing_unused.lambda.exp @@ -1,518 +1,27 @@ -// -- Model dump before env processor pipeline: -module 0x42::Test { - public fun foo(f: |(u64, u64)|,z: u64) { - Test::quux(|(a: u64, b: u64): (u64, u64)| (f)(a, b), z); - Tuple() - } - public fun quux(f: |(u64, u64)|,_z: u64) { - { - let x: u64 = 3; - { - let q: u64 = 5; - (f)(x, q); - Tuple() - } - } - } - public fun test_shadowing() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::foo(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } - public fun test_shadowing2() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::quux(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor unused checks: -module 0x42::Test { - public fun foo(f: |(u64, u64)|,z: u64) { - Test::quux(|(a: u64, b: u64): (u64, u64)| (f)(a, b), z); - Tuple() - } - public fun quux(f: |(u64, u64)|,_z: u64) { - { - let x: u64 = 3; - { - let q: u64 = 5; - (f)(x, q); - Tuple() - } - } - } - public fun test_shadowing() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::foo(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } - public fun test_shadowing2() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::quux(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor type parameter check: -module 0x42::Test { - public fun foo(f: |(u64, u64)|,z: u64) { - Test::quux(|(a: u64, b: u64): (u64, u64)| (f)(a, b), z); - Tuple() - } - public fun quux(f: |(u64, u64)|,_z: u64) { - { - let x: u64 = 3; - { - let q: u64 = 5; - (f)(x, q); - Tuple() - } - } - } - public fun test_shadowing() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::foo(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } - public fun test_shadowing2() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::quux(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor check recursive struct definition: -module 0x42::Test { - public fun foo(f: |(u64, u64)|,z: u64) { - Test::quux(|(a: u64, b: u64): (u64, u64)| (f)(a, b), z); - Tuple() - } - public fun quux(f: |(u64, u64)|,_z: u64) { - { - let x: u64 = 3; - { - let q: u64 = 5; - (f)(x, q); - Tuple() - } - } - } - public fun test_shadowing() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::foo(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } - public fun test_shadowing2() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::quux(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x42::Test { - public fun foo(f: |(u64, u64)|,z: u64) { - Test::quux(|(a: u64, b: u64): (u64, u64)| (f)(a, b), z); - Tuple() - } - public fun quux(f: |(u64, u64)|,_z: u64) { - { - let x: u64 = 3; - { - let q: u64 = 5; - (f)(x, q); - Tuple() - } - } - } - public fun test_shadowing() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::foo(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } - public fun test_shadowing2() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::quux(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor unused struct params check: -module 0x42::Test { - public fun foo(f: |(u64, u64)|,z: u64) { - Test::quux(|(a: u64, b: u64): (u64, u64)| (f)(a, b), z); - Tuple() - } - public fun quux(f: |(u64, u64)|,_z: u64) { - { - let x: u64 = 3; - { - let q: u64 = 5; - (f)(x, q); - Tuple() - } - } - } - public fun test_shadowing() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::foo(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } - public fun test_shadowing2() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::quux(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check before inlining: -module 0x42::Test { - public fun foo(f: |(u64, u64)|,z: u64) { - Test::quux(|(a: u64, b: u64): (u64, u64)| (f)(a, b), z); - Tuple() - } - public fun quux(f: |(u64, u64)|,_z: u64) { - { - let x: u64 = 3; - { - let q: u64 = 5; - (f)(x, q); - Tuple() - } - } - } - public fun test_shadowing() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::foo(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } - public fun test_shadowing2() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::quux(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor inlining: -module 0x42::Test { - public fun foo(f: |(u64, u64)|,z: u64) { - Test::quux(|(a: u64, b: u64): (u64, u64)| (f)(a, b), z); - Tuple() - } - public fun quux(f: |(u64, u64)|,_z: u64) { - { - let x: u64 = 3; - { - let q: u64 = 5; - (f)(x, q); - Tuple() - } - } - } - public fun test_shadowing() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::foo(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } - public fun test_shadowing2() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::quux(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check after inlining: -module 0x42::Test { - public fun foo(f: |(u64, u64)|,z: u64) { - Test::quux(|(a: u64, b: u64): (u64, u64)| (f)(a, b), z); - Tuple() - } - public fun quux(f: |(u64, u64)|,_z: u64) { - { - let x: u64 = 3; - { - let q: u64 = 5; - (f)(x, q); - Tuple() - } - } - } - public fun test_shadowing() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::foo(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } - public fun test_shadowing2() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::quux(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor acquires check: -module 0x42::Test { - public fun foo(f: |(u64, u64)|,z: u64) { - Test::quux(|(a: u64, b: u64): (u64, u64)| (f)(a, b), z); - Tuple() - } - public fun quux(f: |(u64, u64)|,_z: u64) { - { - let x: u64 = 3; - { - let q: u64 = 5; - (f)(x, q); - Tuple() - } - } - } - public fun test_shadowing() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::foo(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } - public fun test_shadowing2() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::quux(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor simplifier: -module 0x42::Test { - public fun foo(f: |(u64, u64)|,z: u64) { - Test::quux(|(a: u64, b: u64): (u64, u64)| (f)(a, b), z); - Tuple() - } - public fun quux(f: |(u64, u64)|,_z: u64) { - (f)(3, 5); - Tuple() - } - public fun test_shadowing() { - { - let _x: u64 = 1; - Test::foo(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, 4); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - public fun test_shadowing2() { - { - let _x: u64 = 1; - Test::quux(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, 4); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } -} // end 0x42::Test - - Diagnostics: -error: captured variable `_x` cannot be modified inside of a lambda - ┌─ tests/lambda/inline-parity/shadowing_unused.move:18:13 +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. + ┌─ tests/lambda/inline-parity/shadowing_unused.move:11:14 │ -18 │ _x = y // We expect this to assign 3 via foo if renaming works correctly. If not it would - │ ^^ +11 │ quux(|a, b| f(a, b), z); + │ ^^^^^^^^^^^^^^ -error: captured variable `_x` cannot be modified inside of a lambda - ┌─ tests/lambda/inline-parity/shadowing_unused.move:28:13 +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. + ┌─ tests/lambda/inline-parity/shadowing_unused.move:17:13 + │ +17 │ foo(|y, _q| { + │ ╭─────────────^ +18 │ │ _x = y // We expect this to assign 3 via foo if renaming works correctly. If not it would +19 │ │ // have the value 1. +20 │ │ }, z); + │ ╰─────────^ + +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. + ┌─ tests/lambda/inline-parity/shadowing_unused.move:27:14 │ -28 │ _x = y // We expect this to assign 3 via foo if renaming works correctly. If not it would - │ ^^ +27 │ quux(|y, _q| { + │ ╭──────────────^ +28 │ │ _x = y // We expect this to assign 3 via foo if renaming works correctly. If not it would +29 │ │ // have the value 1. +30 │ │ }, z); + │ ╰─────────^ diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/shadowing_unused_nodecl.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/shadowing_unused_nodecl.lambda.exp index ccbae64fbd2f7..71807d374704d 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/shadowing_unused_nodecl.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/shadowing_unused_nodecl.lambda.exp @@ -1,508 +1,3 @@ -// -- Model dump before env processor pipeline: -module 0x42::Test { - public fun foo(f: |(u64, u64)|,z: u64) { - Test::quux(|(a: u64, b: u64): (u64, u64)| (f)(a, b), z); - Tuple() - } - public fun quux(f: |(u64, u64)|,z: u64) { - { - let x: u64 = 3; - { - let q: u64 = 5; - (f)(x, q); - Tuple() - } - } - } - public fun test_shadowing() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::foo(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } - public fun test_shadowing2() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::quux(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor unused checks: -module 0x42::Test { - public fun foo(f: |(u64, u64)|,z: u64) { - Test::quux(|(a: u64, b: u64): (u64, u64)| (f)(a, b), z); - Tuple() - } - public fun quux(f: |(u64, u64)|,z: u64) { - { - let x: u64 = 3; - { - let q: u64 = 5; - (f)(x, q); - Tuple() - } - } - } - public fun test_shadowing() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::foo(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } - public fun test_shadowing2() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::quux(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor type parameter check: -module 0x42::Test { - public fun foo(f: |(u64, u64)|,z: u64) { - Test::quux(|(a: u64, b: u64): (u64, u64)| (f)(a, b), z); - Tuple() - } - public fun quux(f: |(u64, u64)|,z: u64) { - { - let x: u64 = 3; - { - let q: u64 = 5; - (f)(x, q); - Tuple() - } - } - } - public fun test_shadowing() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::foo(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } - public fun test_shadowing2() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::quux(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor check recursive struct definition: -module 0x42::Test { - public fun foo(f: |(u64, u64)|,z: u64) { - Test::quux(|(a: u64, b: u64): (u64, u64)| (f)(a, b), z); - Tuple() - } - public fun quux(f: |(u64, u64)|,z: u64) { - { - let x: u64 = 3; - { - let q: u64 = 5; - (f)(x, q); - Tuple() - } - } - } - public fun test_shadowing() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::foo(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } - public fun test_shadowing2() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::quux(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x42::Test { - public fun foo(f: |(u64, u64)|,z: u64) { - Test::quux(|(a: u64, b: u64): (u64, u64)| (f)(a, b), z); - Tuple() - } - public fun quux(f: |(u64, u64)|,z: u64) { - { - let x: u64 = 3; - { - let q: u64 = 5; - (f)(x, q); - Tuple() - } - } - } - public fun test_shadowing() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::foo(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } - public fun test_shadowing2() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::quux(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor unused struct params check: -module 0x42::Test { - public fun foo(f: |(u64, u64)|,z: u64) { - Test::quux(|(a: u64, b: u64): (u64, u64)| (f)(a, b), z); - Tuple() - } - public fun quux(f: |(u64, u64)|,z: u64) { - { - let x: u64 = 3; - { - let q: u64 = 5; - (f)(x, q); - Tuple() - } - } - } - public fun test_shadowing() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::foo(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } - public fun test_shadowing2() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::quux(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check before inlining: -module 0x42::Test { - public fun foo(f: |(u64, u64)|,z: u64) { - Test::quux(|(a: u64, b: u64): (u64, u64)| (f)(a, b), z); - Tuple() - } - public fun quux(f: |(u64, u64)|,z: u64) { - { - let x: u64 = 3; - { - let q: u64 = 5; - (f)(x, q); - Tuple() - } - } - } - public fun test_shadowing() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::foo(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } - public fun test_shadowing2() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::quux(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor inlining: -module 0x42::Test { - public fun foo(f: |(u64, u64)|,z: u64) { - Test::quux(|(a: u64, b: u64): (u64, u64)| (f)(a, b), z); - Tuple() - } - public fun quux(f: |(u64, u64)|,z: u64) { - { - let x: u64 = 3; - { - let q: u64 = 5; - (f)(x, q); - Tuple() - } - } - } - public fun test_shadowing() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::foo(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } - public fun test_shadowing2() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::quux(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check after inlining: -module 0x42::Test { - public fun foo(f: |(u64, u64)|,z: u64) { - Test::quux(|(a: u64, b: u64): (u64, u64)| (f)(a, b), z); - Tuple() - } - public fun quux(f: |(u64, u64)|,z: u64) { - { - let x: u64 = 3; - { - let q: u64 = 5; - (f)(x, q); - Tuple() - } - } - } - public fun test_shadowing() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::foo(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } - public fun test_shadowing2() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::quux(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor acquires check: -module 0x42::Test { - public fun foo(f: |(u64, u64)|,z: u64) { - Test::quux(|(a: u64, b: u64): (u64, u64)| (f)(a, b), z); - Tuple() - } - public fun quux(f: |(u64, u64)|,z: u64) { - { - let x: u64 = 3; - { - let q: u64 = 5; - (f)(x, q); - Tuple() - } - } - } - public fun test_shadowing() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::foo(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } - public fun test_shadowing2() { - { - let _x: u64 = 1; - { - let z: u64 = 4; - Test::quux(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, z); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor simplifier: -module 0x42::Test { - public fun foo(f: |(u64, u64)|,z: u64) { - Test::quux(|(a: u64, b: u64): (u64, u64)| (f)(a, b), z); - Tuple() - } - public fun quux(f: |(u64, u64)|,z: u64) { - (f)(3, 5); - Tuple() - } - public fun test_shadowing() { - { - let _x: u64 = 1; - Test::foo(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, 4); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } - public fun test_shadowing2() { - { - let _x: u64 = 1; - Test::quux(|(y: u64, _q: u64): (u64, u64)| _x: u64 = y, 4); - if Eq(_x, 3) { - Tuple() - } else { - Abort(0) - } - } - } -} // end 0x42::Test - - Diagnostics: warning: Unused parameter `z`. Consider removing or prefixing with an underscore: `_z` @@ -511,14 +6,28 @@ warning: Unused parameter `z`. Consider removing or prefixing with an underscore 6 │ public fun quux(f:|u64, u64|, z: u64) { │ ^ -error: captured variable `_x` cannot be modified inside of a lambda - ┌─ tests/lambda/inline-parity/shadowing_unused_nodecl.move:20:13 +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. + ┌─ tests/lambda/inline-parity/shadowing_unused_nodecl.move:13:14 │ -20 │ _x = y // We expect this to assign 3 via foo if renaming works correctly. If not it would - │ ^^ +13 │ quux(|a, b| f(a, b), z); + │ ^^^^^^^^^^^^^^ -error: captured variable `_x` cannot be modified inside of a lambda - ┌─ tests/lambda/inline-parity/shadowing_unused_nodecl.move:30:13 +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. + ┌─ tests/lambda/inline-parity/shadowing_unused_nodecl.move:19:13 + │ +19 │ foo(|y, _q| { + │ ╭─────────────^ +20 │ │ _x = y // We expect this to assign 3 via foo if renaming works correctly. If not it would +21 │ │ // have the value 1. +22 │ │ }, z); + │ ╰─────────^ + +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. + ┌─ tests/lambda/inline-parity/shadowing_unused_nodecl.move:29:14 │ -30 │ _x = y // We expect this to assign 3 via foo if renaming works correctly. If not it would - │ ^^ +29 │ quux(|y, _q| { + │ ╭──────────────^ +30 │ │ _x = y // We expect this to assign 3 via foo if renaming works correctly. If not it would +31 │ │ // have the value 1. +32 │ │ }, z); + │ ╰─────────^ diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/simple_map_keys.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/simple_map_keys.lambda.exp index 90288bcbca57e..53b479c4b3def 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/simple_map_keys.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/simple_map_keys.lambda.exp @@ -1,689 +1,17 @@ -// -- Model dump before env processor pipeline: -module 0x42::simple_map { - use 0x1::vector; // resolved as: 0x1::vector - struct Element { - key: Key, - value: Value, - } - struct SimpleMap { - data: vector>, - } - public fun for_each_ref(v: &vector,f: |&Element|) { - { - let i: u64 = 0; - { - let len: u64 = vector::length(v); - loop { - if Lt(i, len) { - (f)(vector::borrow(v, i)); - i: u64 = Add(i, 1) - } else { - break - } - } - } - } - } - public fun keys(map: &SimpleMap): vector { - simple_map::map_ref, Key>(Borrow(Immutable)(select simple_map::SimpleMap.data<&SimpleMap>(map)), |e: &Element| { - let e: &Element = e; - select simple_map::Element.key<&Element>(e) - }) - } - public fun map_ref(v: &vector,f: |&Element|NewElement): vector { - { - let result: vector = Vector(); - simple_map::for_each_ref(v, |elem: &Element| vector::push_back(Borrow(Mutable)(result), (f)(elem))); - result - } - } - public fun run() { - { - let entry: Element = pack simple_map::Element(1, 2); - { - let data: vector> = Vector>(entry, entry, entry); - { - let map: SimpleMap = pack simple_map::SimpleMap(data); - { - let keys: vector = simple_map::keys(Borrow(Immutable)(map)); - if Eq>(keys, Vector(1, 1, 1)) { - Tuple() - } else { - Abort(33) - }; - Tuple() - } - } - } - } - } -} // end 0x42::simple_map - - -// -- Model dump after env processor unused checks: -module 0x42::simple_map { - use 0x1::vector; // resolved as: 0x1::vector - struct Element { - key: Key, - value: Value, - } - struct SimpleMap { - data: vector>, - } - public fun for_each_ref(v: &vector,f: |&Element|) { - { - let i: u64 = 0; - { - let len: u64 = vector::length(v); - loop { - if Lt(i, len) { - (f)(vector::borrow(v, i)); - i: u64 = Add(i, 1) - } else { - break - } - } - } - } - } - public fun keys(map: &SimpleMap): vector { - simple_map::map_ref, Key>(Borrow(Immutable)(select simple_map::SimpleMap.data<&SimpleMap>(map)), |e: &Element| { - let e: &Element = e; - select simple_map::Element.key<&Element>(e) - }) - } - public fun map_ref(v: &vector,f: |&Element|NewElement): vector { - { - let result: vector = Vector(); - simple_map::for_each_ref(v, |elem: &Element| vector::push_back(Borrow(Mutable)(result), (f)(elem))); - result - } - } - public fun run() { - { - let entry: Element = pack simple_map::Element(1, 2); - { - let data: vector> = Vector>(entry, entry, entry); - { - let map: SimpleMap = pack simple_map::SimpleMap(data); - { - let keys: vector = simple_map::keys(Borrow(Immutable)(map)); - if Eq>(keys, Vector(1, 1, 1)) { - Tuple() - } else { - Abort(33) - }; - Tuple() - } - } - } - } - } -} // end 0x42::simple_map - - -// -- Model dump after env processor type parameter check: -module 0x42::simple_map { - use 0x1::vector; // resolved as: 0x1::vector - struct Element { - key: Key, - value: Value, - } - struct SimpleMap { - data: vector>, - } - public fun for_each_ref(v: &vector,f: |&Element|) { - { - let i: u64 = 0; - { - let len: u64 = vector::length(v); - loop { - if Lt(i, len) { - (f)(vector::borrow(v, i)); - i: u64 = Add(i, 1) - } else { - break - } - } - } - } - } - public fun keys(map: &SimpleMap): vector { - simple_map::map_ref, Key>(Borrow(Immutable)(select simple_map::SimpleMap.data<&SimpleMap>(map)), |e: &Element| { - let e: &Element = e; - select simple_map::Element.key<&Element>(e) - }) - } - public fun map_ref(v: &vector,f: |&Element|NewElement): vector { - { - let result: vector = Vector(); - simple_map::for_each_ref(v, |elem: &Element| vector::push_back(Borrow(Mutable)(result), (f)(elem))); - result - } - } - public fun run() { - { - let entry: Element = pack simple_map::Element(1, 2); - { - let data: vector> = Vector>(entry, entry, entry); - { - let map: SimpleMap = pack simple_map::SimpleMap(data); - { - let keys: vector = simple_map::keys(Borrow(Immutable)(map)); - if Eq>(keys, Vector(1, 1, 1)) { - Tuple() - } else { - Abort(33) - }; - Tuple() - } - } - } - } - } -} // end 0x42::simple_map - - -// -- Model dump after env processor check recursive struct definition: -module 0x42::simple_map { - use 0x1::vector; // resolved as: 0x1::vector - struct Element { - key: Key, - value: Value, - } - struct SimpleMap { - data: vector>, - } - public fun for_each_ref(v: &vector,f: |&Element|) { - { - let i: u64 = 0; - { - let len: u64 = vector::length(v); - loop { - if Lt(i, len) { - (f)(vector::borrow(v, i)); - i: u64 = Add(i, 1) - } else { - break - } - } - } - } - } - public fun keys(map: &SimpleMap): vector { - simple_map::map_ref, Key>(Borrow(Immutable)(select simple_map::SimpleMap.data<&SimpleMap>(map)), |e: &Element| { - let e: &Element = e; - select simple_map::Element.key<&Element>(e) - }) - } - public fun map_ref(v: &vector,f: |&Element|NewElement): vector { - { - let result: vector = Vector(); - simple_map::for_each_ref(v, |elem: &Element| vector::push_back(Borrow(Mutable)(result), (f)(elem))); - result - } - } - public fun run() { - { - let entry: Element = pack simple_map::Element(1, 2); - { - let data: vector> = Vector>(entry, entry, entry); - { - let map: SimpleMap = pack simple_map::SimpleMap(data); - { - let keys: vector = simple_map::keys(Borrow(Immutable)(map)); - if Eq>(keys, Vector(1, 1, 1)) { - Tuple() - } else { - Abort(33) - }; - Tuple() - } - } - } - } - } -} // end 0x42::simple_map - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x42::simple_map { - use 0x1::vector; // resolved as: 0x1::vector - struct Element { - key: Key, - value: Value, - } - struct SimpleMap { - data: vector>, - } - public fun for_each_ref(v: &vector,f: |&Element|) { - { - let i: u64 = 0; - { - let len: u64 = vector::length(v); - loop { - if Lt(i, len) { - (f)(vector::borrow(v, i)); - i: u64 = Add(i, 1) - } else { - break - } - } - } - } - } - public fun keys(map: &SimpleMap): vector { - simple_map::map_ref, Key>(Borrow(Immutable)(select simple_map::SimpleMap.data<&SimpleMap>(map)), |e: &Element| { - let e: &Element = e; - select simple_map::Element.key<&Element>(e) - }) - } - public fun map_ref(v: &vector,f: |&Element|NewElement): vector { - { - let result: vector = Vector(); - simple_map::for_each_ref(v, |elem: &Element| vector::push_back(Borrow(Mutable)(result), (f)(elem))); - result - } - } - public fun run() { - { - let entry: Element = pack simple_map::Element(1, 2); - { - let data: vector> = Vector>(entry, entry, entry); - { - let map: SimpleMap = pack simple_map::SimpleMap(data); - { - let keys: vector = simple_map::keys(Borrow(Immutable)(map)); - if Eq>(keys, Vector(1, 1, 1)) { - Tuple() - } else { - Abort(33) - }; - Tuple() - } - } - } - } - } -} // end 0x42::simple_map - - -// -- Model dump after env processor unused struct params check: -module 0x42::simple_map { - use 0x1::vector; // resolved as: 0x1::vector - struct Element { - key: Key, - value: Value, - } - struct SimpleMap { - data: vector>, - } - public fun for_each_ref(v: &vector,f: |&Element|) { - { - let i: u64 = 0; - { - let len: u64 = vector::length(v); - loop { - if Lt(i, len) { - (f)(vector::borrow(v, i)); - i: u64 = Add(i, 1) - } else { - break - } - } - } - } - } - public fun keys(map: &SimpleMap): vector { - simple_map::map_ref, Key>(Borrow(Immutable)(select simple_map::SimpleMap.data<&SimpleMap>(map)), |e: &Element| { - let e: &Element = e; - select simple_map::Element.key<&Element>(e) - }) - } - public fun map_ref(v: &vector,f: |&Element|NewElement): vector { - { - let result: vector = Vector(); - simple_map::for_each_ref(v, |elem: &Element| vector::push_back(Borrow(Mutable)(result), (f)(elem))); - result - } - } - public fun run() { - { - let entry: Element = pack simple_map::Element(1, 2); - { - let data: vector> = Vector>(entry, entry, entry); - { - let map: SimpleMap = pack simple_map::SimpleMap(data); - { - let keys: vector = simple_map::keys(Borrow(Immutable)(map)); - if Eq>(keys, Vector(1, 1, 1)) { - Tuple() - } else { - Abort(33) - }; - Tuple() - } - } - } - } - } -} // end 0x42::simple_map - - -// -- Model dump after env processor access and use check before inlining: -module 0x42::simple_map { - use 0x1::vector; // resolved as: 0x1::vector - struct Element { - key: Key, - value: Value, - } - struct SimpleMap { - data: vector>, - } - public fun for_each_ref(v: &vector,f: |&Element|) { - { - let i: u64 = 0; - { - let len: u64 = vector::length(v); - loop { - if Lt(i, len) { - (f)(vector::borrow(v, i)); - i: u64 = Add(i, 1) - } else { - break - } - } - } - } - } - public fun keys(map: &SimpleMap): vector { - simple_map::map_ref, Key>(Borrow(Immutable)(select simple_map::SimpleMap.data<&SimpleMap>(map)), |e: &Element| { - let e: &Element = e; - select simple_map::Element.key<&Element>(e) - }) - } - public fun map_ref(v: &vector,f: |&Element|NewElement): vector { - { - let result: vector = Vector(); - simple_map::for_each_ref(v, |elem: &Element| vector::push_back(Borrow(Mutable)(result), (f)(elem))); - result - } - } - public fun run() { - { - let entry: Element = pack simple_map::Element(1, 2); - { - let data: vector> = Vector>(entry, entry, entry); - { - let map: SimpleMap = pack simple_map::SimpleMap(data); - { - let keys: vector = simple_map::keys(Borrow(Immutable)(map)); - if Eq>(keys, Vector(1, 1, 1)) { - Tuple() - } else { - Abort(33) - }; - Tuple() - } - } - } - } - } -} // end 0x42::simple_map - - -// -- Model dump after env processor inlining: -module 0x42::simple_map { - use 0x1::vector; // resolved as: 0x1::vector - struct Element { - key: Key, - value: Value, - } - struct SimpleMap { - data: vector>, - } - public fun for_each_ref(v: &vector,f: |&Element|) { - { - let i: u64 = 0; - { - let len: u64 = vector::length(v); - loop { - if Lt(i, len) { - (f)(vector::borrow(v, i)); - i: u64 = Add(i, 1) - } else { - break - } - } - } - } - } - public fun keys(map: &SimpleMap): vector { - simple_map::map_ref, Key>(Borrow(Immutable)(select simple_map::SimpleMap.data<&SimpleMap>(map)), |e: &Element| { - let e: &Element = e; - select simple_map::Element.key<&Element>(e) - }) - } - public fun map_ref(v: &vector,f: |&Element|NewElement): vector { - { - let result: vector = Vector(); - simple_map::for_each_ref(v, |elem: &Element| vector::push_back(Borrow(Mutable)(result), (f)(elem))); - result - } - } - public fun run() { - { - let entry: Element = pack simple_map::Element(1, 2); - { - let data: vector> = Vector>(entry, entry, entry); - { - let map: SimpleMap = pack simple_map::SimpleMap(data); - { - let keys: vector = simple_map::keys(Borrow(Immutable)(map)); - if Eq>(keys, Vector(1, 1, 1)) { - Tuple() - } else { - Abort(33) - }; - Tuple() - } - } - } - } - } -} // end 0x42::simple_map - - -// -- Model dump after env processor access and use check after inlining: -module 0x42::simple_map { - use 0x1::vector; // resolved as: 0x1::vector - struct Element { - key: Key, - value: Value, - } - struct SimpleMap { - data: vector>, - } - public fun for_each_ref(v: &vector,f: |&Element|) { - { - let i: u64 = 0; - { - let len: u64 = vector::length(v); - loop { - if Lt(i, len) { - (f)(vector::borrow(v, i)); - i: u64 = Add(i, 1) - } else { - break - } - } - } - } - } - public fun keys(map: &SimpleMap): vector { - simple_map::map_ref, Key>(Borrow(Immutable)(select simple_map::SimpleMap.data<&SimpleMap>(map)), |e: &Element| { - let e: &Element = e; - select simple_map::Element.key<&Element>(e) - }) - } - public fun map_ref(v: &vector,f: |&Element|NewElement): vector { - { - let result: vector = Vector(); - simple_map::for_each_ref(v, |elem: &Element| vector::push_back(Borrow(Mutable)(result), (f)(elem))); - result - } - } - public fun run() { - { - let entry: Element = pack simple_map::Element(1, 2); - { - let data: vector> = Vector>(entry, entry, entry); - { - let map: SimpleMap = pack simple_map::SimpleMap(data); - { - let keys: vector = simple_map::keys(Borrow(Immutable)(map)); - if Eq>(keys, Vector(1, 1, 1)) { - Tuple() - } else { - Abort(33) - }; - Tuple() - } - } - } - } - } -} // end 0x42::simple_map - - -// -- Model dump after env processor acquires check: -module 0x42::simple_map { - use 0x1::vector; // resolved as: 0x1::vector - struct Element { - key: Key, - value: Value, - } - struct SimpleMap { - data: vector>, - } - public fun for_each_ref(v: &vector,f: |&Element|) { - { - let i: u64 = 0; - { - let len: u64 = vector::length(v); - loop { - if Lt(i, len) { - (f)(vector::borrow(v, i)); - i: u64 = Add(i, 1) - } else { - break - } - } - } - } - } - public fun keys(map: &SimpleMap): vector { - simple_map::map_ref, Key>(Borrow(Immutable)(select simple_map::SimpleMap.data<&SimpleMap>(map)), |e: &Element| { - let e: &Element = e; - select simple_map::Element.key<&Element>(e) - }) - } - public fun map_ref(v: &vector,f: |&Element|NewElement): vector { - { - let result: vector = Vector(); - simple_map::for_each_ref(v, |elem: &Element| vector::push_back(Borrow(Mutable)(result), (f)(elem))); - result - } - } - public fun run() { - { - let entry: Element = pack simple_map::Element(1, 2); - { - let data: vector> = Vector>(entry, entry, entry); - { - let map: SimpleMap = pack simple_map::SimpleMap(data); - { - let keys: vector = simple_map::keys(Borrow(Immutable)(map)); - if Eq>(keys, Vector(1, 1, 1)) { - Tuple() - } else { - Abort(33) - }; - Tuple() - } - } - } - } - } -} // end 0x42::simple_map - - -// -- Model dump after env processor simplifier: -module 0x42::simple_map { - use 0x1::vector; // resolved as: 0x1::vector - struct Element { - key: Key, - value: Value, - } - struct SimpleMap { - data: vector>, - } - public fun for_each_ref(v: &vector,f: |&Element|) { - { - let i: u64 = 0; - { - let len: u64 = vector::length(v); - loop { - if Lt(i, len) { - (f)(vector::borrow(v, i)); - i: u64 = Add(i, 1) - } else { - break - } - } - } - } - } - public fun keys(map: &SimpleMap): vector { - simple_map::map_ref, Key>(Borrow(Immutable)(select simple_map::SimpleMap.data<&SimpleMap>(map)), |e: &Element| { - let e: &Element = e; - select simple_map::Element.key<&Element>(e) - }) - } - public fun map_ref(v: &vector,f: |&Element|NewElement): vector { - { - let result: vector = Vector(); - simple_map::for_each_ref(v, |elem: &Element| vector::push_back(Borrow(Mutable)(result), (f)(elem))); - result - } - } - public fun run() { - { - let entry: Element = pack simple_map::Element(1, 2); - { - let data: vector> = Vector>(entry, entry, entry); - { - let map: SimpleMap = pack simple_map::SimpleMap(data); - { - let keys: vector = simple_map::keys(Borrow(Immutable)(map)); - if Eq>(keys, [Number(1), Number(1), Number(1)]) { - Tuple() - } else { - Abort(33) - }; - Tuple() - } - } - } - } - } -} // end 0x42::simple_map - - Diagnostics: -error: captured variable `result` cannot be modified inside of a lambda - ┌─ tests/lambda/inline-parity/simple_map_keys.move:28:55 +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. + ┌─ tests/lambda/inline-parity/simple_map_keys.move:17:28 + │ +17 │ map_ref(&map.data, |e| { + │ ╭────────────────────────────^ +18 │ │ let e: &Element = e; +19 │ │ e.key +20 │ │ }) + │ ╰─────────^ + +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. + ┌─ tests/lambda/inline-parity/simple_map_keys.move:28:25 │ 28 │ for_each_ref(v, |elem| vector::push_back(&mut result, f(elem))); - │ ^^^^^^ + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/spec_inlining.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/spec_inlining.lambda.exp index 82da96e292c71..5d2bf75d581e6 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/spec_inlining.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/spec_inlining.lambda.exp @@ -1,582 +1,12 @@ -// -- Model dump before env processor pipeline: -module 0x42::Test { - private fun apply(v: u64,predicate: |u64|bool): bool { - spec { - assert Ge($t0, 0); - } - ; - (predicate)(v) - } - public fun test_apply(x: u64) { - { - let r1: bool = Test::apply(x, |v: u64| Ge(v, 0)); - spec { - assert r1; - } - ; - if r1 { - Tuple() - } else { - Abort(1) - }; - { - let r2: bool = Test::apply(x, |v: u64| Neq(v, 0)); - spec { - assert r2; - } - ; - if r2 { - Tuple() - } else { - Abort(2) - }; - Tuple() - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor unused checks: -module 0x42::Test { - private fun apply(v: u64,predicate: |u64|bool): bool { - spec { - assert Ge($t0, 0); - } - ; - (predicate)(v) - } - public fun test_apply(x: u64) { - { - let r1: bool = Test::apply(x, |v: u64| Ge(v, 0)); - spec { - assert r1; - } - ; - if r1 { - Tuple() - } else { - Abort(1) - }; - { - let r2: bool = Test::apply(x, |v: u64| Neq(v, 0)); - spec { - assert r2; - } - ; - if r2 { - Tuple() - } else { - Abort(2) - }; - Tuple() - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor type parameter check: -module 0x42::Test { - private fun apply(v: u64,predicate: |u64|bool): bool { - spec { - assert Ge($t0, 0); - } - ; - (predicate)(v) - } - public fun test_apply(x: u64) { - { - let r1: bool = Test::apply(x, |v: u64| Ge(v, 0)); - spec { - assert r1; - } - ; - if r1 { - Tuple() - } else { - Abort(1) - }; - { - let r2: bool = Test::apply(x, |v: u64| Neq(v, 0)); - spec { - assert r2; - } - ; - if r2 { - Tuple() - } else { - Abort(2) - }; - Tuple() - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor check recursive struct definition: -module 0x42::Test { - private fun apply(v: u64,predicate: |u64|bool): bool { - spec { - assert Ge($t0, 0); - } - ; - (predicate)(v) - } - public fun test_apply(x: u64) { - { - let r1: bool = Test::apply(x, |v: u64| Ge(v, 0)); - spec { - assert r1; - } - ; - if r1 { - Tuple() - } else { - Abort(1) - }; - { - let r2: bool = Test::apply(x, |v: u64| Neq(v, 0)); - spec { - assert r2; - } - ; - if r2 { - Tuple() - } else { - Abort(2) - }; - Tuple() - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x42::Test { - private fun apply(v: u64,predicate: |u64|bool): bool { - spec { - assert Ge($t0, 0); - } - ; - (predicate)(v) - } - public fun test_apply(x: u64) { - { - let r1: bool = Test::apply(x, |v: u64| Ge(v, 0)); - spec { - assert r1; - } - ; - if r1 { - Tuple() - } else { - Abort(1) - }; - { - let r2: bool = Test::apply(x, |v: u64| Neq(v, 0)); - spec { - assert r2; - } - ; - if r2 { - Tuple() - } else { - Abort(2) - }; - Tuple() - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor unused struct params check: -module 0x42::Test { - private fun apply(v: u64,predicate: |u64|bool): bool { - spec { - assert Ge($t0, 0); - } - ; - (predicate)(v) - } - public fun test_apply(x: u64) { - { - let r1: bool = Test::apply(x, |v: u64| Ge(v, 0)); - spec { - assert r1; - } - ; - if r1 { - Tuple() - } else { - Abort(1) - }; - { - let r2: bool = Test::apply(x, |v: u64| Neq(v, 0)); - spec { - assert r2; - } - ; - if r2 { - Tuple() - } else { - Abort(2) - }; - Tuple() - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check before inlining: -module 0x42::Test { - private fun apply(v: u64,predicate: |u64|bool): bool { - spec { - assert Ge($t0, 0); - } - ; - (predicate)(v) - } - public fun test_apply(x: u64) { - { - let r1: bool = Test::apply(x, |v: u64| Ge(v, 0)); - spec { - assert r1; - } - ; - if r1 { - Tuple() - } else { - Abort(1) - }; - { - let r2: bool = Test::apply(x, |v: u64| Neq(v, 0)); - spec { - assert r2; - } - ; - if r2 { - Tuple() - } else { - Abort(2) - }; - Tuple() - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor inlining: -module 0x42::Test { - private fun apply(v: u64,predicate: |u64|bool): bool { - spec { - assert Ge($t0, 0); - } - ; - (predicate)(v) - } - public fun test_apply(x: u64) { - { - let r1: bool = Test::apply(x, |v: u64| Ge(v, 0)); - spec { - assert r1; - } - ; - if r1 { - Tuple() - } else { - Abort(1) - }; - { - let r2: bool = Test::apply(x, |v: u64| Neq(v, 0)); - spec { - assert r2; - } - ; - if r2 { - Tuple() - } else { - Abort(2) - }; - Tuple() - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor access and use check after inlining: -module 0x42::Test { - private fun apply(v: u64,predicate: |u64|bool): bool { - spec { - assert Ge($t0, 0); - } - ; - (predicate)(v) - } - public fun test_apply(x: u64) { - { - let r1: bool = Test::apply(x, |v: u64| Ge(v, 0)); - spec { - assert r1; - } - ; - if r1 { - Tuple() - } else { - Abort(1) - }; - { - let r2: bool = Test::apply(x, |v: u64| Neq(v, 0)); - spec { - assert r2; - } - ; - if r2 { - Tuple() - } else { - Abort(2) - }; - Tuple() - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor acquires check: -module 0x42::Test { - private fun apply(v: u64,predicate: |u64|bool): bool { - spec { - assert Ge($t0, 0); - } - ; - (predicate)(v) - } - public fun test_apply(x: u64) { - { - let r1: bool = Test::apply(x, |v: u64| Ge(v, 0)); - spec { - assert r1; - } - ; - if r1 { - Tuple() - } else { - Abort(1) - }; - { - let r2: bool = Test::apply(x, |v: u64| Neq(v, 0)); - spec { - assert r2; - } - ; - if r2 { - Tuple() - } else { - Abort(2) - }; - Tuple() - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor simplifier: -module 0x42::Test { - private fun apply(v: u64,predicate: |u64|bool): bool { - spec { - assert Ge($t0, 0); - } - ; - (predicate)(v) - } - public fun test_apply(x: u64) { - { - let r1: bool = Test::apply(x, |v: u64| Ge(v, 0)); - spec { - assert r1; - } - ; - if r1 { - Tuple() - } else { - Abort(1) - }; - { - let r2: bool = Test::apply(x, |v: u64| Neq(v, 0)); - spec { - assert r2; - } - ; - if r2 { - Tuple() - } else { - Abort(2) - }; - Tuple() - } - } - } -} // end 0x42::Test - - -// -- Model dump after env processor lambda-lifting: -module 0x42::Test { - private fun apply(v: u64,predicate: |u64|bool): bool { - spec { - assert Ge($t0, 0); - } - ; - (predicate)(v) - } - public fun test_apply(x: u64) { - { - let r1: bool = Test::apply(x, closure Test::test_apply$lambda$1()); - spec { - assert r1; - } - ; - if r1 { - Tuple() - } else { - Abort(1) - }; - { - let r2: bool = Test::apply(x, closure Test::test_apply$lambda$2()); - spec { - assert r2; - } - ; - if r2 { - Tuple() - } else { - Abort(2) - }; - Tuple() - } - } - } - private fun test_apply$lambda$1(v: u64): bool { - Ge(v, 0) - } - private fun test_apply$lambda$2(v: u64): bool { - Neq(v, 0) - } -} // end 0x42::Test - - -// -- Model dump after env processor specification checker: -module 0x42::Test { - private fun apply(v: u64,predicate: |u64|bool): bool { - spec { - assert Ge($t0, 0); - } - ; - (predicate)(v) - } - public fun test_apply(x: u64) { - { - let r1: bool = Test::apply(x, closure Test::test_apply$lambda$1()); - spec { - assert r1; - } - ; - if r1 { - Tuple() - } else { - Abort(1) - }; - { - let r2: bool = Test::apply(x, closure Test::test_apply$lambda$2()); - spec { - assert r2; - } - ; - if r2 { - Tuple() - } else { - Abort(2) - }; - Tuple() - } - } - } - private fun test_apply$lambda$1(v: u64): bool { - Ge(v, 0) - } - private fun test_apply$lambda$2(v: u64): bool { - Neq(v, 0) - } -} // end 0x42::Test - - -// -- Model dump after env processor specification rewriter: -module 0x42::Test { - private fun apply(v: u64,predicate: |u64|bool): bool { - spec { - assert Ge($t0, 0); - } - ; - (predicate)(v) - } - public fun test_apply(x: u64) { - { - let r1: bool = Test::apply(x, closure Test::test_apply$lambda$1()); - spec { - assert r1; - } - ; - if r1 { - Tuple() - } else { - Abort(1) - }; - { - let r2: bool = Test::apply(x, closure Test::test_apply$lambda$2()); - spec { - assert r2; - } - ; - if r2 { - Tuple() - } else { - Abort(2) - }; - Tuple() - } - } - } - private fun test_apply$lambda$1(v: u64): bool { - Ge(v, 0) - } - private fun test_apply$lambda$2(v: u64): bool { - Neq(v, 0) - } -} // end 0x42::Test - - Diagnostics: -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda/inline-parity/spec_inlining.move:6:9 - │ -6 │ predicate(v) - │ ^^^^^^^^^ - -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/spec_inlining.move:10:27 │ 10 │ let r1 = apply(x, |v| v >= 0); │ ^^^^^^^^^^ -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/spec_inlining.move:16:27 │ 16 │ let r2 = apply(x, |v| v != 0); diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/subtype_args.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/subtype_args.lambda.exp index 51316f7cd9c17..9ec45fff49c1b 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/subtype_args.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/subtype_args.lambda.exp @@ -1,4 +1,4 @@ -// -- Model dump before env processor pipeline: +// -- Model dump before bytecode pipeline module 0x8675309::M { struct S { dummy_field: bool, @@ -35,500 +35,34 @@ module 0x8675309::M { } } // end 0x8675309::M - -// -- Model dump after env processor unused checks: -module 0x8675309::M { - struct S { - dummy_field: bool, - } - private fun imm(_x: &T) { - Tuple() - } - private fun imm_imm(_x: &T,_y: &T) { - Tuple() - } - private fun imm_mut(_x: &T,_y: &mut T) { - Tuple() - } - private fun mut_imm(_x: &mut T,_y: &T) { - Tuple() - } - private fun t0() { - M::imm(Freeze(false)(Borrow(Mutable)(0))); - M::imm(Borrow(Immutable)(0)); - M::imm(Freeze(false)(Borrow(Mutable)(pack M::S(false)))); - M::imm(Borrow(Immutable)(pack M::S(false))); - Tuple() - } - private fun t1() { - M::imm_mut(Freeze(false)(Borrow(Mutable)(0)), Borrow(Mutable)(0)); - M::mut_imm(Borrow(Mutable)(0), Freeze(false)(Borrow(Mutable)(0))); - M::imm_imm(Freeze(false)(Borrow(Mutable)(0)), Freeze(false)(Borrow(Mutable)(0))); - Tuple() - } - private fun t2(f: |(&u64, &mut u64)|) { - (f)(Borrow(Mutable)(0), Borrow(Mutable)(0)); - (f)(Borrow(Immutable)(0), Borrow(Mutable)(0)); - Tuple() - } -} // end 0x8675309::M - - -// -- Model dump after env processor type parameter check: -module 0x8675309::M { - struct S { - dummy_field: bool, - } - private fun imm(_x: &T) { - Tuple() - } - private fun imm_imm(_x: &T,_y: &T) { - Tuple() - } - private fun imm_mut(_x: &T,_y: &mut T) { - Tuple() - } - private fun mut_imm(_x: &mut T,_y: &T) { - Tuple() - } - private fun t0() { - M::imm(Freeze(false)(Borrow(Mutable)(0))); - M::imm(Borrow(Immutable)(0)); - M::imm(Freeze(false)(Borrow(Mutable)(pack M::S(false)))); - M::imm(Borrow(Immutable)(pack M::S(false))); - Tuple() - } - private fun t1() { - M::imm_mut(Freeze(false)(Borrow(Mutable)(0)), Borrow(Mutable)(0)); - M::mut_imm(Borrow(Mutable)(0), Freeze(false)(Borrow(Mutable)(0))); - M::imm_imm(Freeze(false)(Borrow(Mutable)(0)), Freeze(false)(Borrow(Mutable)(0))); - Tuple() - } - private fun t2(f: |(&u64, &mut u64)|) { - (f)(Borrow(Mutable)(0), Borrow(Mutable)(0)); - (f)(Borrow(Immutable)(0), Borrow(Mutable)(0)); - Tuple() - } -} // end 0x8675309::M - - -// -- Model dump after env processor check recursive struct definition: -module 0x8675309::M { - struct S { - dummy_field: bool, - } - private fun imm(_x: &T) { - Tuple() - } - private fun imm_imm(_x: &T,_y: &T) { - Tuple() - } - private fun imm_mut(_x: &T,_y: &mut T) { - Tuple() - } - private fun mut_imm(_x: &mut T,_y: &T) { - Tuple() - } - private fun t0() { - M::imm(Freeze(false)(Borrow(Mutable)(0))); - M::imm(Borrow(Immutable)(0)); - M::imm(Freeze(false)(Borrow(Mutable)(pack M::S(false)))); - M::imm(Borrow(Immutable)(pack M::S(false))); - Tuple() - } - private fun t1() { - M::imm_mut(Freeze(false)(Borrow(Mutable)(0)), Borrow(Mutable)(0)); - M::mut_imm(Borrow(Mutable)(0), Freeze(false)(Borrow(Mutable)(0))); - M::imm_imm(Freeze(false)(Borrow(Mutable)(0)), Freeze(false)(Borrow(Mutable)(0))); - Tuple() - } - private fun t2(f: |(&u64, &mut u64)|) { - (f)(Borrow(Mutable)(0), Borrow(Mutable)(0)); - (f)(Borrow(Immutable)(0), Borrow(Mutable)(0)); - Tuple() - } -} // end 0x8675309::M - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x8675309::M { - struct S { - dummy_field: bool, - } - private fun imm(_x: &T) { - Tuple() - } - private fun imm_imm(_x: &T,_y: &T) { - Tuple() - } - private fun imm_mut(_x: &T,_y: &mut T) { - Tuple() - } - private fun mut_imm(_x: &mut T,_y: &T) { - Tuple() - } - private fun t0() { - M::imm(Freeze(false)(Borrow(Mutable)(0))); - M::imm(Borrow(Immutable)(0)); - M::imm(Freeze(false)(Borrow(Mutable)(pack M::S(false)))); - M::imm(Borrow(Immutable)(pack M::S(false))); - Tuple() - } - private fun t1() { - M::imm_mut(Freeze(false)(Borrow(Mutable)(0)), Borrow(Mutable)(0)); - M::mut_imm(Borrow(Mutable)(0), Freeze(false)(Borrow(Mutable)(0))); - M::imm_imm(Freeze(false)(Borrow(Mutable)(0)), Freeze(false)(Borrow(Mutable)(0))); - Tuple() - } - private fun t2(f: |(&u64, &mut u64)|) { - (f)(Borrow(Mutable)(0), Borrow(Mutable)(0)); - (f)(Borrow(Immutable)(0), Borrow(Mutable)(0)); - Tuple() - } -} // end 0x8675309::M - - -// -- Model dump after env processor unused struct params check: -module 0x8675309::M { - struct S { - dummy_field: bool, - } - private fun imm(_x: &T) { - Tuple() - } - private fun imm_imm(_x: &T,_y: &T) { - Tuple() - } - private fun imm_mut(_x: &T,_y: &mut T) { - Tuple() - } - private fun mut_imm(_x: &mut T,_y: &T) { - Tuple() - } - private fun t0() { - M::imm(Freeze(false)(Borrow(Mutable)(0))); - M::imm(Borrow(Immutable)(0)); - M::imm(Freeze(false)(Borrow(Mutable)(pack M::S(false)))); - M::imm(Borrow(Immutable)(pack M::S(false))); - Tuple() - } - private fun t1() { - M::imm_mut(Freeze(false)(Borrow(Mutable)(0)), Borrow(Mutable)(0)); - M::mut_imm(Borrow(Mutable)(0), Freeze(false)(Borrow(Mutable)(0))); - M::imm_imm(Freeze(false)(Borrow(Mutable)(0)), Freeze(false)(Borrow(Mutable)(0))); - Tuple() - } - private fun t2(f: |(&u64, &mut u64)|) { - (f)(Borrow(Mutable)(0), Borrow(Mutable)(0)); - (f)(Borrow(Immutable)(0), Borrow(Mutable)(0)); - Tuple() - } -} // end 0x8675309::M - - -// -- Model dump after env processor access and use check before inlining: -module 0x8675309::M { - struct S { - dummy_field: bool, - } - private fun imm(_x: &T) { - Tuple() - } - private fun imm_imm(_x: &T,_y: &T) { - Tuple() - } - private fun imm_mut(_x: &T,_y: &mut T) { - Tuple() - } - private fun mut_imm(_x: &mut T,_y: &T) { - Tuple() - } - private fun t0() { - M::imm(Freeze(false)(Borrow(Mutable)(0))); - M::imm(Borrow(Immutable)(0)); - M::imm(Freeze(false)(Borrow(Mutable)(pack M::S(false)))); - M::imm(Borrow(Immutable)(pack M::S(false))); - Tuple() - } - private fun t1() { - M::imm_mut(Freeze(false)(Borrow(Mutable)(0)), Borrow(Mutable)(0)); - M::mut_imm(Borrow(Mutable)(0), Freeze(false)(Borrow(Mutable)(0))); - M::imm_imm(Freeze(false)(Borrow(Mutable)(0)), Freeze(false)(Borrow(Mutable)(0))); - Tuple() - } - private fun t2(f: |(&u64, &mut u64)|) { - (f)(Borrow(Mutable)(0), Borrow(Mutable)(0)); - (f)(Borrow(Immutable)(0), Borrow(Mutable)(0)); - Tuple() - } -} // end 0x8675309::M - - -// -- Model dump after env processor inlining: -module 0x8675309::M { - struct S { - dummy_field: bool, - } - private fun imm(_x: &T) { - Tuple() - } - private fun imm_imm(_x: &T,_y: &T) { - Tuple() - } - private fun imm_mut(_x: &T,_y: &mut T) { - Tuple() - } - private fun mut_imm(_x: &mut T,_y: &T) { - Tuple() - } - private fun t0() { - M::imm(Freeze(false)(Borrow(Mutable)(0))); - M::imm(Borrow(Immutable)(0)); - M::imm(Freeze(false)(Borrow(Mutable)(pack M::S(false)))); - M::imm(Borrow(Immutable)(pack M::S(false))); - Tuple() - } - private fun t1() { - M::imm_mut(Freeze(false)(Borrow(Mutable)(0)), Borrow(Mutable)(0)); - M::mut_imm(Borrow(Mutable)(0), Freeze(false)(Borrow(Mutable)(0))); - M::imm_imm(Freeze(false)(Borrow(Mutable)(0)), Freeze(false)(Borrow(Mutable)(0))); - Tuple() - } - private fun t2(f: |(&u64, &mut u64)|) { - (f)(Borrow(Mutable)(0), Borrow(Mutable)(0)); - (f)(Borrow(Immutable)(0), Borrow(Mutable)(0)); - Tuple() - } -} // end 0x8675309::M - - -// -- Model dump after env processor access and use check after inlining: -module 0x8675309::M { - struct S { - dummy_field: bool, - } - private fun imm(_x: &T) { - Tuple() - } - private fun imm_imm(_x: &T,_y: &T) { - Tuple() - } - private fun imm_mut(_x: &T,_y: &mut T) { - Tuple() - } - private fun mut_imm(_x: &mut T,_y: &T) { - Tuple() - } - private fun t0() { - M::imm(Freeze(false)(Borrow(Mutable)(0))); - M::imm(Borrow(Immutable)(0)); - M::imm(Freeze(false)(Borrow(Mutable)(pack M::S(false)))); - M::imm(Borrow(Immutable)(pack M::S(false))); - Tuple() - } - private fun t1() { - M::imm_mut(Freeze(false)(Borrow(Mutable)(0)), Borrow(Mutable)(0)); - M::mut_imm(Borrow(Mutable)(0), Freeze(false)(Borrow(Mutable)(0))); - M::imm_imm(Freeze(false)(Borrow(Mutable)(0)), Freeze(false)(Borrow(Mutable)(0))); - Tuple() - } - private fun t2(f: |(&u64, &mut u64)|) { - (f)(Borrow(Mutable)(0), Borrow(Mutable)(0)); - (f)(Borrow(Immutable)(0), Borrow(Mutable)(0)); - Tuple() - } -} // end 0x8675309::M - - -// -- Model dump after env processor acquires check: -module 0x8675309::M { - struct S { - dummy_field: bool, - } - private fun imm(_x: &T) { - Tuple() - } - private fun imm_imm(_x: &T,_y: &T) { - Tuple() - } - private fun imm_mut(_x: &T,_y: &mut T) { - Tuple() - } - private fun mut_imm(_x: &mut T,_y: &T) { - Tuple() - } - private fun t0() { - M::imm(Freeze(false)(Borrow(Mutable)(0))); - M::imm(Borrow(Immutable)(0)); - M::imm(Freeze(false)(Borrow(Mutable)(pack M::S(false)))); - M::imm(Borrow(Immutable)(pack M::S(false))); - Tuple() - } - private fun t1() { - M::imm_mut(Freeze(false)(Borrow(Mutable)(0)), Borrow(Mutable)(0)); - M::mut_imm(Borrow(Mutable)(0), Freeze(false)(Borrow(Mutable)(0))); - M::imm_imm(Freeze(false)(Borrow(Mutable)(0)), Freeze(false)(Borrow(Mutable)(0))); - Tuple() - } - private fun t2(f: |(&u64, &mut u64)|) { - (f)(Borrow(Mutable)(0), Borrow(Mutable)(0)); - (f)(Borrow(Immutable)(0), Borrow(Mutable)(0)); - Tuple() - } -} // end 0x8675309::M - - -// -- Model dump after env processor simplifier: -module 0x8675309::M { - struct S { - dummy_field: bool, - } - private fun imm(_x: &T) { - Tuple() - } - private fun imm_imm(_x: &T,_y: &T) { - Tuple() - } - private fun imm_mut(_x: &T,_y: &mut T) { - Tuple() - } - private fun mut_imm(_x: &mut T,_y: &T) { - Tuple() - } - private fun t0() { - M::imm(Freeze(false)(Borrow(Mutable)(0))); - M::imm(Borrow(Immutable)(0)); - M::imm(Freeze(false)(Borrow(Mutable)(pack M::S(false)))); - M::imm(Borrow(Immutable)(pack M::S(false))); - Tuple() - } - private fun t1() { - M::imm_mut(Freeze(false)(Borrow(Mutable)(0)), Borrow(Mutable)(0)); - M::mut_imm(Borrow(Mutable)(0), Freeze(false)(Borrow(Mutable)(0))); - M::imm_imm(Freeze(false)(Borrow(Mutable)(0)), Freeze(false)(Borrow(Mutable)(0))); - Tuple() - } - private fun t2(f: |(&u64, &mut u64)|) { - (f)(Borrow(Mutable)(0), Borrow(Mutable)(0)); - (f)(Borrow(Immutable)(0), Borrow(Mutable)(0)); - Tuple() - } -} // end 0x8675309::M - - -// -- Model dump after env processor lambda-lifting: -module 0x8675309::M { - struct S { - dummy_field: bool, - } - private fun imm(_x: &T) { - Tuple() - } - private fun imm_imm(_x: &T,_y: &T) { - Tuple() - } - private fun imm_mut(_x: &T,_y: &mut T) { - Tuple() - } - private fun mut_imm(_x: &mut T,_y: &T) { - Tuple() - } - private fun t0() { - M::imm(Freeze(false)(Borrow(Mutable)(0))); - M::imm(Borrow(Immutable)(0)); - M::imm(Freeze(false)(Borrow(Mutable)(pack M::S(false)))); - M::imm(Borrow(Immutable)(pack M::S(false))); - Tuple() - } - private fun t1() { - M::imm_mut(Freeze(false)(Borrow(Mutable)(0)), Borrow(Mutable)(0)); - M::mut_imm(Borrow(Mutable)(0), Freeze(false)(Borrow(Mutable)(0))); - M::imm_imm(Freeze(false)(Borrow(Mutable)(0)), Freeze(false)(Borrow(Mutable)(0))); - Tuple() - } - private fun t2(f: |(&u64, &mut u64)|) { - (f)(Borrow(Mutable)(0), Borrow(Mutable)(0)); - (f)(Borrow(Immutable)(0), Borrow(Mutable)(0)); - Tuple() - } -} // end 0x8675309::M - - -// -- Model dump after env processor specification checker: -module 0x8675309::M { - struct S { - dummy_field: bool, - } - private fun imm(_x: &T) { - Tuple() - } - private fun imm_imm(_x: &T,_y: &T) { - Tuple() - } - private fun imm_mut(_x: &T,_y: &mut T) { - Tuple() - } - private fun mut_imm(_x: &mut T,_y: &T) { - Tuple() - } - private fun t0() { - M::imm(Freeze(false)(Borrow(Mutable)(0))); - M::imm(Borrow(Immutable)(0)); - M::imm(Freeze(false)(Borrow(Mutable)(pack M::S(false)))); - M::imm(Borrow(Immutable)(pack M::S(false))); - Tuple() - } - private fun t1() { - M::imm_mut(Freeze(false)(Borrow(Mutable)(0)), Borrow(Mutable)(0)); - M::mut_imm(Borrow(Mutable)(0), Freeze(false)(Borrow(Mutable)(0))); - M::imm_imm(Freeze(false)(Borrow(Mutable)(0)), Freeze(false)(Borrow(Mutable)(0))); - Tuple() - } - private fun t2(f: |(&u64, &mut u64)|) { - (f)(Borrow(Mutable)(0), Borrow(Mutable)(0)); - (f)(Borrow(Immutable)(0), Borrow(Mutable)(0)); - Tuple() - } -} // end 0x8675309::M - - -// -- Model dump after env processor specification rewriter: +// -- Sourcified model before bytecode pipeline module 0x8675309::M { - struct S { - dummy_field: bool, + struct S has drop { } - private fun imm(_x: &T) { - Tuple() + fun imm(_x: &T) { } - private fun imm_imm(_x: &T,_y: &T) { - Tuple() + fun imm_imm(_x: &T, _y: &T) { } - private fun imm_mut(_x: &T,_y: &mut T) { - Tuple() + fun imm_mut(_x: &T, _y: &mut T) { } - private fun mut_imm(_x: &mut T,_y: &T) { - Tuple() + fun mut_imm(_x: &mut T, _y: &T) { } - private fun t0() { - M::imm(Freeze(false)(Borrow(Mutable)(0))); - M::imm(Borrow(Immutable)(0)); - M::imm(Freeze(false)(Borrow(Mutable)(pack M::S(false)))); - M::imm(Borrow(Immutable)(pack M::S(false))); - Tuple() + fun t0() { + imm(/*freeze*/&mut 0); + imm(&0); + imm(/*freeze*/&mut S{}); + imm(&S{}); } - private fun t1() { - M::imm_mut(Freeze(false)(Borrow(Mutable)(0)), Borrow(Mutable)(0)); - M::mut_imm(Borrow(Mutable)(0), Freeze(false)(Borrow(Mutable)(0))); - M::imm_imm(Freeze(false)(Borrow(Mutable)(0)), Freeze(false)(Borrow(Mutable)(0))); - Tuple() + fun t1() { + imm_mut(/*freeze*/&mut 0, &mut 0); + mut_imm(&mut 0, /*freeze*/&mut 0); + imm_imm(/*freeze*/&mut 0, /*freeze*/&mut 0); } - private fun t2(f: |(&u64, &mut u64)|) { - (f)(Borrow(Mutable)(0), Borrow(Mutable)(0)); - (f)(Borrow(Immutable)(0), Borrow(Mutable)(0)); - Tuple() + fun t2(f: |(&u64, &mut u64)|) { + f(&mut 0, &mut 0); + f(&0, &mut 0); } -} // end 0x8675309::M - +} Diagnostics: @@ -536,10 +70,10 @@ error: Calls to function values other than inline function parameters not yet su ┌─ tests/lambda/inline-parity/subtype_args.move:24:9 │ 24 │ f(&mut 0, &mut 0); - │ ^ + │ ^^^^^^^^^^^^^^^^^ error: Calls to function values other than inline function parameters not yet supported ┌─ tests/lambda/inline-parity/subtype_args.move:25:9 │ 25 │ f(&0, &mut 0); - │ ^ + │ ^^^^^^^^^^^^^ diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/unnecessary_numerical_extreme_comparisons_warn.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/unnecessary_numerical_extreme_comparisons_warn.lambda.exp index 2506246844937..a451017f6c8e8 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/unnecessary_numerical_extreme_comparisons_warn.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/unnecessary_numerical_extreme_comparisons_warn.lambda.exp @@ -1,1799 +1,6 @@ -// -- Model dump before env processor pipeline: -module 0xc0ffee::m { - private fun apply(f: |u8|bool,x: u8): bool { - (f)(x) - } - private fun bar() { - Tuple() - } - private fun foo(x: T): T { - x - } - public fun test1(x: u8) { - if Gt(Add(x, 1), 255) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test2(x: &u8,y: &u8) { - if Eq(Gt(Add(Deref(x), Deref(y)), 255), true) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test3(x: u8) { - if Or(Lt(x, 0), Gt(0, x)) { - m::bar() - } else { - Tuple() - }; - if Le(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Ge(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - if Gt(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Lt(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - if Ge(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Le(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test4(a: u8,b: u16,c: u32,d: u64,e: u128,f: u256) { - if Or(Gt(a, 255), Gt(f, Cast(255))) { - m::bar() - } else { - Tuple() - }; - if Ge(b, 65535) { - m::bar() - } else { - Tuple() - }; - if Lt(4294967295, c) { - m::bar() - } else { - Tuple() - }; - if Le(18446744073709551615, d) { - m::bar() - } else { - Tuple() - }; - if Lt(e, 340282366920938463463374607431768211455) { - m::bar() - } else { - Tuple() - }; - if Le(f, 115792089237316195423570985008687907853269984665640564039457584007913129639935) { - m::bar() - } else { - Tuple() - }; - if Ge(115792089237316195423570985008687907853269984665640564039457584007913129639935, f) { - m::bar() - } else { - Tuple() - }; - if Gt(340282366920938463463374607431768211455, e) { - m::bar() - } else { - Tuple() - }; - spec { - assert Le($t0, 255); - } - - } - public fun test5(x: u8): bool { - m::apply(|x: u8| Gt(x, 255), x) - } -} // end 0xc0ffee::m -module 0xc0ffee::no_warn { - public fun test(x: u8) { - if Lt(x, 0) { - Abort(1) - } else { - Tuple() - }; - Tuple() - } -} // end 0xc0ffee::no_warn - - -// -- Model dump after env processor unused checks: -module 0xc0ffee::m { - private fun apply(f: |u8|bool,x: u8): bool { - (f)(x) - } - private fun bar() { - Tuple() - } - private fun foo(x: T): T { - x - } - public fun test1(x: u8) { - if Gt(Add(x, 1), 255) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test2(x: &u8,y: &u8) { - if Eq(Gt(Add(Deref(x), Deref(y)), 255), true) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test3(x: u8) { - if Or(Lt(x, 0), Gt(0, x)) { - m::bar() - } else { - Tuple() - }; - if Le(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Ge(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - if Gt(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Lt(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - if Ge(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Le(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test4(a: u8,b: u16,c: u32,d: u64,e: u128,f: u256) { - if Or(Gt(a, 255), Gt(f, Cast(255))) { - m::bar() - } else { - Tuple() - }; - if Ge(b, 65535) { - m::bar() - } else { - Tuple() - }; - if Lt(4294967295, c) { - m::bar() - } else { - Tuple() - }; - if Le(18446744073709551615, d) { - m::bar() - } else { - Tuple() - }; - if Lt(e, 340282366920938463463374607431768211455) { - m::bar() - } else { - Tuple() - }; - if Le(f, 115792089237316195423570985008687907853269984665640564039457584007913129639935) { - m::bar() - } else { - Tuple() - }; - if Ge(115792089237316195423570985008687907853269984665640564039457584007913129639935, f) { - m::bar() - } else { - Tuple() - }; - if Gt(340282366920938463463374607431768211455, e) { - m::bar() - } else { - Tuple() - }; - spec { - assert Le($t0, 255); - } - - } - public fun test5(x: u8): bool { - m::apply(|x: u8| Gt(x, 255), x) - } -} // end 0xc0ffee::m -module 0xc0ffee::no_warn { - public fun test(x: u8) { - if Lt(x, 0) { - Abort(1) - } else { - Tuple() - }; - Tuple() - } -} // end 0xc0ffee::no_warn - - -// -- Model dump after env processor type parameter check: -module 0xc0ffee::m { - private fun apply(f: |u8|bool,x: u8): bool { - (f)(x) - } - private fun bar() { - Tuple() - } - private fun foo(x: T): T { - x - } - public fun test1(x: u8) { - if Gt(Add(x, 1), 255) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test2(x: &u8,y: &u8) { - if Eq(Gt(Add(Deref(x), Deref(y)), 255), true) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test3(x: u8) { - if Or(Lt(x, 0), Gt(0, x)) { - m::bar() - } else { - Tuple() - }; - if Le(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Ge(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - if Gt(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Lt(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - if Ge(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Le(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test4(a: u8,b: u16,c: u32,d: u64,e: u128,f: u256) { - if Or(Gt(a, 255), Gt(f, Cast(255))) { - m::bar() - } else { - Tuple() - }; - if Ge(b, 65535) { - m::bar() - } else { - Tuple() - }; - if Lt(4294967295, c) { - m::bar() - } else { - Tuple() - }; - if Le(18446744073709551615, d) { - m::bar() - } else { - Tuple() - }; - if Lt(e, 340282366920938463463374607431768211455) { - m::bar() - } else { - Tuple() - }; - if Le(f, 115792089237316195423570985008687907853269984665640564039457584007913129639935) { - m::bar() - } else { - Tuple() - }; - if Ge(115792089237316195423570985008687907853269984665640564039457584007913129639935, f) { - m::bar() - } else { - Tuple() - }; - if Gt(340282366920938463463374607431768211455, e) { - m::bar() - } else { - Tuple() - }; - spec { - assert Le($t0, 255); - } - - } - public fun test5(x: u8): bool { - m::apply(|x: u8| Gt(x, 255), x) - } -} // end 0xc0ffee::m -module 0xc0ffee::no_warn { - public fun test(x: u8) { - if Lt(x, 0) { - Abort(1) - } else { - Tuple() - }; - Tuple() - } -} // end 0xc0ffee::no_warn - - -// -- Model dump after env processor check recursive struct definition: -module 0xc0ffee::m { - private fun apply(f: |u8|bool,x: u8): bool { - (f)(x) - } - private fun bar() { - Tuple() - } - private fun foo(x: T): T { - x - } - public fun test1(x: u8) { - if Gt(Add(x, 1), 255) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test2(x: &u8,y: &u8) { - if Eq(Gt(Add(Deref(x), Deref(y)), 255), true) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test3(x: u8) { - if Or(Lt(x, 0), Gt(0, x)) { - m::bar() - } else { - Tuple() - }; - if Le(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Ge(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - if Gt(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Lt(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - if Ge(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Le(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test4(a: u8,b: u16,c: u32,d: u64,e: u128,f: u256) { - if Or(Gt(a, 255), Gt(f, Cast(255))) { - m::bar() - } else { - Tuple() - }; - if Ge(b, 65535) { - m::bar() - } else { - Tuple() - }; - if Lt(4294967295, c) { - m::bar() - } else { - Tuple() - }; - if Le(18446744073709551615, d) { - m::bar() - } else { - Tuple() - }; - if Lt(e, 340282366920938463463374607431768211455) { - m::bar() - } else { - Tuple() - }; - if Le(f, 115792089237316195423570985008687907853269984665640564039457584007913129639935) { - m::bar() - } else { - Tuple() - }; - if Ge(115792089237316195423570985008687907853269984665640564039457584007913129639935, f) { - m::bar() - } else { - Tuple() - }; - if Gt(340282366920938463463374607431768211455, e) { - m::bar() - } else { - Tuple() - }; - spec { - assert Le($t0, 255); - } - - } - public fun test5(x: u8): bool { - m::apply(|x: u8| Gt(x, 255), x) - } -} // end 0xc0ffee::m -module 0xc0ffee::no_warn { - public fun test(x: u8) { - if Lt(x, 0) { - Abort(1) - } else { - Tuple() - }; - Tuple() - } -} // end 0xc0ffee::no_warn - - -// -- Model dump after env processor check cyclic type instantiation: -module 0xc0ffee::m { - private fun apply(f: |u8|bool,x: u8): bool { - (f)(x) - } - private fun bar() { - Tuple() - } - private fun foo(x: T): T { - x - } - public fun test1(x: u8) { - if Gt(Add(x, 1), 255) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test2(x: &u8,y: &u8) { - if Eq(Gt(Add(Deref(x), Deref(y)), 255), true) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test3(x: u8) { - if Or(Lt(x, 0), Gt(0, x)) { - m::bar() - } else { - Tuple() - }; - if Le(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Ge(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - if Gt(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Lt(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - if Ge(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Le(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test4(a: u8,b: u16,c: u32,d: u64,e: u128,f: u256) { - if Or(Gt(a, 255), Gt(f, Cast(255))) { - m::bar() - } else { - Tuple() - }; - if Ge(b, 65535) { - m::bar() - } else { - Tuple() - }; - if Lt(4294967295, c) { - m::bar() - } else { - Tuple() - }; - if Le(18446744073709551615, d) { - m::bar() - } else { - Tuple() - }; - if Lt(e, 340282366920938463463374607431768211455) { - m::bar() - } else { - Tuple() - }; - if Le(f, 115792089237316195423570985008687907853269984665640564039457584007913129639935) { - m::bar() - } else { - Tuple() - }; - if Ge(115792089237316195423570985008687907853269984665640564039457584007913129639935, f) { - m::bar() - } else { - Tuple() - }; - if Gt(340282366920938463463374607431768211455, e) { - m::bar() - } else { - Tuple() - }; - spec { - assert Le($t0, 255); - } - - } - public fun test5(x: u8): bool { - m::apply(|x: u8| Gt(x, 255), x) - } -} // end 0xc0ffee::m -module 0xc0ffee::no_warn { - public fun test(x: u8) { - if Lt(x, 0) { - Abort(1) - } else { - Tuple() - }; - Tuple() - } -} // end 0xc0ffee::no_warn - - -// -- Model dump after env processor unused struct params check: -module 0xc0ffee::m { - private fun apply(f: |u8|bool,x: u8): bool { - (f)(x) - } - private fun bar() { - Tuple() - } - private fun foo(x: T): T { - x - } - public fun test1(x: u8) { - if Gt(Add(x, 1), 255) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test2(x: &u8,y: &u8) { - if Eq(Gt(Add(Deref(x), Deref(y)), 255), true) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test3(x: u8) { - if Or(Lt(x, 0), Gt(0, x)) { - m::bar() - } else { - Tuple() - }; - if Le(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Ge(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - if Gt(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Lt(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - if Ge(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Le(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test4(a: u8,b: u16,c: u32,d: u64,e: u128,f: u256) { - if Or(Gt(a, 255), Gt(f, Cast(255))) { - m::bar() - } else { - Tuple() - }; - if Ge(b, 65535) { - m::bar() - } else { - Tuple() - }; - if Lt(4294967295, c) { - m::bar() - } else { - Tuple() - }; - if Le(18446744073709551615, d) { - m::bar() - } else { - Tuple() - }; - if Lt(e, 340282366920938463463374607431768211455) { - m::bar() - } else { - Tuple() - }; - if Le(f, 115792089237316195423570985008687907853269984665640564039457584007913129639935) { - m::bar() - } else { - Tuple() - }; - if Ge(115792089237316195423570985008687907853269984665640564039457584007913129639935, f) { - m::bar() - } else { - Tuple() - }; - if Gt(340282366920938463463374607431768211455, e) { - m::bar() - } else { - Tuple() - }; - spec { - assert Le($t0, 255); - } - - } - public fun test5(x: u8): bool { - m::apply(|x: u8| Gt(x, 255), x) - } -} // end 0xc0ffee::m -module 0xc0ffee::no_warn { - public fun test(x: u8) { - if Lt(x, 0) { - Abort(1) - } else { - Tuple() - }; - Tuple() - } -} // end 0xc0ffee::no_warn - - -// -- Model dump after env processor access and use check before inlining: -module 0xc0ffee::m { - private fun apply(f: |u8|bool,x: u8): bool { - (f)(x) - } - private fun bar() { - Tuple() - } - private fun foo(x: T): T { - x - } - public fun test1(x: u8) { - if Gt(Add(x, 1), 255) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test2(x: &u8,y: &u8) { - if Eq(Gt(Add(Deref(x), Deref(y)), 255), true) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test3(x: u8) { - if Or(Lt(x, 0), Gt(0, x)) { - m::bar() - } else { - Tuple() - }; - if Le(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Ge(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - if Gt(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Lt(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - if Ge(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Le(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test4(a: u8,b: u16,c: u32,d: u64,e: u128,f: u256) { - if Or(Gt(a, 255), Gt(f, Cast(255))) { - m::bar() - } else { - Tuple() - }; - if Ge(b, 65535) { - m::bar() - } else { - Tuple() - }; - if Lt(4294967295, c) { - m::bar() - } else { - Tuple() - }; - if Le(18446744073709551615, d) { - m::bar() - } else { - Tuple() - }; - if Lt(e, 340282366920938463463374607431768211455) { - m::bar() - } else { - Tuple() - }; - if Le(f, 115792089237316195423570985008687907853269984665640564039457584007913129639935) { - m::bar() - } else { - Tuple() - }; - if Ge(115792089237316195423570985008687907853269984665640564039457584007913129639935, f) { - m::bar() - } else { - Tuple() - }; - if Gt(340282366920938463463374607431768211455, e) { - m::bar() - } else { - Tuple() - }; - spec { - assert Le($t0, 255); - } - - } - public fun test5(x: u8): bool { - m::apply(|x: u8| Gt(x, 255), x) - } -} // end 0xc0ffee::m -module 0xc0ffee::no_warn { - public fun test(x: u8) { - if Lt(x, 0) { - Abort(1) - } else { - Tuple() - }; - Tuple() - } -} // end 0xc0ffee::no_warn - - -// -- Model dump after env processor inlining: -module 0xc0ffee::m { - private fun apply(f: |u8|bool,x: u8): bool { - (f)(x) - } - private fun bar() { - Tuple() - } - private fun foo(x: T): T { - x - } - public fun test1(x: u8) { - if Gt(Add(x, 1), 255) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test2(x: &u8,y: &u8) { - if Eq(Gt(Add(Deref(x), Deref(y)), 255), true) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test3(x: u8) { - if Or(Lt(x, 0), Gt(0, x)) { - m::bar() - } else { - Tuple() - }; - if Le(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Ge(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - if Gt(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Lt(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - if Ge(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Le(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test4(a: u8,b: u16,c: u32,d: u64,e: u128,f: u256) { - if Or(Gt(a, 255), Gt(f, Cast(255))) { - m::bar() - } else { - Tuple() - }; - if Ge(b, 65535) { - m::bar() - } else { - Tuple() - }; - if Lt(4294967295, c) { - m::bar() - } else { - Tuple() - }; - if Le(18446744073709551615, d) { - m::bar() - } else { - Tuple() - }; - if Lt(e, 340282366920938463463374607431768211455) { - m::bar() - } else { - Tuple() - }; - if Le(f, 115792089237316195423570985008687907853269984665640564039457584007913129639935) { - m::bar() - } else { - Tuple() - }; - if Ge(115792089237316195423570985008687907853269984665640564039457584007913129639935, f) { - m::bar() - } else { - Tuple() - }; - if Gt(340282366920938463463374607431768211455, e) { - m::bar() - } else { - Tuple() - }; - spec { - assert Le($t0, 255); - } - - } - public fun test5(x: u8): bool { - m::apply(|x: u8| Gt(x, 255), x) - } -} // end 0xc0ffee::m -module 0xc0ffee::no_warn { - public fun test(x: u8) { - if Lt(x, 0) { - Abort(1) - } else { - Tuple() - }; - Tuple() - } -} // end 0xc0ffee::no_warn - - -// -- Model dump after env processor access and use check after inlining: -module 0xc0ffee::m { - private fun apply(f: |u8|bool,x: u8): bool { - (f)(x) - } - private fun bar() { - Tuple() - } - private fun foo(x: T): T { - x - } - public fun test1(x: u8) { - if Gt(Add(x, 1), 255) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test2(x: &u8,y: &u8) { - if Eq(Gt(Add(Deref(x), Deref(y)), 255), true) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test3(x: u8) { - if Or(Lt(x, 0), Gt(0, x)) { - m::bar() - } else { - Tuple() - }; - if Le(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Ge(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - if Gt(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Lt(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - if Ge(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Le(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test4(a: u8,b: u16,c: u32,d: u64,e: u128,f: u256) { - if Or(Gt(a, 255), Gt(f, Cast(255))) { - m::bar() - } else { - Tuple() - }; - if Ge(b, 65535) { - m::bar() - } else { - Tuple() - }; - if Lt(4294967295, c) { - m::bar() - } else { - Tuple() - }; - if Le(18446744073709551615, d) { - m::bar() - } else { - Tuple() - }; - if Lt(e, 340282366920938463463374607431768211455) { - m::bar() - } else { - Tuple() - }; - if Le(f, 115792089237316195423570985008687907853269984665640564039457584007913129639935) { - m::bar() - } else { - Tuple() - }; - if Ge(115792089237316195423570985008687907853269984665640564039457584007913129639935, f) { - m::bar() - } else { - Tuple() - }; - if Gt(340282366920938463463374607431768211455, e) { - m::bar() - } else { - Tuple() - }; - spec { - assert Le($t0, 255); - } - - } - public fun test5(x: u8): bool { - m::apply(|x: u8| Gt(x, 255), x) - } -} // end 0xc0ffee::m -module 0xc0ffee::no_warn { - public fun test(x: u8) { - if Lt(x, 0) { - Abort(1) - } else { - Tuple() - }; - Tuple() - } -} // end 0xc0ffee::no_warn - - -// -- Model dump after env processor acquires check: -module 0xc0ffee::m { - private fun apply(f: |u8|bool,x: u8): bool { - (f)(x) - } - private fun bar() { - Tuple() - } - private fun foo(x: T): T { - x - } - public fun test1(x: u8) { - if Gt(Add(x, 1), 255) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test2(x: &u8,y: &u8) { - if Eq(Gt(Add(Deref(x), Deref(y)), 255), true) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test3(x: u8) { - if Or(Lt(x, 0), Gt(0, x)) { - m::bar() - } else { - Tuple() - }; - if Le(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Ge(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - if Gt(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Lt(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - if Ge(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Le(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test4(a: u8,b: u16,c: u32,d: u64,e: u128,f: u256) { - if Or(Gt(a, 255), Gt(f, Cast(255))) { - m::bar() - } else { - Tuple() - }; - if Ge(b, 65535) { - m::bar() - } else { - Tuple() - }; - if Lt(4294967295, c) { - m::bar() - } else { - Tuple() - }; - if Le(18446744073709551615, d) { - m::bar() - } else { - Tuple() - }; - if Lt(e, 340282366920938463463374607431768211455) { - m::bar() - } else { - Tuple() - }; - if Le(f, 115792089237316195423570985008687907853269984665640564039457584007913129639935) { - m::bar() - } else { - Tuple() - }; - if Ge(115792089237316195423570985008687907853269984665640564039457584007913129639935, f) { - m::bar() - } else { - Tuple() - }; - if Gt(340282366920938463463374607431768211455, e) { - m::bar() - } else { - Tuple() - }; - spec { - assert Le($t0, 255); - } - - } - public fun test5(x: u8): bool { - m::apply(|x: u8| Gt(x, 255), x) - } -} // end 0xc0ffee::m -module 0xc0ffee::no_warn { - public fun test(x: u8) { - if Lt(x, 0) { - Abort(1) - } else { - Tuple() - }; - Tuple() - } -} // end 0xc0ffee::no_warn - - -// -- Model dump after env processor simplifier: -module 0xc0ffee::m { - private fun apply(f: |u8|bool,x: u8): bool { - (f)(x) - } - private fun bar() { - Tuple() - } - private fun foo(x: T): T { - x - } - public fun test1(x: u8) { - if Gt(Add(x, 1), 255) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test2(x: &u8,y: &u8) { - if Eq(Gt(Add(Deref(x), Deref(y)), 255), true) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test3(x: u8) { - if Or(Lt(x, 0), Gt(0, x)) { - m::bar() - } else { - Tuple() - }; - if Le(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Ge(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - if Gt(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Lt(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - if Ge(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Le(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test4(a: u8,b: u16,c: u32,d: u64,e: u128,f: u256) { - if Or(Gt(a, 255), Gt(f, 255)) { - m::bar() - } else { - Tuple() - }; - if Ge(b, 65535) { - m::bar() - } else { - Tuple() - }; - if Lt(4294967295, c) { - m::bar() - } else { - Tuple() - }; - if Le(18446744073709551615, d) { - m::bar() - } else { - Tuple() - }; - if Lt(e, 340282366920938463463374607431768211455) { - m::bar() - } else { - Tuple() - }; - if Le(f, 115792089237316195423570985008687907853269984665640564039457584007913129639935) { - m::bar() - } else { - Tuple() - }; - if Ge(115792089237316195423570985008687907853269984665640564039457584007913129639935, f) { - m::bar() - } else { - Tuple() - }; - if Gt(340282366920938463463374607431768211455, e) { - m::bar() - } else { - Tuple() - }; - spec { - assert Le($t0, 255); - } - - } - public fun test5(x: u8): bool { - m::apply(|x: u8| Gt(x, 255), x) - } -} // end 0xc0ffee::m -module 0xc0ffee::no_warn { - public fun test(x: u8) { - if Lt(x, 0) { - Abort(1) - } else { - Tuple() - }; - Tuple() - } -} // end 0xc0ffee::no_warn - - -// -- Model dump after env processor lambda-lifting: -module 0xc0ffee::m { - private fun apply(f: |u8|bool,x: u8): bool { - (f)(x) - } - private fun bar() { - Tuple() - } - private fun foo(x: T): T { - x - } - public fun test1(x: u8) { - if Gt(Add(x, 1), 255) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test2(x: &u8,y: &u8) { - if Eq(Gt(Add(Deref(x), Deref(y)), 255), true) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test3(x: u8) { - if Or(Lt(x, 0), Gt(0, x)) { - m::bar() - } else { - Tuple() - }; - if Le(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Ge(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - if Gt(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Lt(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - if Ge(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Le(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test4(a: u8,b: u16,c: u32,d: u64,e: u128,f: u256) { - if Or(Gt(a, 255), Gt(f, 255)) { - m::bar() - } else { - Tuple() - }; - if Ge(b, 65535) { - m::bar() - } else { - Tuple() - }; - if Lt(4294967295, c) { - m::bar() - } else { - Tuple() - }; - if Le(18446744073709551615, d) { - m::bar() - } else { - Tuple() - }; - if Lt(e, 340282366920938463463374607431768211455) { - m::bar() - } else { - Tuple() - }; - if Le(f, 115792089237316195423570985008687907853269984665640564039457584007913129639935) { - m::bar() - } else { - Tuple() - }; - if Ge(115792089237316195423570985008687907853269984665640564039457584007913129639935, f) { - m::bar() - } else { - Tuple() - }; - if Gt(340282366920938463463374607431768211455, e) { - m::bar() - } else { - Tuple() - }; - spec { - assert Le($t0, 255); - } - - } - public fun test5(x: u8): bool { - m::apply(closure m::test5$lambda$1(), x) - } - private fun test5$lambda$1(x: u8): bool { - Gt(x, 255) - } -} // end 0xc0ffee::m -module 0xc0ffee::no_warn { - public fun test(x: u8) { - if Lt(x, 0) { - Abort(1) - } else { - Tuple() - }; - Tuple() - } -} // end 0xc0ffee::no_warn - - -// -- Model dump after env processor specification checker: -module 0xc0ffee::m { - private fun apply(f: |u8|bool,x: u8): bool { - (f)(x) - } - private fun bar() { - Tuple() - } - private fun foo(x: T): T { - x - } - public fun test1(x: u8) { - if Gt(Add(x, 1), 255) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test2(x: &u8,y: &u8) { - if Eq(Gt(Add(Deref(x), Deref(y)), 255), true) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test3(x: u8) { - if Or(Lt(x, 0), Gt(0, x)) { - m::bar() - } else { - Tuple() - }; - if Le(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Ge(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - if Gt(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Lt(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - if Ge(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Le(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test4(a: u8,b: u16,c: u32,d: u64,e: u128,f: u256) { - if Or(Gt(a, 255), Gt(f, 255)) { - m::bar() - } else { - Tuple() - }; - if Ge(b, 65535) { - m::bar() - } else { - Tuple() - }; - if Lt(4294967295, c) { - m::bar() - } else { - Tuple() - }; - if Le(18446744073709551615, d) { - m::bar() - } else { - Tuple() - }; - if Lt(e, 340282366920938463463374607431768211455) { - m::bar() - } else { - Tuple() - }; - if Le(f, 115792089237316195423570985008687907853269984665640564039457584007913129639935) { - m::bar() - } else { - Tuple() - }; - if Ge(115792089237316195423570985008687907853269984665640564039457584007913129639935, f) { - m::bar() - } else { - Tuple() - }; - if Gt(340282366920938463463374607431768211455, e) { - m::bar() - } else { - Tuple() - }; - spec { - assert Le($t0, 255); - } - - } - public fun test5(x: u8): bool { - m::apply(closure m::test5$lambda$1(), x) - } - private fun test5$lambda$1(x: u8): bool { - Gt(x, 255) - } -} // end 0xc0ffee::m -module 0xc0ffee::no_warn { - public fun test(x: u8) { - if Lt(x, 0) { - Abort(1) - } else { - Tuple() - }; - Tuple() - } -} // end 0xc0ffee::no_warn - - -// -- Model dump after env processor specification rewriter: -module 0xc0ffee::m { - private fun apply(f: |u8|bool,x: u8): bool { - (f)(x) - } - private fun bar() { - Tuple() - } - private fun foo(x: T): T { - x - } - public fun test1(x: u8) { - if Gt(Add(x, 1), 255) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test2(x: &u8,y: &u8) { - if Eq(Gt(Add(Deref(x), Deref(y)), 255), true) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test3(x: u8) { - if Or(Lt(x, 0), Gt(0, x)) { - m::bar() - } else { - Tuple() - }; - if Le(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Ge(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - if Gt(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Lt(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - if Ge(m::foo(x), 0) { - m::bar() - } else { - Tuple() - }; - if Le(0, m::foo(x)) { - m::bar() - } else { - Tuple() - }; - Tuple() - } - public fun test4(a: u8,b: u16,c: u32,d: u64,e: u128,f: u256) { - if Or(Gt(a, 255), Gt(f, 255)) { - m::bar() - } else { - Tuple() - }; - if Ge(b, 65535) { - m::bar() - } else { - Tuple() - }; - if Lt(4294967295, c) { - m::bar() - } else { - Tuple() - }; - if Le(18446744073709551615, d) { - m::bar() - } else { - Tuple() - }; - if Lt(e, 340282366920938463463374607431768211455) { - m::bar() - } else { - Tuple() - }; - if Le(f, 115792089237316195423570985008687907853269984665640564039457584007913129639935) { - m::bar() - } else { - Tuple() - }; - if Ge(115792089237316195423570985008687907853269984665640564039457584007913129639935, f) { - m::bar() - } else { - Tuple() - }; - if Gt(340282366920938463463374607431768211455, e) { - m::bar() - } else { - Tuple() - }; - spec { - assert Le($t0, 255); - } - - } - public fun test5(x: u8): bool { - m::apply(closure m::test5$lambda$1(), x) - } - private fun test5$lambda$1(x: u8): bool { - Gt(x, 255) - } -} // end 0xc0ffee::m -module 0xc0ffee::no_warn { - public fun test(x: u8) { - if Lt(x, 0) { - Abort(1) - } else { - Tuple() - }; - Tuple() - } -} // end 0xc0ffee::no_warn - - Diagnostics: -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda/inline-parity/unnecessary_numerical_extreme_comparisons_warn.move:50:9 - │ -50 │ f(x) - │ ^ - -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/unnecessary_numerical_extreme_comparisons_warn.move:54:15 │ 54 │ apply(|x| x > U8_MAX, x) diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/unpack_generic_struct.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/unpack_generic_struct.lambda.exp index 2bdecc21d6698..88b8fd7975260 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/unpack_generic_struct.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/unpack_generic_struct.lambda.exp @@ -1,680 +1,6 @@ -// -- Model dump before env processor pipeline: -module 0x42::m { - use std::vector; - struct E { - key: Key, - } - struct Option { - vec: vector, - } - public fun destroy_none(t: Option) { - if m::is_none(Borrow(Immutable)(t)) { - Tuple() - } else { - Abort(262144) - }; - { - let m::Option{ vec } = t; - vector::destroy_empty(vec) - } - } - public fun foo(data: E,v: &mut Key) { - { - let f: E = m::h(data, |e: Key| pack m::E(e)); - m::g(f, |e: E| { - let (m::E{ key }, _x: u64): (E, u64) = Tuple(e, 3); - v = key; - Tuple() - }); - Tuple() - } - } - public fun g(x: E,v: |E|) { - (v)(x) - } - public fun h(x: E,v: |Key|E): E { - { - let m::E{ key } = x; - (v)(key) - } - } - public fun is_none(t: &Option): bool { - vector::is_empty(Borrow(Immutable)(select m::Option.vec<&Option>(t))) - } -} // end 0x42::m - - -// -- Model dump after env processor unused checks: -module 0x42::m { - use std::vector; - struct E { - key: Key, - } - struct Option { - vec: vector, - } - public fun destroy_none(t: Option) { - if m::is_none(Borrow(Immutable)(t)) { - Tuple() - } else { - Abort(262144) - }; - { - let m::Option{ vec } = t; - vector::destroy_empty(vec) - } - } - public fun foo(data: E,v: &mut Key) { - { - let f: E = m::h(data, |e: Key| pack m::E(e)); - m::g(f, |e: E| { - let (m::E{ key }, _x: u64): (E, u64) = Tuple(e, 3); - v = key; - Tuple() - }); - Tuple() - } - } - public fun g(x: E,v: |E|) { - (v)(x) - } - public fun h(x: E,v: |Key|E): E { - { - let m::E{ key } = x; - (v)(key) - } - } - public fun is_none(t: &Option): bool { - vector::is_empty(Borrow(Immutable)(select m::Option.vec<&Option>(t))) - } -} // end 0x42::m - - -// -- Model dump after env processor type parameter check: -module 0x42::m { - use std::vector; - struct E { - key: Key, - } - struct Option { - vec: vector, - } - public fun destroy_none(t: Option) { - if m::is_none(Borrow(Immutable)(t)) { - Tuple() - } else { - Abort(262144) - }; - { - let m::Option{ vec } = t; - vector::destroy_empty(vec) - } - } - public fun foo(data: E,v: &mut Key) { - { - let f: E = m::h(data, |e: Key| pack m::E(e)); - m::g(f, |e: E| { - let (m::E{ key }, _x: u64): (E, u64) = Tuple(e, 3); - v = key; - Tuple() - }); - Tuple() - } - } - public fun g(x: E,v: |E|) { - (v)(x) - } - public fun h(x: E,v: |Key|E): E { - { - let m::E{ key } = x; - (v)(key) - } - } - public fun is_none(t: &Option): bool { - vector::is_empty(Borrow(Immutable)(select m::Option.vec<&Option>(t))) - } -} // end 0x42::m - - -// -- Model dump after env processor check recursive struct definition: -module 0x42::m { - use std::vector; - struct E { - key: Key, - } - struct Option { - vec: vector, - } - public fun destroy_none(t: Option) { - if m::is_none(Borrow(Immutable)(t)) { - Tuple() - } else { - Abort(262144) - }; - { - let m::Option{ vec } = t; - vector::destroy_empty(vec) - } - } - public fun foo(data: E,v: &mut Key) { - { - let f: E = m::h(data, |e: Key| pack m::E(e)); - m::g(f, |e: E| { - let (m::E{ key }, _x: u64): (E, u64) = Tuple(e, 3); - v = key; - Tuple() - }); - Tuple() - } - } - public fun g(x: E,v: |E|) { - (v)(x) - } - public fun h(x: E,v: |Key|E): E { - { - let m::E{ key } = x; - (v)(key) - } - } - public fun is_none(t: &Option): bool { - vector::is_empty(Borrow(Immutable)(select m::Option.vec<&Option>(t))) - } -} // end 0x42::m - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x42::m { - use std::vector; - struct E { - key: Key, - } - struct Option { - vec: vector, - } - public fun destroy_none(t: Option) { - if m::is_none(Borrow(Immutable)(t)) { - Tuple() - } else { - Abort(262144) - }; - { - let m::Option{ vec } = t; - vector::destroy_empty(vec) - } - } - public fun foo(data: E,v: &mut Key) { - { - let f: E = m::h(data, |e: Key| pack m::E(e)); - m::g(f, |e: E| { - let (m::E{ key }, _x: u64): (E, u64) = Tuple(e, 3); - v = key; - Tuple() - }); - Tuple() - } - } - public fun g(x: E,v: |E|) { - (v)(x) - } - public fun h(x: E,v: |Key|E): E { - { - let m::E{ key } = x; - (v)(key) - } - } - public fun is_none(t: &Option): bool { - vector::is_empty(Borrow(Immutable)(select m::Option.vec<&Option>(t))) - } -} // end 0x42::m - - -// -- Model dump after env processor unused struct params check: -module 0x42::m { - use std::vector; - struct E { - key: Key, - } - struct Option { - vec: vector, - } - public fun destroy_none(t: Option) { - if m::is_none(Borrow(Immutable)(t)) { - Tuple() - } else { - Abort(262144) - }; - { - let m::Option{ vec } = t; - vector::destroy_empty(vec) - } - } - public fun foo(data: E,v: &mut Key) { - { - let f: E = m::h(data, |e: Key| pack m::E(e)); - m::g(f, |e: E| { - let (m::E{ key }, _x: u64): (E, u64) = Tuple(e, 3); - v = key; - Tuple() - }); - Tuple() - } - } - public fun g(x: E,v: |E|) { - (v)(x) - } - public fun h(x: E,v: |Key|E): E { - { - let m::E{ key } = x; - (v)(key) - } - } - public fun is_none(t: &Option): bool { - vector::is_empty(Borrow(Immutable)(select m::Option.vec<&Option>(t))) - } -} // end 0x42::m - - -// -- Model dump after env processor access and use check before inlining: -module 0x42::m { - use std::vector; - struct E { - key: Key, - } - struct Option { - vec: vector, - } - public fun destroy_none(t: Option) { - if m::is_none(Borrow(Immutable)(t)) { - Tuple() - } else { - Abort(262144) - }; - { - let m::Option{ vec } = t; - vector::destroy_empty(vec) - } - } - public fun foo(data: E,v: &mut Key) { - { - let f: E = m::h(data, |e: Key| pack m::E(e)); - m::g(f, |e: E| { - let (m::E{ key }, _x: u64): (E, u64) = Tuple(e, 3); - v = key; - Tuple() - }); - Tuple() - } - } - public fun g(x: E,v: |E|) { - (v)(x) - } - public fun h(x: E,v: |Key|E): E { - { - let m::E{ key } = x; - (v)(key) - } - } - public fun is_none(t: &Option): bool { - vector::is_empty(Borrow(Immutable)(select m::Option.vec<&Option>(t))) - } -} // end 0x42::m - - -// -- Model dump after env processor inlining: -module 0x42::m { - use std::vector; - struct E { - key: Key, - } - struct Option { - vec: vector, - } - public fun destroy_none(t: Option) { - if m::is_none(Borrow(Immutable)(t)) { - Tuple() - } else { - Abort(262144) - }; - { - let m::Option{ vec } = t; - vector::destroy_empty(vec) - } - } - public fun foo(data: E,v: &mut Key) { - { - let f: E = m::h(data, |e: Key| pack m::E(e)); - m::g(f, |e: E| { - let (m::E{ key }, _x: u64): (E, u64) = Tuple(e, 3); - v = key; - Tuple() - }); - Tuple() - } - } - public fun g(x: E,v: |E|) { - (v)(x) - } - public fun h(x: E,v: |Key|E): E { - { - let m::E{ key } = x; - (v)(key) - } - } - public fun is_none(t: &Option): bool { - vector::is_empty(Borrow(Immutable)(select m::Option.vec<&Option>(t))) - } -} // end 0x42::m - - -// -- Model dump after env processor access and use check after inlining: -module 0x42::m { - use std::vector; - struct E { - key: Key, - } - struct Option { - vec: vector, - } - public fun destroy_none(t: Option) { - if m::is_none(Borrow(Immutable)(t)) { - Tuple() - } else { - Abort(262144) - }; - { - let m::Option{ vec } = t; - vector::destroy_empty(vec) - } - } - public fun foo(data: E,v: &mut Key) { - { - let f: E = m::h(data, |e: Key| pack m::E(e)); - m::g(f, |e: E| { - let (m::E{ key }, _x: u64): (E, u64) = Tuple(e, 3); - v = key; - Tuple() - }); - Tuple() - } - } - public fun g(x: E,v: |E|) { - (v)(x) - } - public fun h(x: E,v: |Key|E): E { - { - let m::E{ key } = x; - (v)(key) - } - } - public fun is_none(t: &Option): bool { - vector::is_empty(Borrow(Immutable)(select m::Option.vec<&Option>(t))) - } -} // end 0x42::m - - -// -- Model dump after env processor acquires check: -module 0x42::m { - use std::vector; - struct E { - key: Key, - } - struct Option { - vec: vector, - } - public fun destroy_none(t: Option) { - if m::is_none(Borrow(Immutable)(t)) { - Tuple() - } else { - Abort(262144) - }; - { - let m::Option{ vec } = t; - vector::destroy_empty(vec) - } - } - public fun foo(data: E,v: &mut Key) { - { - let f: E = m::h(data, |e: Key| pack m::E(e)); - m::g(f, |e: E| { - let (m::E{ key }, _x: u64): (E, u64) = Tuple(e, 3); - v = key; - Tuple() - }); - Tuple() - } - } - public fun g(x: E,v: |E|) { - (v)(x) - } - public fun h(x: E,v: |Key|E): E { - { - let m::E{ key } = x; - (v)(key) - } - } - public fun is_none(t: &Option): bool { - vector::is_empty(Borrow(Immutable)(select m::Option.vec<&Option>(t))) - } -} // end 0x42::m - - -// -- Model dump after env processor simplifier: -module 0x42::m { - use std::vector; - struct E { - key: Key, - } - struct Option { - vec: vector, - } - public fun destroy_none(t: Option) { - if m::is_none(Borrow(Immutable)(t)) { - Tuple() - } else { - Abort(262144) - }; - { - let m::Option{ vec } = t; - vector::destroy_empty(vec) - } - } - public fun foo(data: E,v: &mut Key) { - { - let f: E = m::h(data, |e: Key| pack m::E(e)); - m::g(f, |e: E| { - let (m::E{ key }, _x: u64): (E, u64) = Tuple(e, 3); - v = key; - Tuple() - }); - Tuple() - } - } - public fun g(x: E,v: |E|) { - (v)(x) - } - public fun h(x: E,v: |Key|E): E { - { - let m::E{ key } = x; - (v)(key) - } - } - public fun is_none(t: &Option): bool { - vector::is_empty(Borrow(Immutable)(select m::Option.vec<&Option>(t))) - } -} // end 0x42::m - - -// -- Model dump after env processor lambda-lifting: -module 0x42::m { - use std::vector; - struct E { - key: Key, - } - struct Option { - vec: vector, - } - public fun destroy_none(t: Option) { - if m::is_none(Borrow(Immutable)(t)) { - Tuple() - } else { - Abort(262144) - }; - { - let m::Option{ vec } = t; - vector::destroy_empty(vec) - } - } - public fun foo(data: E,v: &mut Key) { - { - let f: E = m::h(data, closure m::foo$lambda$1()); - m::g(f, closure m::foo$lambda$2(v)); - Tuple() - } - } - public fun g(x: E,v: |E|) { - (v)(x) - } - public fun h(x: E,v: |Key|E): E { - { - let m::E{ key } = x; - (v)(key) - } - } - public fun is_none(t: &Option): bool { - vector::is_empty(Borrow(Immutable)(select m::Option.vec<&Option>(t))) - } - private fun foo$lambda$1(e: Key): E { - pack m::E(e) - } - private fun foo$lambda$2(v: &mut Key,e: E) { - { - let (m::E{ key }, _x: u64): (E, u64) = Tuple(e, 3); - v = key; - Tuple() - } - } -} // end 0x42::m - - -// -- Model dump after env processor specification checker: -module 0x42::m { - use std::vector; - struct E { - key: Key, - } - struct Option { - vec: vector, - } - public fun destroy_none(t: Option) { - if m::is_none(Borrow(Immutable)(t)) { - Tuple() - } else { - Abort(262144) - }; - { - let m::Option{ vec } = t; - vector::destroy_empty(vec) - } - } - public fun foo(data: E,v: &mut Key) { - { - let f: E = m::h(data, closure m::foo$lambda$1()); - m::g(f, closure m::foo$lambda$2(v)); - Tuple() - } - } - public fun g(x: E,v: |E|) { - (v)(x) - } - public fun h(x: E,v: |Key|E): E { - { - let m::E{ key } = x; - (v)(key) - } - } - public fun is_none(t: &Option): bool { - vector::is_empty(Borrow(Immutable)(select m::Option.vec<&Option>(t))) - } - private fun foo$lambda$1(e: Key): E { - pack m::E(e) - } - private fun foo$lambda$2(v: &mut Key,e: E) { - { - let (m::E{ key }, _x: u64): (E, u64) = Tuple(e, 3); - v = key; - Tuple() - } - } -} // end 0x42::m - - -// -- Model dump after env processor specification rewriter: -module 0x42::m { - use std::vector; - struct E { - key: Key, - } - struct Option { - vec: vector, - } - public fun destroy_none(t: Option) { - if m::is_none(Borrow(Immutable)(t)) { - Tuple() - } else { - Abort(262144) - }; - { - let m::Option{ vec } = t; - vector::destroy_empty(vec) - } - } - public fun foo(data: E,v: &mut Key) { - { - let f: E = m::h(data, closure m::foo$lambda$1()); - m::g(f, closure m::foo$lambda$2(v)); - Tuple() - } - } - public fun g(x: E,v: |E|) { - (v)(x) - } - public fun h(x: E,v: |Key|E): E { - { - let m::E{ key } = x; - (v)(key) - } - } - public fun is_none(t: &Option): bool { - vector::is_empty(Borrow(Immutable)(select m::Option.vec<&Option>(t))) - } - private fun foo$lambda$1(e: Key): E { - pack m::E(e) - } - private fun foo$lambda$2(v: &mut Key,e: E) { - { - let (m::E{ key }, _x: u64): (E, u64) = Tuple(e, 3); - v = key; - Tuple() - } - } -} // end 0x42::m - - Diagnostics: -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda/inline-parity/unpack_generic_struct.move:24:9 - │ -24 │ v(key) - │ ^ - -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda/inline-parity/unpack_generic_struct.move:28:9 - │ -28 │ v(x) - │ ^ - -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/unpack_generic_struct.move:33:25 │ 33 │ let f = h(data, |e| { @@ -683,7 +9,7 @@ error: Function-typed values not yet supported except as parameters to calls to 35 │ │ }); │ ╰─────────^ -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/unpack_generic_struct.move:36:14 │ 36 │ g(f, |e| { diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/unused_lambda_param.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/unused_lambda_param.lambda.exp index a720df7124c63..8b3b95192ac54 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/unused_lambda_param.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/unused_lambda_param.lambda.exp @@ -1,319 +1,3 @@ -// -- Model dump before env processor pipeline: -module 0xc0ffee::m { - private fun test(p: u64,f: |u64|u64): u64 { - (f)(p) - } - private fun unused_lambda() { - m::test(0, |x: u64| 1); - Tuple() - } - private fun unused_lambda_suppressed1() { - m::test(0, |_x: u64| 1); - Tuple() - } - private fun unused_lambda_suppressed2() { - m::test(0, |_: u64| 1); - Tuple() - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor unused checks: -module 0xc0ffee::m { - private fun test(p: u64,f: |u64|u64): u64 { - (f)(p) - } - private fun unused_lambda() { - m::test(0, |x: u64| 1); - Tuple() - } - private fun unused_lambda_suppressed1() { - m::test(0, |_x: u64| 1); - Tuple() - } - private fun unused_lambda_suppressed2() { - m::test(0, |_: u64| 1); - Tuple() - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor type parameter check: -module 0xc0ffee::m { - private fun test(p: u64,f: |u64|u64): u64 { - (f)(p) - } - private fun unused_lambda() { - m::test(0, |x: u64| 1); - Tuple() - } - private fun unused_lambda_suppressed1() { - m::test(0, |_x: u64| 1); - Tuple() - } - private fun unused_lambda_suppressed2() { - m::test(0, |_: u64| 1); - Tuple() - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor check recursive struct definition: -module 0xc0ffee::m { - private fun test(p: u64,f: |u64|u64): u64 { - (f)(p) - } - private fun unused_lambda() { - m::test(0, |x: u64| 1); - Tuple() - } - private fun unused_lambda_suppressed1() { - m::test(0, |_x: u64| 1); - Tuple() - } - private fun unused_lambda_suppressed2() { - m::test(0, |_: u64| 1); - Tuple() - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor check cyclic type instantiation: -module 0xc0ffee::m { - private fun test(p: u64,f: |u64|u64): u64 { - (f)(p) - } - private fun unused_lambda() { - m::test(0, |x: u64| 1); - Tuple() - } - private fun unused_lambda_suppressed1() { - m::test(0, |_x: u64| 1); - Tuple() - } - private fun unused_lambda_suppressed2() { - m::test(0, |_: u64| 1); - Tuple() - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor unused struct params check: -module 0xc0ffee::m { - private fun test(p: u64,f: |u64|u64): u64 { - (f)(p) - } - private fun unused_lambda() { - m::test(0, |x: u64| 1); - Tuple() - } - private fun unused_lambda_suppressed1() { - m::test(0, |_x: u64| 1); - Tuple() - } - private fun unused_lambda_suppressed2() { - m::test(0, |_: u64| 1); - Tuple() - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor access and use check before inlining: -module 0xc0ffee::m { - private fun test(p: u64,f: |u64|u64): u64 { - (f)(p) - } - private fun unused_lambda() { - m::test(0, |x: u64| 1); - Tuple() - } - private fun unused_lambda_suppressed1() { - m::test(0, |_x: u64| 1); - Tuple() - } - private fun unused_lambda_suppressed2() { - m::test(0, |_: u64| 1); - Tuple() - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor inlining: -module 0xc0ffee::m { - private fun test(p: u64,f: |u64|u64): u64 { - (f)(p) - } - private fun unused_lambda() { - m::test(0, |x: u64| 1); - Tuple() - } - private fun unused_lambda_suppressed1() { - m::test(0, |_x: u64| 1); - Tuple() - } - private fun unused_lambda_suppressed2() { - m::test(0, |_: u64| 1); - Tuple() - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor access and use check after inlining: -module 0xc0ffee::m { - private fun test(p: u64,f: |u64|u64): u64 { - (f)(p) - } - private fun unused_lambda() { - m::test(0, |x: u64| 1); - Tuple() - } - private fun unused_lambda_suppressed1() { - m::test(0, |_x: u64| 1); - Tuple() - } - private fun unused_lambda_suppressed2() { - m::test(0, |_: u64| 1); - Tuple() - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor acquires check: -module 0xc0ffee::m { - private fun test(p: u64,f: |u64|u64): u64 { - (f)(p) - } - private fun unused_lambda() { - m::test(0, |x: u64| 1); - Tuple() - } - private fun unused_lambda_suppressed1() { - m::test(0, |_x: u64| 1); - Tuple() - } - private fun unused_lambda_suppressed2() { - m::test(0, |_: u64| 1); - Tuple() - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor simplifier: -module 0xc0ffee::m { - private fun test(p: u64,f: |u64|u64): u64 { - (f)(p) - } - private fun unused_lambda() { - m::test(0, |x: u64| 1); - Tuple() - } - private fun unused_lambda_suppressed1() { - m::test(0, |_x: u64| 1); - Tuple() - } - private fun unused_lambda_suppressed2() { - m::test(0, |_: u64| 1); - Tuple() - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor lambda-lifting: -module 0xc0ffee::m { - private fun test(p: u64,f: |u64|u64): u64 { - (f)(p) - } - private fun unused_lambda() { - m::test(0, closure m::unused_lambda$lambda$1()); - Tuple() - } - private fun unused_lambda_suppressed1() { - m::test(0, closure m::unused_lambda_suppressed1$lambda$1()); - Tuple() - } - private fun unused_lambda_suppressed2() { - m::test(0, closure m::unused_lambda_suppressed2$lambda$1()); - Tuple() - } - private fun unused_lambda$lambda$1(x: u64): u64 { - 1 - } - private fun unused_lambda_suppressed1$lambda$1(_x: u64): u64 { - 1 - } - private fun unused_lambda_suppressed2$lambda$1(param$0: u64): u64 { - { - let _: u64 = param$0; - 1 - } - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor specification checker: -module 0xc0ffee::m { - private fun test(p: u64,f: |u64|u64): u64 { - (f)(p) - } - private fun unused_lambda() { - m::test(0, closure m::unused_lambda$lambda$1()); - Tuple() - } - private fun unused_lambda_suppressed1() { - m::test(0, closure m::unused_lambda_suppressed1$lambda$1()); - Tuple() - } - private fun unused_lambda_suppressed2() { - m::test(0, closure m::unused_lambda_suppressed2$lambda$1()); - Tuple() - } - private fun unused_lambda$lambda$1(x: u64): u64 { - 1 - } - private fun unused_lambda_suppressed1$lambda$1(_x: u64): u64 { - 1 - } - private fun unused_lambda_suppressed2$lambda$1(param$0: u64): u64 { - { - let _: u64 = param$0; - 1 - } - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor specification rewriter: -module 0xc0ffee::m { - private fun test(p: u64,f: |u64|u64): u64 { - (f)(p) - } - private fun unused_lambda() { - m::test(0, closure m::unused_lambda$lambda$1()); - Tuple() - } - private fun unused_lambda_suppressed1() { - m::test(0, closure m::unused_lambda_suppressed1$lambda$1()); - Tuple() - } - private fun unused_lambda_suppressed2() { - m::test(0, closure m::unused_lambda_suppressed2$lambda$1()); - Tuple() - } - private fun unused_lambda$lambda$1(x: u64): u64 { - 1 - } - private fun unused_lambda_suppressed1$lambda$1(_x: u64): u64 { - 1 - } - private fun unused_lambda_suppressed2$lambda$1(param$0: u64): u64 { - { - let _: u64 = param$0; - 1 - } - } -} // end 0xc0ffee::m - - Diagnostics: warning: Unused anonymous function parameter `x`. Consider removing or prefixing with an underscore: `_x` @@ -322,27 +6,19 @@ warning: Unused anonymous function parameter `x`. Consider removing or prefixing 7 │ test(0, |x| 1); │ ^ - -Diagnostics: -error: Calls to function values other than inline function parameters not yet supported - ┌─ tests/lambda/inline-parity/unused_lambda_param.move:3:9 - │ -3 │ f(p) - │ ^ - -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/unused_lambda_param.move:7:17 │ 7 │ test(0, |x| 1); │ ^^^^^ -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/unused_lambda_param.move:11:17 │ 11 │ test(0, |_x| 1); │ ^^^^^^ -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/inline-parity/unused_lambda_param.move:15:17 │ 15 │ test(0, |_| 1); diff --git a/third_party/move/move-compiler-v2/tests/lambda/lambda3.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/lambda3.lambda.exp index db9ce1b64dc58..927c4b68424f8 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/lambda3.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/lambda3.lambda.exp @@ -1,169 +1,6 @@ -// -- Model dump before env processor pipeline: -module 0x8675309::M { - public fun lambda_not_allowed() { - { - let _x: |u64|u64 = |i: u64| Add(i, 1); - Tuple() - } - } -} // end 0x8675309::M - - -// -- Model dump after env processor unused checks: -module 0x8675309::M { - public fun lambda_not_allowed() { - { - let _x: |u64|u64 = |i: u64| Add(i, 1); - Tuple() - } - } -} // end 0x8675309::M - - -// -- Model dump after env processor type parameter check: -module 0x8675309::M { - public fun lambda_not_allowed() { - { - let _x: |u64|u64 = |i: u64| Add(i, 1); - Tuple() - } - } -} // end 0x8675309::M - - -// -- Model dump after env processor check recursive struct definition: -module 0x8675309::M { - public fun lambda_not_allowed() { - { - let _x: |u64|u64 = |i: u64| Add(i, 1); - Tuple() - } - } -} // end 0x8675309::M - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x8675309::M { - public fun lambda_not_allowed() { - { - let _x: |u64|u64 = |i: u64| Add(i, 1); - Tuple() - } - } -} // end 0x8675309::M - - -// -- Model dump after env processor unused struct params check: -module 0x8675309::M { - public fun lambda_not_allowed() { - { - let _x: |u64|u64 = |i: u64| Add(i, 1); - Tuple() - } - } -} // end 0x8675309::M - - -// -- Model dump after env processor access and use check before inlining: -module 0x8675309::M { - public fun lambda_not_allowed() { - { - let _x: |u64|u64 = |i: u64| Add(i, 1); - Tuple() - } - } -} // end 0x8675309::M - - -// -- Model dump after env processor inlining: -module 0x8675309::M { - public fun lambda_not_allowed() { - { - let _x: |u64|u64 = |i: u64| Add(i, 1); - Tuple() - } - } -} // end 0x8675309::M - - -// -- Model dump after env processor access and use check after inlining: -module 0x8675309::M { - public fun lambda_not_allowed() { - { - let _x: |u64|u64 = |i: u64| Add(i, 1); - Tuple() - } - } -} // end 0x8675309::M - - -// -- Model dump after env processor acquires check: -module 0x8675309::M { - public fun lambda_not_allowed() { - { - let _x: |u64|u64 = |i: u64| Add(i, 1); - Tuple() - } - } -} // end 0x8675309::M - - -// -- Model dump after env processor simplifier: -module 0x8675309::M { - public fun lambda_not_allowed() { - { - let _x: |u64|u64 = |i: u64| Add(i, 1); - Tuple() - } - } -} // end 0x8675309::M - - -// -- Model dump after env processor lambda-lifting: -module 0x8675309::M { - public fun lambda_not_allowed() { - { - let _x: |u64|u64 = closure M::lambda_not_allowed$lambda$1(); - Tuple() - } - } - private fun lambda_not_allowed$lambda$1(i: u64): u64 { - Add(i, 1) - } -} // end 0x8675309::M - - -// -- Model dump after env processor specification checker: -module 0x8675309::M { - public fun lambda_not_allowed() { - { - let _x: |u64|u64 = closure M::lambda_not_allowed$lambda$1(); - Tuple() - } - } - private fun lambda_not_allowed$lambda$1(i: u64): u64 { - Add(i, 1) - } -} // end 0x8675309::M - - -// -- Model dump after env processor specification rewriter: -module 0x8675309::M { - public fun lambda_not_allowed() { - { - let _x: |u64|u64 = closure M::lambda_not_allowed$lambda$1(); - Tuple() - } - } - private fun lambda_not_allowed$lambda$1(i: u64): u64 { - Add(i, 1) - } -} // end 0x8675309::M - - Diagnostics: -error: Function-typed values not yet supported except as parameters to calls to inline functions +error: Currently, lambda expressions must explicitly declare `move` capture of free variables, except when appearing as an argument to an inline functioncall. ┌─ tests/lambda/lambda3.move:77:18 │ 77 │ let _x = |i| i + 1; // expected lambda not allowed diff --git a/third_party/move/move-compiler-v2/tests/lambda/lambda4.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/lambda4.lambda.exp index f374630d851fb..731dfa95c77e7 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/lambda4.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/lambda4.lambda.exp @@ -1,4 +1,4 @@ -// -- Model dump before env processor pipeline: +// -- Model dump before bytecode pipeline module 0x8675309::M { public fun fun_result_lambda_not_allowed(): |u64| { Abort(1) @@ -8,149 +8,15 @@ module 0x8675309::M { } } // end 0x8675309::M - -// -- Model dump after env processor unused checks: -module 0x8675309::M { - public fun fun_result_lambda_not_allowed(): |u64| { - Abort(1) - } - public inline fun macro_result_lambda_not_allowed(): |u64| { - Abort(1) - } -} // end 0x8675309::M - - -// -- Model dump after env processor type parameter check: -module 0x8675309::M { - public fun fun_result_lambda_not_allowed(): |u64| { - Abort(1) - } - public inline fun macro_result_lambda_not_allowed(): |u64| { - Abort(1) - } -} // end 0x8675309::M - - -// -- Model dump after env processor check recursive struct definition: -module 0x8675309::M { - public fun fun_result_lambda_not_allowed(): |u64| { - Abort(1) - } - public inline fun macro_result_lambda_not_allowed(): |u64| { - Abort(1) - } -} // end 0x8675309::M - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x8675309::M { - public fun fun_result_lambda_not_allowed(): |u64| { - Abort(1) - } - public inline fun macro_result_lambda_not_allowed(): |u64| { - Abort(1) - } -} // end 0x8675309::M - - -// -- Model dump after env processor unused struct params check: -module 0x8675309::M { - public fun fun_result_lambda_not_allowed(): |u64| { - Abort(1) - } - public inline fun macro_result_lambda_not_allowed(): |u64| { - Abort(1) - } -} // end 0x8675309::M - - -// -- Model dump after env processor access and use check before inlining: -module 0x8675309::M { - public fun fun_result_lambda_not_allowed(): |u64| { - Abort(1) - } - public inline fun macro_result_lambda_not_allowed(): |u64| { - Abort(1) - } -} // end 0x8675309::M - - -// -- Model dump after env processor inlining: -module 0x8675309::M { - public fun fun_result_lambda_not_allowed(): |u64| { - Abort(1) - } - public inline fun macro_result_lambda_not_allowed(): |u64| { - Abort(1) - } -} // end 0x8675309::M - - -// -- Model dump after env processor access and use check after inlining: -module 0x8675309::M { - public fun fun_result_lambda_not_allowed(): |u64| { - Abort(1) - } - public inline fun macro_result_lambda_not_allowed(): |u64| { - Abort(1) - } -} // end 0x8675309::M - - -// -- Model dump after env processor acquires check: -module 0x8675309::M { - public fun fun_result_lambda_not_allowed(): |u64| { - Abort(1) - } - public inline fun macro_result_lambda_not_allowed(): |u64| { - Abort(1) - } -} // end 0x8675309::M - - -// -- Model dump after env processor simplifier: +// -- Sourcified model before bytecode pipeline module 0x8675309::M { public fun fun_result_lambda_not_allowed(): |u64| { - Abort(1) + abort 1 } public inline fun macro_result_lambda_not_allowed(): |u64| { - Abort(1) + abort 1 } -} // end 0x8675309::M - - -// -- Model dump after env processor lambda-lifting: -module 0x8675309::M { - public fun fun_result_lambda_not_allowed(): |u64| { - Abort(1) - } - public inline fun macro_result_lambda_not_allowed(): |u64| { - Abort(1) - } -} // end 0x8675309::M - - -// -- Model dump after env processor specification checker: -module 0x8675309::M { - public fun fun_result_lambda_not_allowed(): |u64| { - Abort(1) - } - public inline fun macro_result_lambda_not_allowed(): |u64| { - Abort(1) - } -} // end 0x8675309::M - - -// -- Model dump after env processor specification rewriter: -module 0x8675309::M { - public fun fun_result_lambda_not_allowed(): |u64| { - Abort(1) - } - public inline fun macro_result_lambda_not_allowed(): |u64| { - Abort(1) - } -} // end 0x8675309::M - +} ============ initial bytecode ================ diff --git a/third_party/move/move-compiler-v2/tests/lambda/lambda5.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/lambda5.lambda.exp index e1b739ddf2748..62093be8b9262 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/lambda5.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/lambda5.lambda.exp @@ -1,114 +1,16 @@ -// -- Model dump before env processor pipeline: +// -- Model dump before bytecode pipeline module 0x8675309::M { public inline fun macro_result_lambda_not_allowed(): |u64| { Abort(1) } } // end 0x8675309::M - -// -- Model dump after env processor unused checks: -module 0x8675309::M { - public inline fun macro_result_lambda_not_allowed(): |u64| { - Abort(1) - } -} // end 0x8675309::M - - -// -- Model dump after env processor type parameter check: +// -- Sourcified model before bytecode pipeline module 0x8675309::M { public inline fun macro_result_lambda_not_allowed(): |u64| { - Abort(1) - } -} // end 0x8675309::M - - -// -- Model dump after env processor check recursive struct definition: -module 0x8675309::M { - public inline fun macro_result_lambda_not_allowed(): |u64| { - Abort(1) - } -} // end 0x8675309::M - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x8675309::M { - public inline fun macro_result_lambda_not_allowed(): |u64| { - Abort(1) + abort 1 } -} // end 0x8675309::M - - -// -- Model dump after env processor unused struct params check: -module 0x8675309::M { - public inline fun macro_result_lambda_not_allowed(): |u64| { - Abort(1) - } -} // end 0x8675309::M - - -// -- Model dump after env processor access and use check before inlining: -module 0x8675309::M { - public inline fun macro_result_lambda_not_allowed(): |u64| { - Abort(1) - } -} // end 0x8675309::M - - -// -- Model dump after env processor inlining: -module 0x8675309::M { - public inline fun macro_result_lambda_not_allowed(): |u64| { - Abort(1) - } -} // end 0x8675309::M - - -// -- Model dump after env processor access and use check after inlining: -module 0x8675309::M { - public inline fun macro_result_lambda_not_allowed(): |u64| { - Abort(1) - } -} // end 0x8675309::M - - -// -- Model dump after env processor acquires check: -module 0x8675309::M { - public inline fun macro_result_lambda_not_allowed(): |u64| { - Abort(1) - } -} // end 0x8675309::M - - -// -- Model dump after env processor simplifier: -module 0x8675309::M { - public inline fun macro_result_lambda_not_allowed(): |u64| { - Abort(1) - } -} // end 0x8675309::M - - -// -- Model dump after env processor lambda-lifting: -module 0x8675309::M { - public inline fun macro_result_lambda_not_allowed(): |u64| { - Abort(1) - } -} // end 0x8675309::M - - -// -- Model dump after env processor specification checker: -module 0x8675309::M { - public inline fun macro_result_lambda_not_allowed(): |u64| { - Abort(1) - } -} // end 0x8675309::M - - -// -- Model dump after env processor specification rewriter: -module 0x8675309::M { - public inline fun macro_result_lambda_not_allowed(): |u64| { - Abort(1) - } -} // end 0x8675309::M - +} ============ initial bytecode ================ ============ after LiveVarAnalysisProcessor: ================ diff --git a/third_party/move/move-compiler-v2/tests/lambda/non_lambda_arg.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/non_lambda_arg.lambda.exp index 0a35235798063..28c04eb42119a 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/non_lambda_arg.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/non_lambda_arg.lambda.exp @@ -1,4 +1,4 @@ -// -- Model dump before env processor pipeline: +// -- Model dump before bytecode pipeline module 0x42::sort { use std::vector; public fun incorrect_sort(arr: &mut vector,a_less_b: |(T, T)|bool) { @@ -22,331 +22,20 @@ module 0x42::sort { } } // end 0x42::sort - -// -- Model dump after env processor unused checks: -module 0x42::sort { - use std::vector; - public fun incorrect_sort(arr: &mut vector,a_less_b: |(T, T)|bool) { - { - let n: u64 = vector::length(Freeze(false)(arr)); - sort::incorrect_sort_recursive(arr, 0, Sub(n, 1), a_less_b) - } - } - public fun incorrect_sort_recursive(arr: &mut vector,low: u64,high: u64,a_less_b: |(T, T)|bool) { - if Lt(low, high) { - { - let pi: u64 = Add(low, Div(high, 2)); - sort::incorrect_sort_recursive(arr, low, Sub(pi, 1), a_less_b); - sort::incorrect_sort_recursive(arr, Add(pi, 1), high, a_less_b); - Tuple() - } - } else { - Tuple() - }; - Tuple() - } -} // end 0x42::sort - - -// -- Model dump after env processor type parameter check: -module 0x42::sort { - use std::vector; - public fun incorrect_sort(arr: &mut vector,a_less_b: |(T, T)|bool) { - { - let n: u64 = vector::length(Freeze(false)(arr)); - sort::incorrect_sort_recursive(arr, 0, Sub(n, 1), a_less_b) - } - } - public fun incorrect_sort_recursive(arr: &mut vector,low: u64,high: u64,a_less_b: |(T, T)|bool) { - if Lt(low, high) { - { - let pi: u64 = Add(low, Div(high, 2)); - sort::incorrect_sort_recursive(arr, low, Sub(pi, 1), a_less_b); - sort::incorrect_sort_recursive(arr, Add(pi, 1), high, a_less_b); - Tuple() - } - } else { - Tuple() - }; - Tuple() - } -} // end 0x42::sort - - -// -- Model dump after env processor check recursive struct definition: -module 0x42::sort { - use std::vector; - public fun incorrect_sort(arr: &mut vector,a_less_b: |(T, T)|bool) { - { - let n: u64 = vector::length(Freeze(false)(arr)); - sort::incorrect_sort_recursive(arr, 0, Sub(n, 1), a_less_b) - } - } - public fun incorrect_sort_recursive(arr: &mut vector,low: u64,high: u64,a_less_b: |(T, T)|bool) { - if Lt(low, high) { - { - let pi: u64 = Add(low, Div(high, 2)); - sort::incorrect_sort_recursive(arr, low, Sub(pi, 1), a_less_b); - sort::incorrect_sort_recursive(arr, Add(pi, 1), high, a_less_b); - Tuple() - } - } else { - Tuple() - }; - Tuple() - } -} // end 0x42::sort - - -// -- Model dump after env processor check cyclic type instantiation: -module 0x42::sort { - use std::vector; - public fun incorrect_sort(arr: &mut vector,a_less_b: |(T, T)|bool) { - { - let n: u64 = vector::length(Freeze(false)(arr)); - sort::incorrect_sort_recursive(arr, 0, Sub(n, 1), a_less_b) - } - } - public fun incorrect_sort_recursive(arr: &mut vector,low: u64,high: u64,a_less_b: |(T, T)|bool) { - if Lt(low, high) { - { - let pi: u64 = Add(low, Div(high, 2)); - sort::incorrect_sort_recursive(arr, low, Sub(pi, 1), a_less_b); - sort::incorrect_sort_recursive(arr, Add(pi, 1), high, a_less_b); - Tuple() - } - } else { - Tuple() - }; - Tuple() - } -} // end 0x42::sort - - -// -- Model dump after env processor unused struct params check: -module 0x42::sort { - use std::vector; - public fun incorrect_sort(arr: &mut vector,a_less_b: |(T, T)|bool) { - { - let n: u64 = vector::length(Freeze(false)(arr)); - sort::incorrect_sort_recursive(arr, 0, Sub(n, 1), a_less_b) - } - } - public fun incorrect_sort_recursive(arr: &mut vector,low: u64,high: u64,a_less_b: |(T, T)|bool) { - if Lt(low, high) { - { - let pi: u64 = Add(low, Div(high, 2)); - sort::incorrect_sort_recursive(arr, low, Sub(pi, 1), a_less_b); - sort::incorrect_sort_recursive(arr, Add(pi, 1), high, a_less_b); - Tuple() - } - } else { - Tuple() - }; - Tuple() - } -} // end 0x42::sort - - -// -- Model dump after env processor access and use check before inlining: -module 0x42::sort { - use std::vector; - public fun incorrect_sort(arr: &mut vector,a_less_b: |(T, T)|bool) { - { - let n: u64 = vector::length(Freeze(false)(arr)); - sort::incorrect_sort_recursive(arr, 0, Sub(n, 1), a_less_b) - } - } - public fun incorrect_sort_recursive(arr: &mut vector,low: u64,high: u64,a_less_b: |(T, T)|bool) { - if Lt(low, high) { - { - let pi: u64 = Add(low, Div(high, 2)); - sort::incorrect_sort_recursive(arr, low, Sub(pi, 1), a_less_b); - sort::incorrect_sort_recursive(arr, Add(pi, 1), high, a_less_b); - Tuple() - } - } else { - Tuple() - }; - Tuple() - } -} // end 0x42::sort - - -// -- Model dump after env processor inlining: -module 0x42::sort { - use std::vector; - public fun incorrect_sort(arr: &mut vector,a_less_b: |(T, T)|bool) { - { - let n: u64 = vector::length(Freeze(false)(arr)); - sort::incorrect_sort_recursive(arr, 0, Sub(n, 1), a_less_b) - } - } - public fun incorrect_sort_recursive(arr: &mut vector,low: u64,high: u64,a_less_b: |(T, T)|bool) { - if Lt(low, high) { - { - let pi: u64 = Add(low, Div(high, 2)); - sort::incorrect_sort_recursive(arr, low, Sub(pi, 1), a_less_b); - sort::incorrect_sort_recursive(arr, Add(pi, 1), high, a_less_b); - Tuple() - } - } else { - Tuple() - }; - Tuple() - } -} // end 0x42::sort - - -// -- Model dump after env processor access and use check after inlining: +// -- Sourcified model before bytecode pipeline module 0x42::sort { - use std::vector; - public fun incorrect_sort(arr: &mut vector,a_less_b: |(T, T)|bool) { - { - let n: u64 = vector::length(Freeze(false)(arr)); - sort::incorrect_sort_recursive(arr, 0, Sub(n, 1), a_less_b) - } - } - public fun incorrect_sort_recursive(arr: &mut vector,low: u64,high: u64,a_less_b: |(T, T)|bool) { - if Lt(low, high) { - { - let pi: u64 = Add(low, Div(high, 2)); - sort::incorrect_sort_recursive(arr, low, Sub(pi, 1), a_less_b); - sort::incorrect_sort_recursive(arr, Add(pi, 1), high, a_less_b); - Tuple() - } - } else { - Tuple() - }; - Tuple() - } -} // end 0x42::sort - - -// -- Model dump after env processor acquires check: -module 0x42::sort { - use std::vector; - public fun incorrect_sort(arr: &mut vector,a_less_b: |(T, T)|bool) { - { - let n: u64 = vector::length(Freeze(false)(arr)); - sort::incorrect_sort_recursive(arr, 0, Sub(n, 1), a_less_b) - } - } - public fun incorrect_sort_recursive(arr: &mut vector,low: u64,high: u64,a_less_b: |(T, T)|bool) { - if Lt(low, high) { - { - let pi: u64 = Add(low, Div(high, 2)); - sort::incorrect_sort_recursive(arr, low, Sub(pi, 1), a_less_b); - sort::incorrect_sort_recursive(arr, Add(pi, 1), high, a_less_b); - Tuple() - } - } else { - Tuple() + public fun incorrect_sort(arr: &mut vector, a_less_b: |(T, T)|bool) { + let n = 0x1::vector::length(/*freeze*/arr); + incorrect_sort_recursive(arr, 0, n - 1, a_less_b) + } + public fun incorrect_sort_recursive(arr: &mut vector, low: u64, high: u64, a_less_b: |(T, T)|bool) { + if (low < high) { + let pi = low + high / 2; + incorrect_sort_recursive(arr, low, pi - 1, a_less_b); + incorrect_sort_recursive(arr, pi + 1, high, a_less_b); }; - Tuple() } -} // end 0x42::sort - - -// -- Model dump after env processor simplifier: -module 0x42::sort { - use std::vector; - public fun incorrect_sort(arr: &mut vector,a_less_b: |(T, T)|bool) { - { - let n: u64 = vector::length(Freeze(false)(arr)); - sort::incorrect_sort_recursive(arr, 0, Sub(n, 1), a_less_b) - } - } - public fun incorrect_sort_recursive(arr: &mut vector,low: u64,high: u64,a_less_b: |(T, T)|bool) { - if Lt(low, high) { - { - let pi: u64 = Add(low, Div(high, 2)); - sort::incorrect_sort_recursive(arr, low, Sub(pi, 1), a_less_b); - sort::incorrect_sort_recursive(arr, Add(pi, 1), high, a_less_b); - Tuple() - } - } else { - Tuple() - }; - Tuple() - } -} // end 0x42::sort - - -// -- Model dump after env processor lambda-lifting: -module 0x42::sort { - use std::vector; - public fun incorrect_sort(arr: &mut vector,a_less_b: |(T, T)|bool) { - { - let n: u64 = vector::length(Freeze(false)(arr)); - sort::incorrect_sort_recursive(arr, 0, Sub(n, 1), a_less_b) - } - } - public fun incorrect_sort_recursive(arr: &mut vector,low: u64,high: u64,a_less_b: |(T, T)|bool) { - if Lt(low, high) { - { - let pi: u64 = Add(low, Div(high, 2)); - sort::incorrect_sort_recursive(arr, low, Sub(pi, 1), a_less_b); - sort::incorrect_sort_recursive(arr, Add(pi, 1), high, a_less_b); - Tuple() - } - } else { - Tuple() - }; - Tuple() - } -} // end 0x42::sort - - -// -- Model dump after env processor specification checker: -module 0x42::sort { - use std::vector; - public fun incorrect_sort(arr: &mut vector,a_less_b: |(T, T)|bool) { - { - let n: u64 = vector::length(Freeze(false)(arr)); - sort::incorrect_sort_recursive(arr, 0, Sub(n, 1), a_less_b) - } - } - public fun incorrect_sort_recursive(arr: &mut vector,low: u64,high: u64,a_less_b: |(T, T)|bool) { - if Lt(low, high) { - { - let pi: u64 = Add(low, Div(high, 2)); - sort::incorrect_sort_recursive(arr, low, Sub(pi, 1), a_less_b); - sort::incorrect_sort_recursive(arr, Add(pi, 1), high, a_less_b); - Tuple() - } - } else { - Tuple() - }; - Tuple() - } -} // end 0x42::sort - - -// -- Model dump after env processor specification rewriter: -module 0x42::sort { - use std::vector; - public fun incorrect_sort(arr: &mut vector,a_less_b: |(T, T)|bool) { - { - let n: u64 = vector::length(Freeze(false)(arr)); - sort::incorrect_sort_recursive(arr, 0, Sub(n, 1), a_less_b) - } - } - public fun incorrect_sort_recursive(arr: &mut vector,low: u64,high: u64,a_less_b: |(T, T)|bool) { - if Lt(low, high) { - { - let pi: u64 = Add(low, Div(high, 2)); - sort::incorrect_sort_recursive(arr, low, Sub(pi, 1), a_less_b); - sort::incorrect_sort_recursive(arr, Add(pi, 1), high, a_less_b); - Tuple() - } - } else { - Tuple() - }; - Tuple() - } -} // end 0x42::sort - +} ============ initial bytecode ================ diff --git a/third_party/move/move-compiler-v2/tests/lambda/storable/registry.move b/third_party/move/move-compiler-v2/tests/lambda/storable/registry.move index a6fd8bfab655c..5e79dc83462da 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/storable/registry.move +++ b/third_party/move/move-compiler-v2/tests/lambda/storable/registry.move @@ -78,16 +78,20 @@ module 0x42::test { } fun multiply_by_x(x: u64): |u64|u64 has store { - curry(&multiply, x) + multiply(x..) } + fun multiply_by_x2(x: u64): |u64|u64 has store { + |y| multiply(x, y) + } #[test(a = @0x42)] test_registry1(a; signer) { - register(a, &double, 2); - register(a, &negate, 3); + register(a, double, 2); + register(a, negate, 3); register(a, multiply_by_x(4), 4); register(a, multiply_by_x(5), 5); + register(a, multiply_by_x2(6), 6); match invoke(a, 2, 10) { Some(x) => { assert!(x == 20); } @@ -105,5 +109,9 @@ module 0x42::test { Some(x) => { assert!(x == 15); } _ => assert!(false); } + match invoke(a, 6, 3) { + Some(x) => { assert!(x == 18); } + _ => assert!(false); + } } } diff --git a/third_party/move/move-compiler-v2/tests/lambda/unused_lambda_param.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/unused_lambda_param.lambda.exp index b406b29e1df3d..d3dd4067eb3dc 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/unused_lambda_param.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/unused_lambda_param.lambda.exp @@ -1,298 +1,12 @@ -// -- Model dump before env processor pipeline: -module 0xc0ffee::m { - private inline fun test(p: u64,f: |u64|u64): u64 { - (f)(p) - } - private fun unused_lambda() { - m::test(0, |x: u64| 1); - Tuple() - } - private fun unused_lambda_suppressed1() { - m::test(0, |_x: u64| 1); - Tuple() - } - private fun unused_lambda_suppressed2() { - m::test(0, |_: u64| 1); - Tuple() - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor unused checks: -module 0xc0ffee::m { - private inline fun test(p: u64,f: |u64|u64): u64 { - (f)(p) - } - private fun unused_lambda() { - m::test(0, |x: u64| 1); - Tuple() - } - private fun unused_lambda_suppressed1() { - m::test(0, |_x: u64| 1); - Tuple() - } - private fun unused_lambda_suppressed2() { - m::test(0, |_: u64| 1); - Tuple() - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor type parameter check: -module 0xc0ffee::m { - private inline fun test(p: u64,f: |u64|u64): u64 { - (f)(p) - } - private fun unused_lambda() { - m::test(0, |x: u64| 1); - Tuple() - } - private fun unused_lambda_suppressed1() { - m::test(0, |_x: u64| 1); - Tuple() - } - private fun unused_lambda_suppressed2() { - m::test(0, |_: u64| 1); - Tuple() - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor check recursive struct definition: -module 0xc0ffee::m { - private inline fun test(p: u64,f: |u64|u64): u64 { - (f)(p) - } - private fun unused_lambda() { - m::test(0, |x: u64| 1); - Tuple() - } - private fun unused_lambda_suppressed1() { - m::test(0, |_x: u64| 1); - Tuple() - } - private fun unused_lambda_suppressed2() { - m::test(0, |_: u64| 1); - Tuple() - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor check cyclic type instantiation: -module 0xc0ffee::m { - private inline fun test(p: u64,f: |u64|u64): u64 { - (f)(p) - } - private fun unused_lambda() { - m::test(0, |x: u64| 1); - Tuple() - } - private fun unused_lambda_suppressed1() { - m::test(0, |_x: u64| 1); - Tuple() - } - private fun unused_lambda_suppressed2() { - m::test(0, |_: u64| 1); - Tuple() - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor unused struct params check: -module 0xc0ffee::m { - private inline fun test(p: u64,f: |u64|u64): u64 { - (f)(p) - } - private fun unused_lambda() { - m::test(0, |x: u64| 1); - Tuple() - } - private fun unused_lambda_suppressed1() { - m::test(0, |_x: u64| 1); - Tuple() - } - private fun unused_lambda_suppressed2() { - m::test(0, |_: u64| 1); - Tuple() - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor access and use check before inlining: -module 0xc0ffee::m { - private inline fun test(p: u64,f: |u64|u64): u64 { - (f)(p) - } - private fun unused_lambda() { - m::test(0, |x: u64| 1); - Tuple() - } - private fun unused_lambda_suppressed1() { - m::test(0, |_x: u64| 1); - Tuple() - } - private fun unused_lambda_suppressed2() { - m::test(0, |_: u64| 1); - Tuple() - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor inlining: -module 0xc0ffee::m { - private inline fun test(p: u64,f: |u64|u64): u64 { - (f)(p) - } - private fun unused_lambda() { - { - let (p: u64): (u64) = Tuple(0); - { - let (x: u64): (u64) = Tuple(p); - 1 - } - }; - Tuple() - } - private fun unused_lambda_suppressed1() { - { - let (p: u64): (u64) = Tuple(0); - { - let (_x: u64): (u64) = Tuple(p); - 1 - } - }; - Tuple() - } - private fun unused_lambda_suppressed2() { - { - let (p: u64): (u64) = Tuple(0); - { - let (_: u64): (u64) = Tuple(p); - 1 - } - }; - Tuple() - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor access and use check after inlining: -module 0xc0ffee::m { - private inline fun test(p: u64,f: |u64|u64): u64 { - (f)(p) - } - private fun unused_lambda() { - { - let (p: u64): (u64) = Tuple(0); - { - let (x: u64): (u64) = Tuple(p); - 1 - } - }; - Tuple() - } - private fun unused_lambda_suppressed1() { - { - let (p: u64): (u64) = Tuple(0); - { - let (_x: u64): (u64) = Tuple(p); - 1 - } - }; - Tuple() - } - private fun unused_lambda_suppressed2() { - { - let (p: u64): (u64) = Tuple(0); - { - let (_: u64): (u64) = Tuple(p); - 1 - } - }; - Tuple() - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor acquires check: -module 0xc0ffee::m { - private inline fun test(p: u64,f: |u64|u64): u64 { - (f)(p) - } - private fun unused_lambda() { - { - let (p: u64): (u64) = Tuple(0); - { - let (x: u64): (u64) = Tuple(p); - 1 - } - }; - Tuple() - } - private fun unused_lambda_suppressed1() { - { - let (p: u64): (u64) = Tuple(0); - { - let (_x: u64): (u64) = Tuple(p); - 1 - } - }; - Tuple() - } - private fun unused_lambda_suppressed2() { - { - let (p: u64): (u64) = Tuple(0); - { - let (_: u64): (u64) = Tuple(p); - 1 - } - }; - Tuple() - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor simplifier: -module 0xc0ffee::m { - private inline fun test(p: u64,f: |u64|u64): u64 { - (f)(p) - } - private fun unused_lambda() { - 1; - Tuple() - } - private fun unused_lambda_suppressed1() { - 1; - Tuple() - } - private fun unused_lambda_suppressed2() { - 1; - Tuple() - } -} // end 0xc0ffee::m - - -// -- Model dump after env processor lambda-lifting: -module 0xc0ffee::m { - private inline fun test(p: u64,f: |u64|u64): u64 { - (f)(p) - } - private fun unused_lambda() { - 1; - Tuple() - } - private fun unused_lambda_suppressed1() { - 1; - Tuple() - } - private fun unused_lambda_suppressed2() { - 1; - Tuple() - } -} // end 0xc0ffee::m +Diagnostics: +warning: Unused anonymous function parameter `x`. Consider removing or prefixing with an underscore: `_x` + ┌─ tests/lambda/unused_lambda_param.move:7:18 + │ +7 │ test(0, |x| 1); + │ ^ -// -- Model dump after env processor specification checker: +// -- Model dump before bytecode pipeline module 0xc0ffee::m { private inline fun test(p: u64,f: |u64|u64): u64 { (f)(p) @@ -311,34 +25,21 @@ module 0xc0ffee::m { } } // end 0xc0ffee::m - -// -- Model dump after env processor specification rewriter: +// -- Sourcified model before bytecode pipeline module 0xc0ffee::m { - private inline fun test(p: u64,f: |u64|u64): u64 { - (f)(p) + inline fun test(p: u64, f: |u64|u64): u64 { + f(p) } - private fun unused_lambda() { + fun unused_lambda() { 1; - Tuple() } - private fun unused_lambda_suppressed1() { + fun unused_lambda_suppressed1() { 1; - Tuple() } - private fun unused_lambda_suppressed2() { + fun unused_lambda_suppressed2() { 1; - Tuple() } -} // end 0xc0ffee::m - - - -Diagnostics: -warning: Unused anonymous function parameter `x`. Consider removing or prefixing with an underscore: `_x` - ┌─ tests/lambda/unused_lambda_param.move:7:18 - │ -7 │ test(0, |x| 1); - │ ^ +} ============ initial bytecode ================ diff --git a/third_party/move/move-compiler-v2/tests/more-v1/parser/invalid_call_lhs_complex_expression.exp b/third_party/move/move-compiler-v2/tests/more-v1/parser/invalid_call_lhs_complex_expression.exp index eb41afe8197db..cc556f788c76c 100644 --- a/third_party/move/move-compiler-v2/tests/more-v1/parser/invalid_call_lhs_complex_expression.exp +++ b/third_party/move/move-compiler-v2/tests/more-v1/parser/invalid_call_lhs_complex_expression.exp @@ -1,10 +1,13 @@ Diagnostics: -error: unexpected token - ┌─ tests/more-v1/parser/invalid_call_lhs_complex_expression.move:3:29 +error: expected `|()|_` but found a value of type `integer` + ┌─ tests/more-v1/parser/invalid_call_lhs_complex_expression.move:3:9 │ 3 │ (if (true) 5 else 0)(); - │ ^ - │ │ - │ Unexpected '(' - │ Expected ';' + │ ^^^^^^^^^^^^^^^^^^^^^^ + +error: expected `|(integer, integer)|_` but found a value of type `()` + ┌─ tests/more-v1/parser/invalid_call_lhs_complex_expression.move:4:9 + │ +4 │ (while (false) {})(0, 1); + │ ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/third_party/move/move-compiler-v2/tests/more-v1/parser/invalid_call_lhs_complex_expression2.exp b/third_party/move/move-compiler-v2/tests/more-v1/parser/invalid_call_lhs_complex_expression2.exp index 03ed8ceb2af6f..f9bd44939a1a8 100644 --- a/third_party/move/move-compiler-v2/tests/more-v1/parser/invalid_call_lhs_complex_expression2.exp +++ b/third_party/move/move-compiler-v2/tests/more-v1/parser/invalid_call_lhs_complex_expression2.exp @@ -1,10 +1,13 @@ Diagnostics: -error: unexpected token - ┌─ tests/more-v1/parser/invalid_call_lhs_complex_expression2.move:3:29 +error: expected `|()|_` but found a value of type `integer` + ┌─ tests/more-v1/parser/invalid_call_lhs_complex_expression2.move:3:9 │ 3 │ (if (true) 5 else 0)(); - │ ^ - │ │ - │ Unexpected '(' - │ Expected ';' + │ ^^^^^^^^^^^^^^^^^^^^^^ + +error: expected `|(integer, integer)|_` but found a value of type `()` + ┌─ tests/more-v1/parser/invalid_call_lhs_complex_expression2.move:4:9 + │ +4 │ (while (false) {})(0, 1); + │ ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/third_party/move/move-compiler-v2/tests/more-v1/parser/invalid_call_lhs_parens_around_name.exp b/third_party/move/move-compiler-v2/tests/more-v1/parser/invalid_call_lhs_parens_around_name.exp index 222dec853b372..e86d08c0250ef 100644 --- a/third_party/move/move-compiler-v2/tests/more-v1/parser/invalid_call_lhs_parens_around_name.exp +++ b/third_party/move/move-compiler-v2/tests/more-v1/parser/invalid_call_lhs_parens_around_name.exp @@ -1,10 +1,7 @@ Diagnostics: -error: unexpected token - ┌─ tests/more-v1/parser/invalid_call_lhs_parens_around_name.move:3:14 +error: undeclared `foo` + ┌─ tests/more-v1/parser/invalid_call_lhs_parens_around_name.move:3:10 │ 3 │ (foo)() - │ ^ - │ │ - │ Unexpected '(' - │ Expected ';' + │ ^^^ diff --git a/third_party/move/move-compiler-v2/tests/more-v1/parser/invalid_call_lhs_parens_around_name2.exp b/third_party/move/move-compiler-v2/tests/more-v1/parser/invalid_call_lhs_parens_around_name2.exp index f47f13fe5ecb6..483fe4de5d478 100644 --- a/third_party/move/move-compiler-v2/tests/more-v1/parser/invalid_call_lhs_parens_around_name2.exp +++ b/third_party/move/move-compiler-v2/tests/more-v1/parser/invalid_call_lhs_parens_around_name2.exp @@ -1,10 +1,7 @@ Diagnostics: -error: unexpected token - ┌─ tests/more-v1/parser/invalid_call_lhs_parens_around_name2.move:3:14 +error: undeclared `foo` + ┌─ tests/more-v1/parser/invalid_call_lhs_parens_around_name2.move:3:10 │ 3 │ (foo)() - │ ^ - │ │ - │ Unexpected '(' - │ Expected ';' + │ ^^^ diff --git a/third_party/move/move-compiler-v2/tests/more-v1/parser/invalid_call_lhs_return.exp b/third_party/move/move-compiler-v2/tests/more-v1/parser/invalid_call_lhs_return.exp index 332165ecd3108..4890ecb1afef1 100644 --- a/third_party/move/move-compiler-v2/tests/more-v1/parser/invalid_call_lhs_return.exp +++ b/third_party/move/move-compiler-v2/tests/more-v1/parser/invalid_call_lhs_return.exp @@ -1,10 +1,7 @@ Diagnostics: -error: unexpected token - ┌─ tests/more-v1/parser/invalid_call_lhs_return.move:3:20 +error: Calls to function values other than inline function parameters not yet supported + ┌─ tests/more-v1/parser/invalid_call_lhs_return.move:3:9 │ 3 │ (return ())(0, 1); - │ ^ - │ │ - │ Unexpected '(' - │ Expected ';' + │ ^^^^^^^^^^^^^^^^^ diff --git a/third_party/move/move-compiler-v2/tests/more-v1/parser/invalid_call_lhs_return2.exp b/third_party/move/move-compiler-v2/tests/more-v1/parser/invalid_call_lhs_return2.exp index b9972c50113c3..9b0ec32618792 100644 --- a/third_party/move/move-compiler-v2/tests/more-v1/parser/invalid_call_lhs_return2.exp +++ b/third_party/move/move-compiler-v2/tests/more-v1/parser/invalid_call_lhs_return2.exp @@ -1,10 +1,7 @@ Diagnostics: -error: unexpected token - ┌─ tests/more-v1/parser/invalid_call_lhs_return2.move:3:20 +error: Calls to function values other than inline function parameters not yet supported + ┌─ tests/more-v1/parser/invalid_call_lhs_return2.move:3:9 │ 3 │ (return ())(0, 1); - │ ^ - │ │ - │ Unexpected '(' - │ Expected ';' + │ ^^^^^^^^^^^^^^^^^ diff --git a/third_party/move/move-compiler-v2/tests/more-v1/parser/invalid_call_lhs_value.exp b/third_party/move/move-compiler-v2/tests/more-v1/parser/invalid_call_lhs_value.exp index d17d58623b224..9a9a96a0285a4 100644 --- a/third_party/move/move-compiler-v2/tests/more-v1/parser/invalid_call_lhs_value.exp +++ b/third_party/move/move-compiler-v2/tests/more-v1/parser/invalid_call_lhs_value.exp @@ -1,10 +1,13 @@ Diagnostics: -error: unexpected token - ┌─ tests/more-v1/parser/invalid_call_lhs_value.move:3:10 +error: expected `|()|_` but found a value of type `integer` + ┌─ tests/more-v1/parser/invalid_call_lhs_value.move:3:9 │ 3 │ 5(); - │ ^ - │ │ - │ Unexpected '(' - │ Expected ';' + │ ^^^ + +error: expected `|(integer, integer)|_` but found a value of type `integer` + ┌─ tests/more-v1/parser/invalid_call_lhs_value.move:4:9 + │ +4 │ 5(0, 1); + │ ^^^^^^^ diff --git a/third_party/move/move-compiler-v2/tests/more-v1/parser/invalid_call_lhs_value2.exp b/third_party/move/move-compiler-v2/tests/more-v1/parser/invalid_call_lhs_value2.exp index e2f3d92b38d92..63bab502411bb 100644 --- a/third_party/move/move-compiler-v2/tests/more-v1/parser/invalid_call_lhs_value2.exp +++ b/third_party/move/move-compiler-v2/tests/more-v1/parser/invalid_call_lhs_value2.exp @@ -1,10 +1,13 @@ Diagnostics: -error: unexpected token - ┌─ tests/more-v1/parser/invalid_call_lhs_value2.move:3:10 +error: expected `|()|_` but found a value of type `integer` + ┌─ tests/more-v1/parser/invalid_call_lhs_value2.move:3:9 │ 3 │ 5(); - │ ^ - │ │ - │ Unexpected '(' - │ Expected ';' + │ ^^^ + +error: expected `|(integer, integer)|_` but found a value of type `integer` + ┌─ tests/more-v1/parser/invalid_call_lhs_value2.move:4:9 + │ +4 │ 5(0, 1); + │ ^^^^^^^ diff --git a/third_party/move/move-compiler-v2/tests/more-v1/parser/unexpected_token_after_ability_function_constraint.exp b/third_party/move/move-compiler-v2/tests/more-v1/parser/unexpected_token_after_ability_function_constraint.exp index b9eafd1f9f753..9808aa198bb4b 100644 --- a/third_party/move/move-compiler-v2/tests/more-v1/parser/unexpected_token_after_ability_function_constraint.exp +++ b/third_party/move/move-compiler-v2/tests/more-v1/parser/unexpected_token_after_ability_function_constraint.exp @@ -4,7 +4,6 @@ error: unexpected token ┌─ tests/more-v1/parser/unexpected_token_after_ability_function_constraint.move:4:21 │ 4 │ fun foo() {} - │ ^ - │ │ - │ Unexpected '&' - │ Expected one of: '+', '>', or ',' + │ - ^ Expected '>' + │ │ + │ To match this '<' diff --git a/third_party/move/move-compiler-v2/tests/testsuite.rs b/third_party/move/move-compiler-v2/tests/testsuite.rs index 2be787447d562..9c50f57fa3eab 100644 --- a/third_party/move/move-compiler-v2/tests/testsuite.rs +++ b/third_party/move/move-compiler-v2/tests/testsuite.rs @@ -176,7 +176,7 @@ const TEST_CONFIGS: Lazy> = Lazy::new(|| { .set_experiment(Experiment::LAMBDA_VALUES, true) .set_experiment(Experiment::LAMBDA_LIFTING, true), stop_after: StopAfter::FileFormat, - dump_ast: DumpLevel::AllStages, + dump_ast: DumpLevel::EndStage, dump_bytecode: DumpLevel::EndStage, dump_bytecode_filter: None, }, diff --git a/third_party/move/move-compiler/src/expansion/ast.rs b/third_party/move/move-compiler/src/expansion/ast.rs index 47db86f2654ba..f4c64d7ec66fe 100644 --- a/third_party/move/move-compiler/src/expansion/ast.rs +++ b/third_party/move/move-compiler/src/expansion/ast.rs @@ -6,8 +6,8 @@ use crate::{ expansion::translate::is_valid_struct_constant_or_schema_name, parser::ast::{ self as P, Ability, Ability_, BinOp, CallKind, ConstantName, Field, FunctionName, Label, - ModuleName, QuantKind, SpecApplyPattern, StructName, UnaryOp, UseDecl, Var, VariantName, - ENTRY_MODIFIER, + LambdaCaptureKind, ModuleName, QuantKind, SpecApplyPattern, StructName, UnaryOp, UseDecl, + Var, VariantName, ENTRY_MODIFIER, }, shared::{ ast_debug::*, @@ -401,7 +401,7 @@ pub enum Type_ { Multiple(Vec), Apply(ModuleAccess, Vec), Ref(bool, Box), - Fun(Vec, Box), + Fun(Vec, Box, AbilitySet), UnresolvedError, } pub type Type = Spanned; @@ -498,6 +498,7 @@ pub enum Exp_ { Name(ModuleAccess, Option>), Call(ModuleAccess, CallKind, Option>, Spanned>), + ExpCall(Box, Spanned>), Pack(ModuleAccess, Option>, Fields), Vector(Loc, Option>, Spanned>), @@ -506,7 +507,7 @@ pub enum Exp_ { While(Option