From 0aee7f91711cf4a8ae933efb09f822ba984b9351 Mon Sep 17 00:00:00 2001 From: Wolfgang Grieskamp Date: Sun, 1 Sep 2024 23:51:15 -0700 Subject: [PATCH 1/3] [compiler-v2] Ast generator from stackless bytecode, Source gen from Ast Converter from stackless bytecode into Model AST ('astifier'). (We already have one from binary format to stackless.) Also adds a converter from AST to source ('sourcifier'). This adds the major pieces for a working decompiler. However, the pieces are not fully connected to a tool yet, as more sidework needs to be done first. Specifically, this PR adds breaks/continues to labeled outer loops, which are not yet supported by the compiler. There are some tests in a new test crate `ast-generator-tests`. These call the v2 compiler to compile up to file format, then decompile from there into stackless bytecode, into AST, and via sourcifier back to source. However, desired execution roundtrip comparison tests can only be implemented once the full toolchain is ready. Another set of tests for the 'sourcifier' is via compiler-v2 baseline files. Where AST dump is requested in those tests, we dump now also the sourcified AST. This can live side-by-side for a while until we may decide to remove one of the outputs. --- Cargo.lock | 20 + Cargo.toml | 2 + .../src/bytecode_generator.rs | 5 +- .../src/env_pipeline/inliner.rs | 4 +- .../tests/ability-check/ability_violation.exp | 6 +- .../ability-check/alive_since_borrowed.exp | 4 +- .../tests/ability-check/assign.exp | 2 +- .../tests/ability-check/bug_14189.exp | 2 +- ...ug_14223_unused_non_droppable_no_abort.exp | 2 +- .../tests/ability-check/bug_14227.exp | 2 +- .../tests/ability-check/explicit_move.exp | 2 +- .../tests/ability-check/index_ability_err.exp | 2 +- .../tests/ability-check/loop_abort.exp | 2 +- .../typing/assign_unpack_references.exp | 4 +- .../typing/bind_unpack_references.exp | 4 +- .../typing/borrow_local_temp_resource.exp | 4 +- .../typing/derefrence_reference.exp | 14 +- .../ability-check/typing/eq_invalid2.exp | 6 +- .../ability-check/typing/mutate_resource.exp | 2 +- .../ability-check/typing/neq_invalid2.exp | 12 +- .../tests/ability-check/typing/pack.exp | 2 +- .../phantom_param_op_abilities_invalid2.exp | 8 +- .../type_variable_join_threaded_unpack.exp | 2 +- ...e_variable_join_threaded_unpack_assign.exp | 2 +- .../ability-check/unused_para_no_drop.exp | 12 +- .../v1-borrow-tests/assign_resource.exp | 4 +- .../ability-check/v1-borrow-tests/no_drop.exp | 2 +- .../v1-locals/drop_conditional.exp | 4 +- .../v1-locals/reassign_parameter.exp | 2 +- .../v1-signer/copy_loc_transitive.exp | 2 +- .../v1-typing/assign_pop_resource.exp | 6 +- .../v1-typing/bind_pop_resource.exp | 8 +- .../borrow_field_non_ref_non_local_root.exp | 2 +- .../v1-typing/conditional_copy_invalid.exp | 20 +- .../v1-typing/conditional_drop_invalid.exp | 22 +- ...plicit_deref_borrow_field_not_copyable.exp | 4 +- .../v1-typing/seq_cannot_ignore_resource.exp | 12 +- .../borrowed_from_one_path.exp | 36 +- .../ability-transform/copy_ability_tuple.exp | 60 +- .../tests/ability-transform/mutate_vector.exp | 96 +- .../tests/abort-analysis/drop_on_abort.exp | 12 +- .../tests/abort-analysis/loop_abort.exp | 24 +- .../tests/bytecode-generator/assign.exp | 56 +- .../bytecode-generator/assign_inline.exp | 10 + .../tests/bytecode-generator/borrow.exp | 51 +- .../borrow_deref_optimize.exp | 54 +- .../bug_14300_update_variant_select.exp | 99 +- .../bug_14300_variant_select_autoref.exp | 29 +- .../bug_14471_receiver_inference.exp | 68 +- .../bytecode-generator/conditional_borrow.exp | 152 +- .../bytecode-generator/escape_autoref.exp | 79 +- .../tests/bytecode-generator/fields.exp | 204 +- .../bytecode-generator/fields_invalid.exp | 22 +- .../bytecode-generator/freeze_mut_ref.exp | 123 +- .../tests/bytecode-generator/globals.exp | 62 +- .../tests/bytecode-generator/if_else.exp | 10 + .../tests/bytecode-generator/inline_specs.exp | 24 + .../tests/bytecode-generator/loop.exp | 29 + .../tests/bytecode-generator/loop_invalid.exp | 14 + .../matching_ability_err.exp | 113 +- .../matching_coverage_err.exp | 140 +- .../tests/bytecode-generator/matching_ok.exp | 412 ++- .../matching_refutable_err.exp | 20 +- .../moved_var_not_simplified3.exp | 10 + .../mutate_immutable_cmp.exp | 60 +- .../tests/bytecode-generator/operators.exp | 22 + .../tests/bytecode-generator/pack_order.exp | 83 +- .../tests/bytecode-generator/pack_unpack.exp | 42 +- .../reference_conversion.exp | 13 + .../bytecode-generator/spec_construct.exp | 31 +- .../v1-commands/break_outside_loop.exp | 7 + .../break_outside_loop_in_else.exp | 7 + .../v1-commands/break_outside_loop_in_if.exp | 7 + .../v1-commands/continue_outside_loop.exp | 7 + .../continue_outside_loop_in_if.exp | 7 + .../v1-typing/global_invalid.exp | 9 + .../v1-typing/mutate_immutable.exp | 19 +- .../tests/bytecode-generator/vector.exp | 7 + .../tests/bytecode-generator/wildcard2.exp | 8 + .../tests/bytecode-generator/wildcard3.exp | 35 +- .../tests/bytecode-generator/wildcard4.exp | 11 + .../tests/bytecode-generator/wildcard5.exp | 20 +- .../tests/bytecode-generator/wildcard6.exp | 9 + .../tests/bytecode-generator/wildcard7.exp | 10 + .../tests/bytecode-generator/wildcard8.exp | 8 + .../entry_inline_err_no_report.exp | 13 + .../checking-lang-v1/eq_inline_typed.exp | 9 + .../use_struct_overlap_with_module.exp | 15 +- .../tests/checking/abilities/tuple.exp | 18 +- .../abilities/v1/ability_constraints.exp | 229 +- .../v1/phantom_param_op_abilities.exp | 72 +- .../phantom_params_constraint_abilities.exp | 55 +- .../v1/phantom_params_field_abilities.exp | 38 +- .../checking/access_specifiers/access_ok.exp | 90 +- .../acquires_list_generic.exp | 17 +- .../attributes/aptos_stdlib_attributes2.exp | 8 + .../attributes/attribute_placement.exp | 21 + .../attributes/attribute_variants.exp | 4 + .../checking/control_flow/loop_after_loop.exp | 8 + .../tests/checking/dotdot/dotdot_valid.exp | 225 +- .../tests/checking/dotdot/extra_dotdot.exp | 22 +- .../tests/checking/indexing/examples_book.exp | 28 +- .../tests/checking/inlining/bug_11112.exp | 21 + .../tests/checking/inlining/bug_11223.exp | 11 + .../tests/checking/inlining/bug_9717.exp | 75 + .../checking/inlining/bug_9717_looponly.exp | 17 + .../inlining/continue_without_loop.exp | 7 + .../tests/checking/inlining/deep_exp.exp | 2544 +++++++++++++++++ .../checking/inlining/double_nesting.exp | 19 + .../inlining/inline_accessing_constant.exp | 12 + .../tests/checking/inlining/lambda.exp | 69 + .../tests/checking/inlining/lambda_cast.exp | 40 + .../tests/checking/inlining/lambda_typed.exp | 69 + .../tests/checking/inlining/nested_mul.exp | 13 + .../checking/inlining/order_sensitive.exp | 94 + .../checking/inlining/recursive_nesting.exp | 30 + .../checking/inlining/resources_valid.exp | 43 +- .../checking/inlining/shadowing_unused.exp | 29 + .../inlining/shadowing_unused_nodecl.exp | 29 + .../shadowing_unused_nodecl_typed.exp | 29 + .../inlining/shadowing_unused_typed.exp | 29 + .../tests/checking/inlining/spec_inlining.exp | 51 + .../checking/inlining/spec_inlining_typed.exp | 51 + .../checking/inlining/temp_shadowing.exp | 32 + .../tests/checking/inlining/test_12670.exp | 31 +- .../tests/checking/inlining/unused_inline.exp | 24 + .../naming/duplicate_acquires_list_item.exp | 44 +- .../checking/naming/generics_shadowing.exp | 11 + .../global_builtin_one_type_argument.exp | 27 +- .../naming/struct_in_current_module.exp | 16 +- .../naming/unused_type_parameter_struct.exp | 22 +- .../checking/naming/warning_dependency.exp | 6 +- .../positional_fields/assign_field.exp | 127 +- .../bind_anonymous_field.exp | 43 +- .../positional_fields/common_access.exp | 19 +- .../checking/positional_fields/decl_ok.exp | 45 +- .../named_tuple_ability_decl_ok.exp | 29 +- .../named_tuple_construct_ok.exp | 70 +- .../variant_ability_decl_ok.exp | 22 + .../tests/checking/receiver/calls.exp | 48 +- .../checking/receiver/calls_with_freeze.exp | 36 +- .../tests/checking/receiver/decl_errors.exp | 37 +- .../receiver/dont_warn_unused_self.exp | 11 +- .../tests/checking/receiver/generic_calls.exp | 66 +- .../checking/receiver/generic_calls_typed.exp | 66 +- .../tests/checking/receiver/same_names.exp | 42 +- .../checking/receiver/same_names_typed.exp | 42 +- .../tests/checking/receiver/vectors.exp | 15 + .../specs/assert_skipped_for_spec.exp | 8 + .../tests/checking/specs/conditions_ok.exp | 19 +- .../tests/checking/specs/expressions_ok.exp | 4 + .../checking/specs/inline_fun_in_spec.exp | 62 +- .../specs/inline_fun_in_spec_typed.exp | 62 +- .../checking/specs/inline_fun_spec_ok.exp | 13 + .../checking/specs/inline_spec_inference.exp | 14 + .../specs/inline_spec_inference_bitvector.exp | 18 + .../specs/inline_spec_inference_vector.exp | 14 + .../tests/checking/specs/inline_spec_old.exp | 12 + .../checking/specs/intrinsic_decl_ok.exp | 54 +- .../tests/checking/specs/invariants_ok.exp | 27 +- .../tests/checking/specs/lets_ok.exp | 8 + .../specs/move_function_in_spec_ok.exp | 47 +- .../tests/checking/specs/quantifiers_ok.exp | 15 +- .../tests/checking/specs/schemas_ok.exp | 15 + .../tests/checking/specs/structs_ok.exp | 50 +- .../tests/checking/specs/type_variance_ok.exp | 7 + .../tests/checking/specs/update_field_ok.exp | 21 +- .../tests/checking/typing/annotated_types.exp | 17 +- .../tests/checking/typing/assign_nested2.exp | 19 +- .../tests/checking/typing/assign_tuple_wg.exp | 21 +- .../tests/checking/typing/binary_add.exp | 27 +- .../tests/checking/typing/binary_and.exp | 21 +- .../tests/checking/typing/binary_bit_and.exp | 27 +- .../tests/checking/typing/binary_bit_or.exp | 27 +- .../tests/checking/typing/binary_div.exp | 27 +- .../tests/checking/typing/binary_geq.exp | 27 +- .../tests/checking/typing/binary_gt.exp | 27 +- .../tests/checking/typing/binary_leq.exp | 27 +- .../tests/checking/typing/binary_lt.exp | 27 +- .../tests/checking/typing/binary_mod.exp | 27 +- .../tests/checking/typing/binary_mul.exp | 27 +- .../tests/checking/typing/binary_or.exp | 21 +- .../tests/checking/typing/binary_shl.exp | 27 +- .../tests/checking/typing/binary_shr.exp | 27 +- .../tests/checking/typing/binary_sub.exp | 27 +- .../tests/checking/typing/binary_xor.exp | 27 +- .../checking/typing/bind_with_type_annot.exp | 16 +- .../tests/checking/typing/block_empty.exp | 9 + .../checking/typing/block_single_expr.exp | 13 + .../checking/typing/block_with_statements.exp | 23 +- .../tests/checking/typing/borrow_field.exp | 14 +- .../checking/typing/borrow_field_chain.exp | 48 +- .../typing/borrow_field_complex_root_expr.exp | 34 +- .../typing/borrow_field_non_ref_root.exp | 23 +- .../tests/checking/typing/borrow_local.exp | 42 +- .../checking/typing/borrow_local_temp.exp | 16 + .../tests/checking/typing/break_any_type.exp | 19 +- .../checking/typing/break_outside_loop.exp | 15 + .../tests/checking/typing/cast.exp | 17 + .../typing/constant_all_valid_types.exp | 43 + .../checking/typing/constant_folding.exp | 4 + .../typing/constant_supported_exps.exp | 4 + .../checking/typing/continue_any_type.exp | 19 +- .../checking/typing/continue_outside_loop.exp | 8 + .../typing/decl_unpack_references.exp | 42 +- .../typing/declare_with_type_annot.exp | 12 +- .../tests/checking/typing/derefrence.exp | 44 +- .../tests/checking/typing/dummy_field.exp | 42 +- .../checking/typing/entry_on_any_vis.exp | 10 + .../typing/entry_signature_no_warning.exp | 22 +- .../tests/checking/typing/eq.exp | 64 +- .../tests/checking/typing/eq_inline.exp | 9 + .../tests/checking/typing/eq_inline_typed.exp | 9 + .../tests/checking/typing/eq_ref.exp | 13 + .../tests/checking/typing/exp_list.exp | 21 +- .../tests/checking/typing/explicit_copy.exp | 17 +- .../tests/checking/typing/explicit_move.exp | 20 +- .../tests/checking/typing/global_builtins.exp | 48 +- .../typing/global_builtins_inferred.exp | 18 +- .../typing/hex_and_decimal_address.exp | 23 +- .../checking/typing/if_branches_subtype.exp | 14 + .../tests/checking/typing/if_condition.exp | 12 + .../tests/checking/typing/if_default_else.exp | 11 + .../checking/typing/if_matched_branches.exp | 22 +- .../typing/implicit_deref_borrow_field.exp | 14 +- .../implicit_deref_borrow_field_chain.exp | 33 +- ...t_deref_borrow_field_complex_root_expr.exp | 31 +- ...ef_borrow_field_non_ref_non_local_root.exp | 33 +- ...plicit_deref_borrow_field_non_ref_root.exp | 17 +- .../tests/checking/typing/large_binop.exp | 7 + .../tests/checking/typing/loop_body.exp | 35 + .../checking/typing/loop_result_type.exp | 36 +- .../tests/checking/typing/main_arguments.exp | 6 + .../typing/main_arguments_various_caes.exp | 24 +- .../tests/checking/typing/main_call_entry.exp | 11 + .../typing/main_with_type_parameters.exp | 6 + .../typing/module_call_entry_function.exp | 46 + .../typing/move_from_type_argument.exp | 18 +- .../checking/typing/mutable_eq_and_neq.exp | 75 +- .../tests/checking/typing/mutate.exp | 51 +- .../tests/checking/typing/neq.exp | 64 +- .../checking/typing/nested_post_process.exp | 43 +- .../tests/checking/typing/other_builtins.exp | 13 + .../typing/phantom_param_struct_decl.exp | 27 +- .../tests/checking/typing/return_any_type.exp | 17 +- .../typing/return_type_explicit_exp.exp | 18 +- .../checking/typing/return_type_last_exp.exp | 16 +- .../checking/typing/seq_ignores_value.exp | 18 + .../tests/checking/typing/shadowing.exp | 41 + .../tests/checking/typing/spec_block_ok.exp | 11 + .../checking/typing/struct_no_field_list.exp | 16 +- .../checking/typing/subtype_annotation.exp | 20 + .../tests/checking/typing/subtype_args.exp | 33 +- .../tests/checking/typing/subtype_assign.exp | 25 + .../tests/checking/typing/subtype_bind.exp | 21 + .../tests/checking/typing/subtype_return.exp | 23 +- .../tests/checking/typing/tuple.exp | 18 +- .../typing/type_variable_join_single_pack.exp | 18 +- .../type_variable_join_single_unpack.exp | 23 +- ...ype_variable_join_single_unpack_assign.exp | 31 +- .../type_variable_join_threaded_pack.exp | 40 +- .../tests/checking/typing/unary_not.exp | 20 +- .../tests/checking/typing/unit.exp | 7 + .../checking/typing/unused_lambda_param.exp | 16 + .../typing/unused_lambda_param_typed.exp | 16 + .../tests/checking/typing/unused_local.exp | 34 + .../tests/checking/typing/use_local.exp | 19 +- .../multi_pool_money_market_token.exp | 298 +- .../v1-examples/simple_money_market_token.exp | 263 +- .../tests/checking/typing/values.exp | 11 + .../checking/typing/vector_basic_cases.exp | 31 +- .../tests/checking/typing/while_body.exp | 19 + .../tests/checking/typing/while_condition.exp | 12 + .../tests/checking/unused/local_var.exp | 7 + .../tests/checking/unused/unused_enum.exp | 17 +- .../variants_allow_match_empty_block.exp | 6 + .../variants/variants_allow_match_fun_1.exp | 29 +- .../variants/variants_allow_match_fun_2.exp | 28 +- .../variants/variants_allow_match_fun_3.exp | 29 +- .../variants/variants_allow_match_var.exp | 27 +- .../checking/variants/variants_constants.exp | 53 +- .../tests/checking/variants/variants_ok.exp | 173 +- .../variants_test_no_parenthesis_ok.exp | 46 +- .../checking/variants/variants_test_ok.exp | 46 +- .../variants/variants_test_parse_ok2.exp | 18 +- .../visibility-checker/direct_visibility.exp | 21 + .../module_call_visibility_friend.exp | 48 + .../parser_package_keyword.exp | 8 + .../jump-label.on.exp | 18 +- .../tests/copy-propagation/mut_refs_2.exp | 20 +- .../sequential_assign_struct.exp | 28 +- .../recursive_type_instantiation.exp | 22 +- .../v1-tests/complex_1.exp | 8 +- ...mutually_recursive_just_type_params_ok.exp | 10 + ...mutually_recursive_non_generic_type_ok.exp | 15 +- ...hree_args_just_type_params_shitfing_ok.exp | 13 + ...ree_args_type_con_non_generic_types_ok.exp | 12 +- ...recursive_three_args_type_con_shifting.exp | 12 +- ...rgs_non_generic_type_and_type_param_ok.exp | 10 + ..._two_args_swapping_just_type_params_ok.exp | 10 + ...y_recursive_two_args_swapping_type_con.exp | 6 +- .../v1-tests/mutually_recursive_type_con.exp | 6 +- .../v1-tests/nested_types_1.exp | 2 +- .../v1-tests/nested_types_2.exp | 2 +- .../recursive_infinite_type_terminates.exp | 2 +- .../recursive_one_arg_just_type_params_ok.exp | 7 + .../recursive_one_arg_non_generic_type_ok.exp | 7 + .../v1-tests/recursive_one_arg_type_con.exp | 2 +- .../recursive_two_args_swapping_type_con.exp | 2 +- .../v1-tests/two_loops.exp | 4 +- .../infinite_instantiations_invalid.exp | 56 +- .../infinite_instantiations_valid.exp | 34 +- .../folding/constant_folding_addresses.exp | 10 + .../tests/folding/constant_values.exp | 22 + .../tests/folding/empty_tvectors.exp | 48 +- .../tests/folding/empty_vectors.exp | 43 + .../tests/folding/empty_vectors2.exp | 45 + .../tests/folding/non_constant_empty_vec.exp | 32 +- .../tests/folding/nonempty_tvectors.exp | 48 +- .../tests/folding/nonempty_vectors.exp | 43 + .../tests/lambda-lifting/pattern.exp | 12 +- .../tests/live-var/mut_ref.exp | 120 +- .../tests/more-v1/liveness/mut_ref2.exp | 18 +- .../locals/assign_partial_resource.exp | 6 +- .../tests/more-v1/locals/assign_resource.exp | 8 +- .../tests/more-v1/locals/unused_resource.exp | 14 +- .../unused_resource_explicit_return.exp | 14 +- .../constant_folding_ristretto.exp | 9 + .../moved_var_not_simplified.exp | 9 + .../moved_var_not_simplified2.exp | 10 + .../tests/op-equal/eval_order.exp | 64 + .../tests/op-equal/invalid1.exp | 14 + .../tests/op-equal/invalid6.exp | 13 + .../tests/op-equal/valid0.exp | 363 ++- .../tests/op-equal/valid1.exp | 217 +- .../tests/op-equal/valid2.exp | 69 +- ...urn_with_borrowed_loc_resource_invalid.exp | 2 +- ...h_borrowed_loc_resource_invalid.no-opt.exp | 2 +- ...with_borrowed_loc_resource_invalid.old.exp | 2 +- .../always_false_branch.exp | 12 + .../assign_unpack_references.exp | 64 +- .../simplifier-elimination/binary_add.exp | 19 +- .../bind_with_type_annot.exp | 12 +- .../constant_all_valid_types.exp | 29 + .../simplifier-elimination/double_nesting.exp | 19 + .../else_assigns_if_doesnt.exp | 15 + .../if_assigns_else_doesnt.exp | 15 + .../if_assigns_no_else.exp | 9 + .../simplifier-elimination/if_condition.exp | 8 + .../moved_var_not_simplified.exp | 9 + .../moved_var_not_simplified2.exp | 10 + .../recursive_nesting.exp | 30 + .../use_before_assign.exp | 8 + .../use_before_assign_loop.exp | 39 + .../use_before_assign_while.exp | 38 + .../tests/simplifier/bug_11112.exp | 21 + .../tests/simplifier/conditional_borrow.exp | 84 +- .../simplifier/constant_folding_addresses.exp | 7 + .../simplifier/constant_folding_ristretto.exp | 7 + .../tests/simplifier/deep_exp.exp | 2544 +++++++++++++++++ .../simplifier/moved_var_not_simplified.exp | 9 + .../simplifier/moved_var_not_simplified2.exp | 10 + .../tests/simplifier/random.exp | 77 + .../tests/simplifier/simplifier_test1.exp | 18 + .../tests/simplifier/simplifier_test2.exp | 27 + .../tests/simplifier/simplifier_test3.exp | 19 + .../tests/simplifier/simplifier_test4.exp | 51 +- .../move/move-compiler-v2/tests/testsuite.rs | 12 +- .../struct_use_before_assign.exp | 32 +- .../uninit-use-checker/unused_reference.exp | 8 +- .../v1-locals/use_before_assign_simple.exp | 24 +- .../tests/variable-coalescing/consume_1.exp | 50 +- .../variable-coalescing/consume_1.opt.exp | 50 +- .../tests/variable-coalescing/consume_2.exp | 30 +- .../variable-coalescing/consume_2.opt.exp | 30 +- .../tests/variable-coalescing/consume_3.exp | 30 +- .../variable-coalescing/consume_3.opt.exp | 30 +- .../tests/variable-coalescing/consume_4.exp | 40 +- .../variable-coalescing/consume_4.opt.exp | 40 +- .../tests/variable-coalescing/consume_5.exp | 30 +- .../variable-coalescing/consume_5.opt.exp | 30 +- .../tests/variable-coalescing/mut_refs_2.exp | 70 +- .../variable-coalescing/mut_refs_2.opt.exp | 70 +- .../sequential_assign_struct.exp | 70 +- .../sequential_assign_struct.opt.exp | 70 +- .../mix_friend_package_visibility_valid.exp | 12 + .../visibility-checker/package_visibility.exp | 34 + .../module_call_visibility_friend.exp | 48 + .../visibility-checker/visibility_complex.exp | 26 + .../move/move-model/bytecode/Cargo.toml | 1 + .../bytecode/ast-generator-tests/Cargo.toml | 21 + .../bytecode/ast-generator-tests/src/lib.rs | 5 + .../tests/conditionals.exp | 469 +++ .../tests/conditionals.move | 38 + .../ast-generator-tests/tests/loops.exp | 499 ++++ .../ast-generator-tests/tests/loops.move | 34 + .../ast-generator-tests/tests/match.exp | 335 +++ .../ast-generator-tests/tests/match.move | 21 + .../ast-generator-tests/tests/testsuite.rs | 133 + .../move/move-model/bytecode/src/astifier.rs | 1990 +++++++++++++ .../bytecode/src/dataflow_domains.rs | 9 +- .../move/move-model/bytecode/src/lib.rs | 1 + .../bytecode/src/stackless_bytecode.rs | 31 +- .../src/stackless_control_flow_graph.rs | 42 +- third_party/move/move-model/src/ast.rs | 179 +- .../move-model/src/builder/exp_builder.rs | 6 +- .../move-model/src/builder/model_builder.rs | 1 + .../move/move-model/src/exp_builder.rs | 169 ++ .../move/move-model/src/exp_rewriter.rs | 6 +- third_party/move/move-model/src/lib.rs | 2 + third_party/move/move-model/src/model.rs | 29 +- third_party/move/move-model/src/sourcifier.rs | 1062 +++++++ third_party/move/move-model/src/ty.rs | 16 +- third_party/move/scripts/move_pr.sh | 1 + 414 files changed, 20090 insertions(+), 2420 deletions(-) create mode 100644 third_party/move/move-model/bytecode/ast-generator-tests/Cargo.toml create mode 100644 third_party/move/move-model/bytecode/ast-generator-tests/src/lib.rs create mode 100644 third_party/move/move-model/bytecode/ast-generator-tests/tests/conditionals.exp create mode 100644 third_party/move/move-model/bytecode/ast-generator-tests/tests/conditionals.move create mode 100644 third_party/move/move-model/bytecode/ast-generator-tests/tests/loops.exp create mode 100644 third_party/move/move-model/bytecode/ast-generator-tests/tests/loops.move create mode 100644 third_party/move/move-model/bytecode/ast-generator-tests/tests/match.exp create mode 100644 third_party/move/move-model/bytecode/ast-generator-tests/tests/match.move create mode 100644 third_party/move/move-model/bytecode/ast-generator-tests/tests/testsuite.rs create mode 100644 third_party/move/move-model/bytecode/src/astifier.rs create mode 100644 third_party/move/move-model/src/exp_builder.rs create mode 100644 third_party/move/move-model/src/sourcifier.rs diff --git a/Cargo.lock b/Cargo.lock index ff101bc3974dd..82bd6e543b615 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10839,6 +10839,19 @@ dependencies = [ "tempfile", ] +[[package]] +name = "move-ast-generator-tests" +version = "0.1.0" +dependencies = [ + "anyhow", + "codespan-reporting", + "datatest-stable", + "move-compiler-v2", + "move-model", + "move-prover-test-utils", + "move-stackless-bytecode", +] + [[package]] name = "move-async-vm" version = "0.1.0" @@ -11453,6 +11466,7 @@ dependencies = [ "num 0.4.1", "paste", "petgraph 0.6.5", + "topological-sort", ] [[package]] @@ -16740,6 +16754,12 @@ dependencies = [ "tonic 0.11.0", ] +[[package]] +name = "topological-sort" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea68304e134ecd095ac6c3574494fc62b909f416c4fca77e440530221e549d3d" + [[package]] name = "tower" version = "0.4.13" diff --git a/Cargo.toml b/Cargo.toml index 98659f312410b..d1f271a95416b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -221,6 +221,7 @@ members = [ "third_party/move/move-model", "third_party/move/move-model/bytecode", "third_party/move/move-model/bytecode-test-utils", + "third_party/move/move-model/bytecode/ast-generator-tests", "third_party/move/move-prover", "third_party/move/move-prover/boogie-backend", "third_party/move/move-prover/bytecode-pipeline", @@ -791,6 +792,7 @@ tonic = { version = "0.11.0", features = [ "zstd", ] } tonic-reflection = "0.11.0" +topological-sort = "0.2.2" triomphe = "0.1.9" tui = "0.19.0" typed-arena = "2.0.2" 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 e20f3b09bf19e..16248e056d369 100644 --- a/third_party/move/move-compiler-v2/src/bytecode_generator.rs +++ b/third_party/move/move-compiler-v2/src/bytecode_generator.rs @@ -447,7 +447,7 @@ impl<'env> Generator<'env> { self.emit_with(*id, |attr| Bytecode::Jump(attr, continue_label)); self.emit_with(*id, |attr| Bytecode::Label(attr, break_label)); }, - ExpData::LoopCont(id, do_continue) => { + ExpData::LoopCont(id, 0, do_continue) => { if let Some(LoopContext { continue_label, break_label, @@ -463,6 +463,9 @@ impl<'env> Generator<'env> { self.error(*id, "missing enclosing loop statement") } }, + ExpData::LoopCont(_, _, _) => { + unimplemented!("continue/break with nesting") + }, ExpData::SpecBlock(id, spec) => { // Map locals in spec to assigned temporaries. let mut replacer = |id, target| { 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 6047eae1a82ab..77a4ce7eefede 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 @@ -800,7 +800,7 @@ impl<'env, 'rewriter> InlinedRewriter<'env, 'rewriter> { (lambda expressions)", ) }, - ExpData::LoopCont(node_id, is_continue) if !post && in_loop == 0 => { + ExpData::LoopCont(node_id, _, is_continue) if !post && in_loop == 0 => { let node_loc = env.get_node_loc(*node_id); env.error( &node_loc, @@ -1046,7 +1046,7 @@ impl<'env, 'rewriter> ExpRewriterFunctions for InlinedRewriter<'env, 'rewriter> self.in_loop += 1; true }, - ExpData::LoopCont(node_id, is_continue) if self.in_loop == 0 => { + ExpData::LoopCont(node_id, _, is_continue) if self.in_loop == 0 => { let node_loc = self.env.get_node_loc(*node_id); self.env.error( &node_loc, diff --git a/third_party/move/move-compiler-v2/tests/ability-check/ability_violation.exp b/third_party/move/move-compiler-v2/tests/ability-check/ability_violation.exp index 3910bd4b361dc..449755574b05a 100644 --- a/third_party/move/move-compiler-v2/tests/ability-check/ability_violation.exp +++ b/third_party/move/move-compiler-v2/tests/ability-check/ability_violation.exp @@ -1,6 +1,6 @@ Diagnostics: -error: local `x` of type `ability::Impotent` does not have the `copy` ability +error: local `x` of type `Impotent` does not have the `copy` ability ┌─ tests/ability-check/ability_violation.move:7:10 │ 7 │ (x, x); @@ -8,13 +8,13 @@ error: local `x` of type `ability::Impotent` does not have the `copy` ability │ │ │ copy needed here because value is still in use -error: value of type `ability::Impotent` does not have the `drop` ability +error: value of type `Impotent` does not have the `drop` ability ┌─ tests/ability-check/ability_violation.move:7:10 │ 7 │ (x, x); │ ^ implicitly dropped here since it is no longer used -error: value of type `ability::Impotent` does not have the `drop` ability +error: value of type `Impotent` does not have the `drop` ability ┌─ tests/ability-check/ability_violation.move:7:13 │ 7 │ (x, x); diff --git a/third_party/move/move-compiler-v2/tests/ability-check/alive_since_borrowed.exp b/third_party/move/move-compiler-v2/tests/ability-check/alive_since_borrowed.exp index 780b27d837589..558387a805c8a 100644 --- a/third_party/move/move-compiler-v2/tests/ability-check/alive_since_borrowed.exp +++ b/third_party/move/move-compiler-v2/tests/ability-check/alive_since_borrowed.exp @@ -1,12 +1,12 @@ Diagnostics: -error: local `x` of type `test::Impotent` does not have the `drop` ability +error: local `x` of type `Impotent` does not have the `drop` ability ┌─ tests/ability-check/alive_since_borrowed.move:7:17 │ 7 │ let y = &x; │ ^^ still borrowed but will be implicitly dropped later since it is no longer used -error: local `x` of type `test::S` does not have the `drop` ability +error: local `x` of type `S` does not have the `drop` ability ┌─ tests/ability-check/alive_since_borrowed.move:21:9 │ 21 │ x.g.h diff --git a/third_party/move/move-compiler-v2/tests/ability-check/assign.exp b/third_party/move/move-compiler-v2/tests/ability-check/assign.exp index 0b42b9566280a..342c5583dcf4a 100644 --- a/third_party/move/move-compiler-v2/tests/ability-check/assign.exp +++ b/third_party/move/move-compiler-v2/tests/ability-check/assign.exp @@ -1,6 +1,6 @@ Diagnostics: -error: local `s` of type `assign::S` does not have the `drop` ability +error: local `s` of type `S` does not have the `drop` ability ┌─ tests/ability-check/assign.move:17:9 │ 17 │ *s = S { f: 42, g: T { h: 42 } }; diff --git a/third_party/move/move-compiler-v2/tests/ability-check/bug_14189.exp b/third_party/move/move-compiler-v2/tests/ability-check/bug_14189.exp index 9be1b39f7a68d..1f466890ce1b3 100644 --- a/third_party/move/move-compiler-v2/tests/ability-check/bug_14189.exp +++ b/third_party/move/move-compiler-v2/tests/ability-check/bug_14189.exp @@ -1,6 +1,6 @@ Diagnostics: -error: local `x1` of type `test::S2` does not have the `copy` ability +error: local `x1` of type `S2` does not have the `copy` ability ┌─ tests/ability-check/bug_14189.move:34:18 │ 34 │ let x2 = S3 { x: x1, y: x0, z: x1 }; diff --git a/third_party/move/move-compiler-v2/tests/ability-check/bug_14223_unused_non_droppable_no_abort.exp b/third_party/move/move-compiler-v2/tests/ability-check/bug_14223_unused_non_droppable_no_abort.exp index 7686f9261cd64..b796cb2449c58 100644 --- a/third_party/move/move-compiler-v2/tests/ability-check/bug_14223_unused_non_droppable_no_abort.exp +++ b/third_party/move/move-compiler-v2/tests/ability-check/bug_14223_unused_non_droppable_no_abort.exp @@ -1,6 +1,6 @@ Diagnostics: -error: local `_x` of type `Module0::S` does not have the `drop` ability +error: local `_x` of type `S` does not have the `drop` ability ┌─ tests/ability-check/bug_14223_unused_non_droppable_no_abort.move:5:18 │ 5 │ let _x = S {}; diff --git a/third_party/move/move-compiler-v2/tests/ability-check/bug_14227.exp b/third_party/move/move-compiler-v2/tests/ability-check/bug_14227.exp index fd998cd08ec9e..9d9cc031d2a49 100644 --- a/third_party/move/move-compiler-v2/tests/ability-check/bug_14227.exp +++ b/third_party/move/move-compiler-v2/tests/ability-check/bug_14227.exp @@ -1,6 +1,6 @@ Diagnostics: -error: local `_common_fields` of type `m::CommonFields` does not have the `copy` ability +error: local `_common_fields` of type `CommonFields` does not have the `copy` ability ┌─ tests/ability-check/bug_14227.move:21:16 │ 21 │ y: vector[_common_fields] diff --git a/third_party/move/move-compiler-v2/tests/ability-check/explicit_move.exp b/third_party/move/move-compiler-v2/tests/ability-check/explicit_move.exp index 6d7bca3a95988..82955ef74829c 100644 --- a/third_party/move/move-compiler-v2/tests/ability-check/explicit_move.exp +++ b/third_party/move/move-compiler-v2/tests/ability-check/explicit_move.exp @@ -1,6 +1,6 @@ Diagnostics: -error: local `x` of type `m::R` does not have the `copy` ability +error: local `x` of type `R` does not have the `copy` ability ┌─ tests/ability-check/explicit_move.move:12:9 │ 12 │ some(x); diff --git a/third_party/move/move-compiler-v2/tests/ability-check/index_ability_err.exp b/third_party/move/move-compiler-v2/tests/ability-check/index_ability_err.exp index f43ecc4cd3d91..fa105ebb9bb60 100644 --- a/third_party/move/move-compiler-v2/tests/ability-check/index_ability_err.exp +++ b/third_party/move/move-compiler-v2/tests/ability-check/index_ability_err.exp @@ -1,6 +1,6 @@ Diagnostics: -error: value of type `test::Y>` does not have the `copy` ability +error: value of type `Y>` does not have the `copy` ability ┌─ tests/ability-check/index_ability_err.move:12:17 │ 12 │ let _ = Y>[addr]; diff --git a/third_party/move/move-compiler-v2/tests/ability-check/loop_abort.exp b/third_party/move/move-compiler-v2/tests/ability-check/loop_abort.exp index ad91b8f3de0f4..b1b16e0db1718 100644 --- a/third_party/move/move-compiler-v2/tests/ability-check/loop_abort.exp +++ b/third_party/move/move-compiler-v2/tests/ability-check/loop_abort.exp @@ -1,6 +1,6 @@ Diagnostics: -error: local `_x` of type `Test::Impotent` does not have the `drop` ability +error: local `_x` of type `Impotent` does not have the `drop` ability ┌─ tests/ability-check/loop_abort.move:11:18 │ 11 │ let _x = Impotent {}; diff --git a/third_party/move/move-compiler-v2/tests/ability-check/typing/assign_unpack_references.exp b/third_party/move/move-compiler-v2/tests/ability-check/typing/assign_unpack_references.exp index bbc6a9d36aef0..2c976c12f11c9 100644 --- a/third_party/move/move-compiler-v2/tests/ability-check/typing/assign_unpack_references.exp +++ b/third_party/move/move-compiler-v2/tests/ability-check/typing/assign_unpack_references.exp @@ -1,12 +1,12 @@ Diagnostics: -error: value of type `M::R` does not have the `drop` ability +error: value of type `R` does not have the `drop` ability ┌─ tests/ability-check/typing/assign_unpack_references.move:17:33 │ 17 │ R { s1: S { f }, s2 } = &R { s1: S{f: 0}, s2: S{f: 1} }; f; s2; │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ still borrowed but will be implicitly dropped later since it is no longer used -error: value of type `M::R` does not have the `drop` ability +error: value of type `R` does not have the `drop` ability ┌─ tests/ability-check/typing/assign_unpack_references.move:27:33 │ 27 │ R { s1: S { f }, s2 } = &mut R { s1: S{f: 0}, s2: S{f: 1} }; f; s2; diff --git a/third_party/move/move-compiler-v2/tests/ability-check/typing/bind_unpack_references.exp b/third_party/move/move-compiler-v2/tests/ability-check/typing/bind_unpack_references.exp index ac2b384d7f6a7..4ebf1bda482f5 100644 --- a/third_party/move/move-compiler-v2/tests/ability-check/typing/bind_unpack_references.exp +++ b/third_party/move/move-compiler-v2/tests/ability-check/typing/bind_unpack_references.exp @@ -1,12 +1,12 @@ Diagnostics: -error: value of type `M::R` does not have the `drop` ability +error: value of type `R` does not have the `drop` ability ┌─ tests/ability-check/typing/bind_unpack_references.move:13:41 │ 13 │ let R { s1: S { f }, s2 }: &R = &R { s1: S{f: 0}, s2: S{f: 1} }; f; s2; │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ still borrowed but will be implicitly dropped later since it is no longer used -error: value of type `M::R` does not have the `drop` ability +error: value of type `R` does not have the `drop` ability ┌─ tests/ability-check/typing/bind_unpack_references.move:20:45 │ 20 │ let R { s1: S { f }, s2 }: &mut R = &mut R { s1: S{f: 0}, s2: S{f: 1} }; f; s2; diff --git a/third_party/move/move-compiler-v2/tests/ability-check/typing/borrow_local_temp_resource.exp b/third_party/move/move-compiler-v2/tests/ability-check/typing/borrow_local_temp_resource.exp index 470ba80ca3109..e094596ecd526 100644 --- a/third_party/move/move-compiler-v2/tests/ability-check/typing/borrow_local_temp_resource.exp +++ b/third_party/move/move-compiler-v2/tests/ability-check/typing/borrow_local_temp_resource.exp @@ -1,12 +1,12 @@ Diagnostics: -error: value of type `M::R` does not have the `drop` ability +error: value of type `R` does not have the `drop` ability ┌─ tests/ability-check/typing/borrow_local_temp_resource.move:6:9 │ 6 │ &R{}; │ ^^^^ implicitly dropped here since it is no longer used -error: value of type `M::R` does not have the `drop` ability +error: value of type `R` does not have the `drop` ability ┌─ tests/ability-check/typing/borrow_local_temp_resource.move:7:9 │ 7 │ &mut R{}; diff --git a/third_party/move/move-compiler-v2/tests/ability-check/typing/derefrence_reference.exp b/third_party/move/move-compiler-v2/tests/ability-check/typing/derefrence_reference.exp index 75db7a1e361f1..b2f9787f94a1a 100644 --- a/third_party/move/move-compiler-v2/tests/ability-check/typing/derefrence_reference.exp +++ b/third_party/move/move-compiler-v2/tests/ability-check/typing/derefrence_reference.exp @@ -1,42 +1,42 @@ Diagnostics: -error: local `r` of type `M::R` does not have the `copy` ability +error: local `r` of type `R` does not have the `copy` ability ┌─ tests/ability-check/typing/derefrence_reference.move:6:16 │ 6 │ R {} = *r; │ ^^ reference content copied here -error: local `b` of type `M::B` does not have the `copy` ability +error: local `b` of type `B` does not have the `copy` ability ┌─ tests/ability-check/typing/derefrence_reference.move:7:24 │ 7 │ B { r: R{} } = *b; │ ^^ reference content copied here -error: value of type `M::R` does not have the `copy` ability +error: value of type `R` does not have the `copy` ability ┌─ tests/ability-check/typing/derefrence_reference.move:8:17 │ 8 │ R{} = *&b.r; │ ^^^ reference content copied here -error: local `r` of type `M::R` does not have the `copy` ability +error: local `r` of type `R` does not have the `copy` ability ┌─ tests/ability-check/typing/derefrence_reference.move:12:16 │ 12 │ R {} = *r; │ ^^ reference content copied here -error: local `b` of type `M::B` does not have the `copy` ability +error: local `b` of type `B` does not have the `copy` ability ┌─ tests/ability-check/typing/derefrence_reference.move:13:24 │ 13 │ B { r: R{} } = *b; │ ^^ reference content copied here -error: value of type `M::R` does not have the `copy` ability +error: value of type `R` does not have the `copy` ability ┌─ tests/ability-check/typing/derefrence_reference.move:14:17 │ 14 │ R{} = *&b.r; │ ^^^ reference content copied here -error: value of type `M::R` does not have the `copy` ability +error: value of type `R` does not have the `copy` ability ┌─ tests/ability-check/typing/derefrence_reference.move:15:21 │ 15 │ R{} = *&mut b.r; diff --git a/third_party/move/move-compiler-v2/tests/ability-check/typing/eq_invalid2.exp b/third_party/move/move-compiler-v2/tests/ability-check/typing/eq_invalid2.exp index 7fea4b627a31d..a415502fc4815 100644 --- a/third_party/move/move-compiler-v2/tests/ability-check/typing/eq_invalid2.exp +++ b/third_party/move/move-compiler-v2/tests/ability-check/typing/eq_invalid2.exp @@ -1,18 +1,18 @@ Diagnostics: -error: local `r` of type `M::R` does not have the `copy` ability +error: local `r` of type `R` does not have the `copy` ability ┌─ tests/ability-check/typing/eq_invalid2.move:11:9 │ 11 │ r == r; │ ^^^^^^ copy needed here because value is still in use -error: local `r` of type `M::R` does not have the `drop` ability +error: local `r` of type `R` does not have the `drop` ability ┌─ tests/ability-check/typing/eq_invalid2.move:11:9 │ 11 │ r == r; │ ^^^^^^ operator drops value here (consider borrowing the argument) -error: value of type `M::G1` does not have the `drop` ability +error: value of type `G1` does not have the `drop` ability ┌─ tests/ability-check/typing/eq_invalid2.move:15:9 │ 15 │ G1{ f: t } == G1{ f: t }; diff --git a/third_party/move/move-compiler-v2/tests/ability-check/typing/mutate_resource.exp b/third_party/move/move-compiler-v2/tests/ability-check/typing/mutate_resource.exp index 6be249a01f461..8a2dbc1c78b74 100644 --- a/third_party/move/move-compiler-v2/tests/ability-check/typing/mutate_resource.exp +++ b/third_party/move/move-compiler-v2/tests/ability-check/typing/mutate_resource.exp @@ -1,6 +1,6 @@ Diagnostics: -error: local `r` of type `M::R` does not have the `drop` ability +error: local `r` of type `R` does not have the `drop` ability ┌─ tests/ability-check/typing/mutate_resource.move:5:9 │ 5 │ *r = R {}; diff --git a/third_party/move/move-compiler-v2/tests/ability-check/typing/neq_invalid2.exp b/third_party/move/move-compiler-v2/tests/ability-check/typing/neq_invalid2.exp index c21ca3e6e5640..c07bea1c68b1b 100644 --- a/third_party/move/move-compiler-v2/tests/ability-check/typing/neq_invalid2.exp +++ b/third_party/move/move-compiler-v2/tests/ability-check/typing/neq_invalid2.exp @@ -1,36 +1,36 @@ Diagnostics: -error: local `s2` of type `M::S` does not have the `drop` ability +error: local `s2` of type `S` does not have the `drop` ability ┌─ tests/ability-check/typing/neq_invalid2.move:17:9 │ 17 │ s != s2; │ ^^^^^^^ operator drops value here (consider borrowing the argument) -error: local `s` of type `M::S` does not have the `drop` ability +error: local `s` of type `S` does not have the `drop` ability ┌─ tests/ability-check/typing/neq_invalid2.move:17:9 │ 17 │ s != s2; │ ^^^^^^^ operator drops value here (consider borrowing the argument) -error: local `r1` of type `M::R` does not have the `drop` ability +error: local `r1` of type `R` does not have the `drop` ability ┌─ tests/ability-check/typing/neq_invalid2.move:22:9 │ 22 │ r1 != r2; │ ^^^^^^^^ operator drops value here (consider borrowing the argument) -error: local `r2` of type `M::R` does not have the `drop` ability +error: local `r2` of type `R` does not have the `drop` ability ┌─ tests/ability-check/typing/neq_invalid2.move:22:9 │ 22 │ r1 != r2; │ ^^^^^^^^ operator drops value here (consider borrowing the argument) -error: value of type `M::G1` does not have the `drop` ability +error: value of type `G1` does not have the `drop` ability ┌─ tests/ability-check/typing/neq_invalid2.move:27:9 │ 27 │ G1{} != G1{}; │ ^^^^^^^^^^^^^^^^^^^^^^ operator drops value here (consider borrowing the argument) -error: value of type `M::G2` does not have the `drop` ability +error: value of type `G2` does not have the `drop` ability ┌─ tests/ability-check/typing/neq_invalid2.move:28:9 │ 28 │ G2{} != G2{}; diff --git a/third_party/move/move-compiler-v2/tests/ability-check/typing/pack.exp b/third_party/move/move-compiler-v2/tests/ability-check/typing/pack.exp index b35c01849ea5f..f413f2adcb141 100644 --- a/third_party/move/move-compiler-v2/tests/ability-check/typing/pack.exp +++ b/third_party/move/move-compiler-v2/tests/ability-check/typing/pack.exp @@ -1,6 +1,6 @@ Diagnostics: -error: local `s` of type `M::S` does not have the `copy` ability +error: local `s` of type `S` does not have the `copy` ability ┌─ tests/ability-check/typing/pack.move:14:29 │ 14 │ let n2 = Nat { f: *&s }; diff --git a/third_party/move/move-compiler-v2/tests/ability-check/typing/phantom_param_op_abilities_invalid2.exp b/third_party/move/move-compiler-v2/tests/ability-check/typing/phantom_param_op_abilities_invalid2.exp index 9ff4f8060bc86..412b4fac8c74d 100644 --- a/third_party/move/move-compiler-v2/tests/ability-check/typing/phantom_param_op_abilities_invalid2.exp +++ b/third_party/move/move-compiler-v2/tests/ability-check/typing/phantom_param_op_abilities_invalid2.exp @@ -1,18 +1,18 @@ Diagnostics: -error: local `ref` of type `M::HasDrop` does not have the `drop` ability +error: local `ref` of type `HasDrop` does not have the `drop` ability ┌─ tests/ability-check/typing/phantom_param_op_abilities_invalid2.move:11:9 │ 11 │ *ref = HasDrop { a: NoAbilities { } }; │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference content dropped here -error: value of type `M::HasDrop` does not have the `drop` ability +error: value of type `HasDrop` does not have the `drop` ability ┌─ tests/ability-check/typing/phantom_param_op_abilities_invalid2.move:16:9 │ 16 │ _ = HasDrop { a: NoAbilities { } }; │ ^ implicitly dropped here since it is no longer used -error: local `_x` of type `M::HasDrop` does not have the `drop` ability +error: local `_x` of type `HasDrop` does not have the `drop` ability ┌─ tests/ability-check/typing/phantom_param_op_abilities_invalid2.move:20:51 │ 20 │ fun f3(_x: HasDrop) { @@ -20,7 +20,7 @@ error: local `_x` of type `M::HasDrop` does not 21 │ │ } │ ╰─────^ implicitly dropped here since it is no longer used -error: local `x` of type `M::HasCopy` does not have the `copy` ability +error: local `x` of type `HasCopy` does not have the `copy` ability ┌─ tests/ability-check/typing/phantom_param_op_abilities_invalid2.move:25:10 │ 25 │ (copy x, x) diff --git a/third_party/move/move-compiler-v2/tests/ability-check/typing/type_variable_join_threaded_unpack.exp b/third_party/move/move-compiler-v2/tests/ability-check/typing/type_variable_join_threaded_unpack.exp index a00ded68efbf9..41c2aec98921a 100644 --- a/third_party/move/move-compiler-v2/tests/ability-check/typing/type_variable_join_threaded_unpack.exp +++ b/third_party/move/move-compiler-v2/tests/ability-check/typing/type_variable_join_threaded_unpack.exp @@ -1,6 +1,6 @@ Diagnostics: -error: local `f1` of type `M::Box>` does not have the `copy` ability +error: local `f1` of type `Box>` does not have the `copy` ability ┌─ tests/ability-check/typing/type_variable_join_threaded_unpack.move:40:44 │ 40 │ Container::put(&mut v, Box { f1: *&f1, f2 }); diff --git a/third_party/move/move-compiler-v2/tests/ability-check/typing/type_variable_join_threaded_unpack_assign.exp b/third_party/move/move-compiler-v2/tests/ability-check/typing/type_variable_join_threaded_unpack_assign.exp index 01898c35db8c6..d95c02ffe7b31 100644 --- a/third_party/move/move-compiler-v2/tests/ability-check/typing/type_variable_join_threaded_unpack_assign.exp +++ b/third_party/move/move-compiler-v2/tests/ability-check/typing/type_variable_join_threaded_unpack_assign.exp @@ -1,6 +1,6 @@ Diagnostics: -error: local `f1` of type `M::Box>` does not have the `copy` ability +error: local `f1` of type `Box>` does not have the `copy` ability ┌─ tests/ability-check/typing/type_variable_join_threaded_unpack_assign.move:44:44 │ 44 │ Container::put(&mut v, Box { f1: *&f1, f2 }); diff --git a/third_party/move/move-compiler-v2/tests/ability-check/unused_para_no_drop.exp b/third_party/move/move-compiler-v2/tests/ability-check/unused_para_no_drop.exp index 836f76fef6fd2..011b5e8f6e77d 100644 --- a/third_party/move/move-compiler-v2/tests/ability-check/unused_para_no_drop.exp +++ b/third_party/move/move-compiler-v2/tests/ability-check/unused_para_no_drop.exp @@ -8,7 +8,7 @@ error: local `_x` of type `T` does not have the `drop` ability 10 │ │ } │ ╰─────^ implicitly dropped here since it is no longer used -error: local `_x` of type `m::S` does not have the `drop` ability +error: local `_x` of type `S` does not have the `drop` ability ┌─ tests/ability-check/unused_para_no_drop.move:15:26 │ 15 │ public fun f3(_x: S) { @@ -16,7 +16,7 @@ error: local `_x` of type `m::S` does not have the `drop` ability 16 │ │ } │ ╰─────^ implicitly dropped here since it is no longer used -error: local `_x` of type `vector` does not have the `drop` ability +error: local `_x` of type `vector` does not have the `drop` ability ┌─ tests/ability-check/unused_para_no_drop.move:21:34 │ 21 │ public fun f5(_x: vector) { @@ -30,13 +30,13 @@ error: local `_y` of type `T` does not have the `drop` ability 38 │ x │ ^ implicitly dropped here since it is no longer used -error: local `x` of type `m::S` does not have the `drop` ability +error: local `x` of type `S` does not have the `drop` ability ┌─ tests/ability-check/unused_para_no_drop.move:42:9 │ 42 │ &x == &y │ ^^ still borrowed but will be implicitly dropped later since it is no longer used -error: local `y` of type `m::S` does not have the `drop` ability +error: local `y` of type `S` does not have the `drop` ability ┌─ tests/ability-check/unused_para_no_drop.move:42:15 │ 42 │ &x == &y @@ -54,13 +54,13 @@ error: local `y` of type `T` does not have the `drop` ability 46 │ &x == &y │ ^^ still borrowed but will be implicitly dropped later since it is no longer used -error: local `x` of type `m::S2` does not have the `drop` ability +error: local `x` of type `S2` does not have the `drop` ability ┌─ tests/ability-check/unused_para_no_drop.move:54:9 │ 54 │ x.foo == y.foo │ ^ still borrowed but will be implicitly dropped later since it is no longer used -error: local `y` of type `m::S2` does not have the `drop` ability +error: local `y` of type `S2` does not have the `drop` ability ┌─ tests/ability-check/unused_para_no_drop.move:54:18 │ 54 │ x.foo == y.foo diff --git a/third_party/move/move-compiler-v2/tests/ability-check/v1-borrow-tests/assign_resource.exp b/third_party/move/move-compiler-v2/tests/ability-check/v1-borrow-tests/assign_resource.exp index db2b4f2d7dfab..88b027952a193 100644 --- a/third_party/move/move-compiler-v2/tests/ability-check/v1-borrow-tests/assign_resource.exp +++ b/third_party/move/move-compiler-v2/tests/ability-check/v1-borrow-tests/assign_resource.exp @@ -1,12 +1,12 @@ Diagnostics: -error: local `t` of type `M::T` does not have the `drop` ability +error: local `t` of type `T` does not have the `drop` ability ┌─ tests/ability-check/v1-borrow-tests/assign_resource.move:5:22 │ 5 │ let t = T{}; &t; │ ^^ implicitly dropped here since it is no longer used -error: local `t` of type `M::T` does not have the `drop` ability +error: local `t` of type `T` does not have the `drop` ability ┌─ tests/ability-check/v1-borrow-tests/assign_resource.move:6:19 │ 6 │ t = T {}; &t; diff --git a/third_party/move/move-compiler-v2/tests/ability-check/v1-borrow-tests/no_drop.exp b/third_party/move/move-compiler-v2/tests/ability-check/v1-borrow-tests/no_drop.exp index 87e25ce461590..d0f0bd3816cb5 100644 --- a/third_party/move/move-compiler-v2/tests/ability-check/v1-borrow-tests/no_drop.exp +++ b/third_party/move/move-compiler-v2/tests/ability-check/v1-borrow-tests/no_drop.exp @@ -1,6 +1,6 @@ Diagnostics: -error: local `x` of type `M::X` does not have the `drop` ability +error: local `x` of type `X` does not have the `drop` ability ┌─ tests/ability-check/v1-borrow-tests/no_drop.move:6:9 │ 6 │ &x; diff --git a/third_party/move/move-compiler-v2/tests/ability-check/v1-locals/drop_conditional.exp b/third_party/move/move-compiler-v2/tests/ability-check/v1-locals/drop_conditional.exp index 3aeca4920a7b0..3d1e5403d7704 100644 --- a/third_party/move/move-compiler-v2/tests/ability-check/v1-locals/drop_conditional.exp +++ b/third_party/move/move-compiler-v2/tests/ability-check/v1-locals/drop_conditional.exp @@ -1,12 +1,12 @@ Diagnostics: -error: local `x` of type `M::Cup` does not have the `drop` ability +error: local `x` of type `Cup` does not have the `drop` ability ┌─ tests/ability-check/v1-locals/drop_conditional.move:12:9 │ 12 │ &x; │ ^^ implicitly dropped here since it is no longer used -error: local `x` of type `M::Pair` does not have the `drop` ability +error: local `x` of type `Pair` does not have the `drop` ability ┌─ tests/ability-check/v1-locals/drop_conditional.move:14:9 │ 14 │ &x; diff --git a/third_party/move/move-compiler-v2/tests/ability-check/v1-locals/reassign_parameter.exp b/third_party/move/move-compiler-v2/tests/ability-check/v1-locals/reassign_parameter.exp index 9b30add3a1359..f19e3cefbc39c 100644 --- a/third_party/move/move-compiler-v2/tests/ability-check/v1-locals/reassign_parameter.exp +++ b/third_party/move/move-compiler-v2/tests/ability-check/v1-locals/reassign_parameter.exp @@ -1,6 +1,6 @@ Diagnostics: -error: local `r` of type `M::R` does not have the `drop` ability +error: local `r` of type `R` does not have the `drop` ability ┌─ tests/ability-check/v1-locals/reassign_parameter.move:7:9 │ 7 │ ╭ if (true) { diff --git a/third_party/move/move-compiler-v2/tests/ability-check/v1-signer/copy_loc_transitive.exp b/third_party/move/move-compiler-v2/tests/ability-check/v1-signer/copy_loc_transitive.exp index 884b679059917..e9484ac844f4d 100644 --- a/third_party/move/move-compiler-v2/tests/ability-check/v1-signer/copy_loc_transitive.exp +++ b/third_party/move/move-compiler-v2/tests/ability-check/v1-signer/copy_loc_transitive.exp @@ -1,6 +1,6 @@ Diagnostics: -error: local `x` of type `M::S` does not have the `copy` ability +error: local `x` of type `S` does not have the `copy` ability ┌─ tests/ability-check/v1-signer/copy_loc_transitive.move:5:9 │ 5 │ copy x diff --git a/third_party/move/move-compiler-v2/tests/ability-check/v1-typing/assign_pop_resource.exp b/third_party/move/move-compiler-v2/tests/ability-check/v1-typing/assign_pop_resource.exp index 4094f23a8ee64..21b3423e4df58 100644 --- a/third_party/move/move-compiler-v2/tests/ability-check/v1-typing/assign_pop_resource.exp +++ b/third_party/move/move-compiler-v2/tests/ability-check/v1-typing/assign_pop_resource.exp @@ -1,18 +1,18 @@ Diagnostics: -error: value of type `M::R` does not have the `drop` ability +error: value of type `R` does not have the `drop` ability ┌─ tests/ability-check/v1-typing/assign_pop_resource.move:5:9 │ 5 │ _ = R{}; │ ^ implicitly dropped here since it is no longer used -error: value of type `M::R` does not have the `drop` ability +error: value of type `R` does not have the `drop` ability ┌─ tests/ability-check/v1-typing/assign_pop_resource.move:6:10 │ 6 │ (_, _) = (R{}, R{}); │ ^ implicitly dropped here since it is no longer used -error: value of type `M::R` does not have the `drop` ability +error: value of type `R` does not have the `drop` ability ┌─ tests/ability-check/v1-typing/assign_pop_resource.move:6:13 │ 6 │ (_, _) = (R{}, R{}); diff --git a/third_party/move/move-compiler-v2/tests/ability-check/v1-typing/bind_pop_resource.exp b/third_party/move/move-compiler-v2/tests/ability-check/v1-typing/bind_pop_resource.exp index 2c2f2e34d9686..553bf316dc87d 100644 --- a/third_party/move/move-compiler-v2/tests/ability-check/v1-typing/bind_pop_resource.exp +++ b/third_party/move/move-compiler-v2/tests/ability-check/v1-typing/bind_pop_resource.exp @@ -1,24 +1,24 @@ Diagnostics: -error: value of type `M::R` does not have the `drop` ability +error: value of type `R` does not have the `drop` ability ┌─ tests/ability-check/v1-typing/bind_pop_resource.move:5:13 │ 5 │ let _: R = R{}; │ ^ implicitly dropped here since it is no longer used -error: local `_r` of type `M::R` does not have the `drop` ability +error: local `_r` of type `R` does not have the `drop` ability ┌─ tests/ability-check/v1-typing/bind_pop_resource.move:8:21 │ 8 │ let _r: R = R{}; │ ^^^ implicitly dropped here since it is no longer used -error: value of type `M::R` does not have the `drop` ability +error: value of type `R` does not have the `drop` ability ┌─ tests/ability-check/v1-typing/bind_pop_resource.move:9:14 │ 9 │ let (_, _):(R, R) = (R{}, R{}); │ ^ implicitly dropped here since it is no longer used -error: value of type `M::R` does not have the `drop` ability +error: value of type `R` does not have the `drop` ability ┌─ tests/ability-check/v1-typing/bind_pop_resource.move:9:17 │ 9 │ let (_, _):(R, R) = (R{}, R{}); diff --git a/third_party/move/move-compiler-v2/tests/ability-check/v1-typing/borrow_field_non_ref_non_local_root.exp b/third_party/move/move-compiler-v2/tests/ability-check/v1-typing/borrow_field_non_ref_non_local_root.exp index 3ca8e651183f9..cd06c954f6388 100644 --- a/third_party/move/move-compiler-v2/tests/ability-check/v1-typing/borrow_field_non_ref_non_local_root.exp +++ b/third_party/move/move-compiler-v2/tests/ability-check/v1-typing/borrow_field_non_ref_non_local_root.exp @@ -1,6 +1,6 @@ Diagnostics: -error: value of type `M::S` does not have the `copy` ability +error: value of type `S` does not have the `copy` ability ┌─ tests/ability-check/v1-typing/borrow_field_non_ref_non_local_root.move:9:22 │ 9 │ (&(if (cond) *foo() else bar()).f : &u64); diff --git a/third_party/move/move-compiler-v2/tests/ability-check/v1-typing/conditional_copy_invalid.exp b/third_party/move/move-compiler-v2/tests/ability-check/v1-typing/conditional_copy_invalid.exp index 25893cff8e123..5c0feae4f836e 100644 --- a/third_party/move/move-compiler-v2/tests/ability-check/v1-typing/conditional_copy_invalid.exp +++ b/third_party/move/move-compiler-v2/tests/ability-check/v1-typing/conditional_copy_invalid.exp @@ -1,60 +1,60 @@ Diagnostics: -error: local `x` of type `M::Box` does not have the `copy` ability +error: local `x` of type `Box` does not have the `copy` ability ┌─ tests/ability-check/v1-typing/conditional_copy_invalid.move:15:16 │ 15 │ ignore(copy x); │ ^^^^^^ explicitly copied here -error: local `x` of type `M::Box>` does not have the `copy` ability +error: local `x` of type `Box>` does not have the `copy` ability ┌─ tests/ability-check/v1-typing/conditional_copy_invalid.move:17:16 │ 17 │ ignore(copy x); │ ^^^^^^ explicitly copied here -error: local `x` of type `M::Box` does not have the `copy` ability +error: local `x` of type `Box` does not have the `copy` ability ┌─ tests/ability-check/v1-typing/conditional_copy_invalid.move:19:16 │ 19 │ ignore(copy x); │ ^^^^^^ explicitly copied here -error: local `x` of type `M::Box>` does not have the `copy` ability +error: local `x` of type `Box>` does not have the `copy` ability ┌─ tests/ability-check/v1-typing/conditional_copy_invalid.move:21:16 │ 21 │ ignore(copy x); │ ^^^^^^ explicitly copied here -error: local `x` of type `M::Pair` does not have the `copy` ability +error: local `x` of type `Pair` does not have the `copy` ability ┌─ tests/ability-check/v1-typing/conditional_copy_invalid.move:23:16 │ 23 │ ignore(copy x); │ ^^^^^^ explicitly copied here -error: local `x` of type `M::Box` does not have the `copy` ability +error: local `x` of type `Box` does not have the `copy` ability ┌─ tests/ability-check/v1-typing/conditional_copy_invalid.move:27:16 │ 27 │ ignore(*x); │ ^^ reference content copied here -error: local `x` of type `M::Box>` does not have the `copy` ability +error: local `x` of type `Box>` does not have the `copy` ability ┌─ tests/ability-check/v1-typing/conditional_copy_invalid.move:29:16 │ 29 │ ignore(*x); │ ^^ reference content copied here -error: local `x` of type `M::Box` does not have the `copy` ability +error: local `x` of type `Box` does not have the `copy` ability ┌─ tests/ability-check/v1-typing/conditional_copy_invalid.move:31:16 │ 31 │ ignore(*x); │ ^^ reference content copied here -error: local `x` of type `M::Box>` does not have the `copy` ability +error: local `x` of type `Box>` does not have the `copy` ability ┌─ tests/ability-check/v1-typing/conditional_copy_invalid.move:33:16 │ 33 │ ignore(*x); │ ^^ reference content copied here -error: local `x` of type `M::Pair` does not have the `copy` ability +error: local `x` of type `Pair` does not have the `copy` ability ┌─ tests/ability-check/v1-typing/conditional_copy_invalid.move:35:16 │ 35 │ ignore(*x); diff --git a/third_party/move/move-compiler-v2/tests/ability-check/v1-typing/conditional_drop_invalid.exp b/third_party/move/move-compiler-v2/tests/ability-check/v1-typing/conditional_drop_invalid.exp index e450ad7e5cc9c..5f8413a07c1a8 100644 --- a/third_party/move/move-compiler-v2/tests/ability-check/v1-typing/conditional_drop_invalid.exp +++ b/third_party/move/move-compiler-v2/tests/ability-check/v1-typing/conditional_drop_invalid.exp @@ -1,66 +1,66 @@ Diagnostics: -error: value of type `M::Box` does not have the `drop` ability +error: value of type `Box` does not have the `drop` ability ┌─ tests/ability-check/v1-typing/conditional_drop_invalid.move:10:9 │ 10 │ Box { f: R{} }; │ ^^^^^^^^^^^^^^^^^ implicitly dropped here since it is no longer used -error: value of type `M::Box>` does not have the `drop` ability +error: value of type `Box>` does not have the `drop` ability ┌─ tests/ability-check/v1-typing/conditional_drop_invalid.move:11:9 │ 11 │ Box> { f: Box { f: R{} } }; │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implicitly dropped here since it is no longer used -error: value of type `M::Box` does not have the `drop` ability +error: value of type `Box` does not have the `drop` ability ┌─ tests/ability-check/v1-typing/conditional_drop_invalid.move:12:9 │ 12 │ Box { f: t }; │ ^^^^^^^^^^^^^^^ implicitly dropped here since it is no longer used -error: value of type `M::Box>` does not have the `drop` ability +error: value of type `Box>` does not have the `drop` ability ┌─ tests/ability-check/v1-typing/conditional_drop_invalid.move:13:9 │ 13 │ Box> { f: Box { f: t } }; │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implicitly dropped here since it is no longer used -error: value of type `M::Pair` does not have the `drop` ability +error: value of type `Pair` does not have the `drop` ability ┌─ tests/ability-check/v1-typing/conditional_drop_invalid.move:14:9 │ 14 │ Pair { f1: S{}, f2: R{} }; │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implicitly dropped here since it is no longer used -error: value of type `M::Pair` does not have the `drop` ability +error: value of type `Pair` does not have the `drop` ability ┌─ tests/ability-check/v1-typing/conditional_drop_invalid.move:15:10 │ 15 │ (Pair { f1: S{}, f2: R{} }, 0, @0x1); │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implicitly dropped here since it is no longer used -error: value of type `M::Box` does not have the `drop` ability +error: value of type `Box` does not have the `drop` ability ┌─ tests/ability-check/v1-typing/conditional_drop_invalid.move:17:9 │ 17 │ Box { f: R {} } == Box { f: R {} }; │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ operator drops value here (consider borrowing the argument) -error: value of type `M::Box>` does not have the `drop` ability +error: value of type `Box>` does not have the `drop` ability ┌─ tests/ability-check/v1-typing/conditional_drop_invalid.move:18:9 │ 18 │ Box> { f: Box { f: R {} } } == Box> { f: Box { f: R {} }}; │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ operator drops value here (consider borrowing the argument) -error: value of type `M::Box` does not have the `drop` ability +error: value of type `Box` does not have the `drop` ability ┌─ tests/ability-check/v1-typing/conditional_drop_invalid.move:19:9 │ 19 │ Box { f: t } == Box { f: t }; │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ operator drops value here (consider borrowing the argument) -error: value of type `M::Box>` does not have the `drop` ability +error: value of type `Box>` does not have the `drop` ability ┌─ tests/ability-check/v1-typing/conditional_drop_invalid.move:20:9 │ 20 │ Box> { f: Box { f: t } } == Box> { f: Box { f: t} }; │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ operator drops value here (consider borrowing the argument) -error: value of type `M::Pair` does not have the `drop` ability +error: value of type `Pair` does not have the `drop` ability ┌─ tests/ability-check/v1-typing/conditional_drop_invalid.move:21:9 │ 21 │ Pair { f1: R{}, f2: S{} } == Pair { f1: R{}, f2: S{} }; diff --git a/third_party/move/move-compiler-v2/tests/ability-check/v1-typing/implicit_deref_borrow_field_not_copyable.exp b/third_party/move/move-compiler-v2/tests/ability-check/v1-typing/implicit_deref_borrow_field_not_copyable.exp index 891b17c507714..f9b7fb8bde20e 100644 --- a/third_party/move/move-compiler-v2/tests/ability-check/v1-typing/implicit_deref_borrow_field_not_copyable.exp +++ b/third_party/move/move-compiler-v2/tests/ability-check/v1-typing/implicit_deref_borrow_field_not_copyable.exp @@ -1,12 +1,12 @@ Diagnostics: -error: value of type `M::R` does not have the `copy` ability +error: value of type `R` does not have the `copy` ability ┌─ tests/ability-check/v1-typing/implicit_deref_borrow_field_not_copyable.move:8:15 │ 8 │ R{} = b.r; │ ^^^ reference content copied here -error: value of type `M::R` does not have the `copy` ability +error: value of type `R` does not have the `copy` ability ┌─ tests/ability-check/v1-typing/implicit_deref_borrow_field_not_copyable.move:11:15 │ 11 │ R{} = bref.r; diff --git a/third_party/move/move-compiler-v2/tests/ability-check/v1-typing/seq_cannot_ignore_resource.exp b/third_party/move/move-compiler-v2/tests/ability-check/v1-typing/seq_cannot_ignore_resource.exp index 2f2544c85cbb7..a0b416f33dffa 100644 --- a/third_party/move/move-compiler-v2/tests/ability-check/v1-typing/seq_cannot_ignore_resource.exp +++ b/third_party/move/move-compiler-v2/tests/ability-check/v1-typing/seq_cannot_ignore_resource.exp @@ -1,36 +1,36 @@ Diagnostics: -error: value of type `M::R` does not have the `drop` ability +error: value of type `R` does not have the `drop` ability ┌─ tests/ability-check/v1-typing/seq_cannot_ignore_resource.move:5:9 │ 5 │ R{}; │ ^^^ implicitly dropped here since it is no longer used -error: value of type `M::R` does not have the `drop` ability +error: value of type `R` does not have the `drop` ability ┌─ tests/ability-check/v1-typing/seq_cannot_ignore_resource.move:10:9 │ 10 │ r; │ ^ implicitly dropped here since it is no longer used -error: value of type `M::R` does not have the `drop` ability +error: value of type `R` does not have the `drop` ability ┌─ tests/ability-check/v1-typing/seq_cannot_ignore_resource.move:14:20 │ 14 │ (0, false, R{}); │ ^^^ implicitly dropped here since it is no longer used -error: value of type `M::R` does not have the `drop` ability +error: value of type `R` does not have the `drop` ability ┌─ tests/ability-check/v1-typing/seq_cannot_ignore_resource.move:19:30 │ 19 │ if (true) (0, false, R{}) else (0, false, r); │ ^^^ implicitly dropped here since it is no longer used -error: local `r` of type `M::R` does not have the `drop` ability +error: local `r` of type `R` does not have the `drop` ability ┌─ tests/ability-check/v1-typing/seq_cannot_ignore_resource.move:19:19 │ 19 │ if (true) (0, false, R{}) else (0, false, r); │ ^^^^^^^^^^^^^^^ implicitly dropped here since it is no longer used -error: value of type `M::R` does not have the `drop` ability +error: value of type `R` does not have the `drop` ability ┌─ tests/ability-check/v1-typing/seq_cannot_ignore_resource.move:19:51 │ 19 │ if (true) (0, false, R{}) else (0, false, r); diff --git a/third_party/move/move-compiler-v2/tests/ability-transform/borrowed_from_one_path.exp b/third_party/move/move-compiler-v2/tests/ability-transform/borrowed_from_one_path.exp index 322649a3dde34..64fd1e4a61b95 100644 --- a/third_party/move/move-compiler-v2/tests/ability-transform/borrowed_from_one_path.exp +++ b/third_party/move/move-compiler-v2/tests/ability-transform/borrowed_from_one_path.exp @@ -6,7 +6,7 @@ fun m::f($t0: u8, $t1: &vector): u64 { var $t3: &vector var $t4: bool var $t5: u8 - var $t6: &m::R + var $t6: &0x42::m::R var $t7: address var $t8: &u64 var $t9: u64 @@ -15,8 +15,8 @@ fun m::f($t0: u8, $t1: &vector): u64 { 2: if ($t4) goto 3 else goto 8 3: label L0 4: $t7 := 0x1 - 5: $t6 := borrow_global($t7) - 6: $t3 := borrow_field.data($t6) + 5: $t6 := borrow_global<0x42::m::R>($t7) + 6: $t3 := borrow_field<0x42::m::R>.data($t6) 7: goto 10 8: label L1 9: $t3 := infer($t1) @@ -35,7 +35,7 @@ fun m::f($t0: u8, $t1: &vector): u64 { var $t3: &vector var $t4: bool var $t5: u8 - var $t6: &m::R + var $t6: &0x42::m::R var $t7: address var $t8: &u64 var $t9: u64 @@ -50,9 +50,9 @@ fun m::f($t0: u8, $t1: &vector): u64 { # live vars: 4: $t7 := 0x1 # live vars: $t7 - 5: $t6 := borrow_global($t7) + 5: $t6 := borrow_global<0x42::m::R>($t7) # live vars: $t6 - 6: $t3 := borrow_field.data($t6) + 6: $t3 := borrow_field<0x42::m::R>.data($t6) # live vars: $t3 7: goto 10 # live vars: $t1 @@ -79,7 +79,7 @@ fun m::f($t0: u8, $t1: &vector): u64 { var $t3: &vector var $t4: bool var $t5: u8 - var $t6: &m::R + var $t6: &0x42::m::R var $t7: address var $t8: &u64 var $t9: u64 @@ -94,9 +94,9 @@ fun m::f($t0: u8, $t1: &vector): u64 { # live vars: 4: $t7 := 0x1 # live vars: $t7 - 5: $t6 := borrow_global($t7) + 5: $t6 := borrow_global<0x42::m::R>($t7) # live vars: $t6 - 6: $t3 := borrow_field.data($t6) + 6: $t3 := borrow_field<0x42::m::R>.data($t6) # live vars: $t3 7: goto 10 # live vars: $t1 @@ -123,7 +123,7 @@ fun m::f($t0: u8, $t1: &vector): u64 { var $t3: &vector var $t4: bool var $t5: u8 - var $t6: &m::R + var $t6: &0x42::m::R var $t7: address var $t8: &u64 var $t9: u64 @@ -166,7 +166,7 @@ fun m::f($t0: u8, $t1: &vector): u64 { # live vars: $t7 # refs: [] # - 5: $t6 := borrow_global($t7) + 5: $t6 := borrow_global<0x42::m::R>($t7) # live vars: $t6 # refs: [$t6 => #6] # #6 @@ -174,7 +174,7 @@ fun m::f($t0: u8, $t1: &vector): u64 { # #root # -> #6 via [struct `m::R`] at line 12 # - 6: $t3 := borrow_field.data($t6) + 6: $t3 := borrow_field<0x42::m::R>.data($t6) # live vars: $t3 # refs: [$t3 => #3] # #3 @@ -245,7 +245,7 @@ fun m::f($t0: u8, $t1: &vector): u64 { var $t3: &vector var $t4: bool var $t5: u8 - var $t6: &m::R + var $t6: &0x42::m::R var $t7: address var $t8: &u64 var $t9: u64 @@ -294,7 +294,7 @@ fun m::f($t0: u8, $t1: &vector): u64 { # live vars: $t7 # refs: [] # - 5: $t6 := borrow_global($t7) + 5: $t6 := borrow_global<0x42::m::R>($t7) # abort state: {returns,aborts} # live vars: $t6 # refs: [$t6 => #6] @@ -303,7 +303,7 @@ fun m::f($t0: u8, $t1: &vector): u64 { # #root # -> #6 via [struct `m::R`] at line 12 # - 6: $t3 := borrow_field.data($t6) + 6: $t3 := borrow_field<0x42::m::R>.data($t6) # abort state: {returns,aborts} # live vars: $t3 # refs: [$t3 => #3] @@ -382,7 +382,7 @@ fun m::f($t0: u8, $t1: &vector): u64 { var $t3: &vector var $t4: bool var $t5: u8 - var $t6: &m::R + var $t6: &0x42::m::R var $t7: address var $t8: &u64 var $t9: u64 @@ -392,8 +392,8 @@ fun m::f($t0: u8, $t1: &vector): u64 { 3: label L0 4: drop($t1) 5: $t7 := 0x1 - 6: $t6 := borrow_global($t7) - 7: $t3 := borrow_field.data($t6) + 6: $t6 := borrow_global<0x42::m::R>($t7) + 7: $t3 := borrow_field<0x42::m::R>.data($t6) 8: goto 11 9: label L1 10: $t3 := move($t1) diff --git a/third_party/move/move-compiler-v2/tests/ability-transform/copy_ability_tuple.exp b/third_party/move/move-compiler-v2/tests/ability-transform/copy_ability_tuple.exp index f1da3a8a76fdd..3af453f1202a4 100644 --- a/third_party/move/move-compiler-v2/tests/ability-transform/copy_ability_tuple.exp +++ b/third_party/move/move-compiler-v2/tests/ability-transform/copy_ability_tuple.exp @@ -1,8 +1,8 @@ ============ initial bytecode ================ [variant baseline] -public fun M::f($t0: M::R): (M::R, u64) { - var $t1: M::R +public fun M::f($t0: 0x42::M::R): (0x42::M::R, u64) { + var $t1: 0x42::M::R var $t2: u64 0: $t1 := infer($t0) 1: $t2 := 0 @@ -12,22 +12,22 @@ public fun M::f($t0: M::R): (M::R, u64) { [variant baseline] public fun M::g($t0: &signer) { - var $t1: M::R + var $t1: 0x42::M::R var $t2: u64 var $t3: u64 0: $t2 := 1 - 1: $t1 := pack M::R($t2) + 1: $t1 := pack 0x42::M::R($t2) 2: $t3 := 3 3: ($t1, $t3) := M::f($t1) - 4: move_to($t0, $t1) + 4: move_to<0x42::M::R>($t0, $t1) 5: return () } ============ after LiveVarAnalysisProcessor: ================ [variant baseline] -public fun M::f($t0: M::R): (M::R, u64) { - var $t1: M::R +public fun M::f($t0: 0x42::M::R): (0x42::M::R, u64) { + var $t1: 0x42::M::R var $t2: u64 # live vars: $t0 0: $t1 := infer($t0) @@ -40,19 +40,19 @@ public fun M::f($t0: M::R): (M::R, u64) { [variant baseline] public fun M::g($t0: &signer) { - var $t1: M::R + var $t1: 0x42::M::R var $t2: u64 var $t3: u64 # live vars: $t0 0: $t2 := 1 # live vars: $t0, $t2 - 1: $t1 := pack M::R($t2) + 1: $t1 := pack 0x42::M::R($t2) # live vars: $t0, $t1 2: $t3 := 3 # live vars: $t0, $t1 3: ($t1, $t3) := M::f($t1) # live vars: $t0, $t1 - 4: move_to($t0, $t1) + 4: move_to<0x42::M::R>($t0, $t1) # live vars: 5: return () } @@ -60,8 +60,8 @@ public fun M::g($t0: &signer) { ============ after LiveVarAnalysisProcessor: ================ [variant baseline] -public fun M::f($t0: M::R): (M::R, u64) { - var $t1: M::R +public fun M::f($t0: 0x42::M::R): (0x42::M::R, u64) { + var $t1: 0x42::M::R var $t2: u64 # live vars: $t0 0: $t1 := infer($t0) @@ -74,19 +74,19 @@ public fun M::f($t0: M::R): (M::R, u64) { [variant baseline] public fun M::g($t0: &signer) { - var $t1: M::R + var $t1: 0x42::M::R var $t2: u64 var $t3: u64 # live vars: $t0 0: $t2 := 1 # live vars: $t0, $t2 - 1: $t1 := pack M::R($t2) + 1: $t1 := pack 0x42::M::R($t2) # live vars: $t0, $t1 2: $t3 := 3 # live vars: $t0, $t1 3: ($t1, $t3) := M::f($t1) # live vars: $t0, $t1 - 4: move_to($t0, $t1) + 4: move_to<0x42::M::R>($t0, $t1) # live vars: 5: return () } @@ -94,8 +94,8 @@ public fun M::g($t0: &signer) { ============ after ReferenceSafetyProcessor: ================ [variant baseline] -public fun M::f($t0: M::R): (M::R, u64) { - var $t1: M::R +public fun M::f($t0: 0x42::M::R): (0x42::M::R, u64) { + var $t1: 0x42::M::R var $t2: u64 # live vars: $t0 # refs: [] @@ -114,7 +114,7 @@ public fun M::f($t0: M::R): (M::R, u64) { [variant baseline] public fun M::g($t0: &signer) { - var $t1: M::R + var $t1: 0x42::M::R var $t2: u64 var $t3: u64 # live vars: $t0 @@ -132,7 +132,7 @@ public fun M::g($t0: &signer) { # #root # # - 1: $t1 := pack M::R($t2) + 1: $t1 := pack 0x42::M::R($t2) # live vars: $t0, $t1 # refs: [$t0 => #0] # #0 @@ -156,7 +156,7 @@ public fun M::g($t0: &signer) { # #root # # - 4: move_to($t0, $t1) + 4: move_to<0x42::M::R>($t0, $t1) # live vars: # refs: [] # @@ -166,8 +166,8 @@ public fun M::g($t0: &signer) { ============ after AbortAnalysisProcessor: ================ [variant baseline] -public fun M::f($t0: M::R): (M::R, u64) { - var $t1: M::R +public fun M::f($t0: 0x42::M::R): (0x42::M::R, u64) { + var $t1: 0x42::M::R var $t2: u64 # abort state: {returns} # live vars: $t0 @@ -189,7 +189,7 @@ public fun M::f($t0: M::R): (M::R, u64) { [variant baseline] public fun M::g($t0: &signer) { - var $t1: M::R + var $t1: 0x42::M::R var $t2: u64 var $t3: u64 # abort state: {returns,aborts} @@ -209,7 +209,7 @@ public fun M::g($t0: &signer) { # #root # # - 1: $t1 := pack M::R($t2) + 1: $t1 := pack 0x42::M::R($t2) # abort state: {returns,aborts} # live vars: $t0, $t1 # refs: [$t0 => #0] @@ -236,7 +236,7 @@ public fun M::g($t0: &signer) { # #root # # - 4: move_to($t0, $t1) + 4: move_to<0x42::M::R>($t0, $t1) # abort state: {returns} # live vars: # refs: [] @@ -247,8 +247,8 @@ public fun M::g($t0: &signer) { ============ after AbilityProcessor: ================ [variant baseline] -public fun M::f($t0: M::R): (M::R, u64) { - var $t1: M::R +public fun M::f($t0: 0x42::M::R): (0x42::M::R, u64) { + var $t1: 0x42::M::R var $t2: u64 0: $t1 := move($t0) 1: $t2 := 0 @@ -258,13 +258,13 @@ public fun M::f($t0: M::R): (M::R, u64) { [variant baseline] public fun M::g($t0: &signer) { - var $t1: M::R + var $t1: 0x42::M::R var $t2: u64 var $t3: u64 0: $t2 := 1 - 1: $t1 := pack M::R($t2) + 1: $t1 := pack 0x42::M::R($t2) 2: $t3 := 3 3: ($t1, $t3) := M::f($t1) - 4: move_to($t0, $t1) + 4: move_to<0x42::M::R>($t0, $t1) 5: return () } diff --git a/third_party/move/move-compiler-v2/tests/ability-transform/mutate_vector.exp b/third_party/move/move-compiler-v2/tests/ability-transform/mutate_vector.exp index 358ffa25771a9..7259af56e7847 100644 --- a/third_party/move/move-compiler-v2/tests/ability-transform/mutate_vector.exp +++ b/third_party/move/move-compiler-v2/tests/ability-transform/mutate_vector.exp @@ -1,16 +1,16 @@ ============ initial bytecode ================ [variant baseline] -public fun m::new_scalar_from_u8($t0: u8): m::Scalar { - var $t1: m::Scalar - var $t2: m::Scalar +public fun m::new_scalar_from_u8($t0: u8): 0x42::m::Scalar { + var $t1: 0x42::m::Scalar + var $t2: 0x42::m::Scalar var $t3: &mut u8 var $t4: &mut vector - var $t5: &mut m::Scalar + var $t5: &mut 0x42::m::Scalar var $t6: u64 0: $t2 := m::scalar_zero() 1: $t5 := borrow_local($t2) - 2: $t4 := borrow_field.data($t5) + 2: $t4 := borrow_field<0x42::m::Scalar>.data($t5) 3: $t6 := 0 4: $t3 := vector::borrow_mut($t4, $t6) 5: write_ref($t3, $t0) @@ -20,30 +20,30 @@ public fun m::new_scalar_from_u8($t0: u8): m::Scalar { [variant baseline] -public fun m::scalar_zero(): m::Scalar { - var $t0: m::Scalar +public fun m::scalar_zero(): 0x42::m::Scalar { + var $t0: 0x42::m::Scalar var $t1: vector 0: $t1 := [0] - 1: $t0 := pack m::Scalar($t1) + 1: $t0 := pack 0x42::m::Scalar($t1) 2: return $t0 } ============ after LiveVarAnalysisProcessor: ================ [variant baseline] -public fun m::new_scalar_from_u8($t0: u8): m::Scalar { - var $t1: m::Scalar - var $t2: m::Scalar +public fun m::new_scalar_from_u8($t0: u8): 0x42::m::Scalar { + var $t1: 0x42::m::Scalar + var $t2: 0x42::m::Scalar var $t3: &mut u8 var $t4: &mut vector - var $t5: &mut m::Scalar + var $t5: &mut 0x42::m::Scalar var $t6: u64 # live vars: $t0 0: $t2 := m::scalar_zero() # live vars: $t0, $t2 1: $t5 := borrow_local($t2) # live vars: $t0, $t2, $t5 - 2: $t4 := borrow_field.data($t5) + 2: $t4 := borrow_field<0x42::m::Scalar>.data($t5) # live vars: $t0, $t2, $t4 3: $t6 := 0 # live vars: $t0, $t2, $t4, $t6 @@ -58,13 +58,13 @@ public fun m::new_scalar_from_u8($t0: u8): m::Scalar { [variant baseline] -public fun m::scalar_zero(): m::Scalar { - var $t0: m::Scalar +public fun m::scalar_zero(): 0x42::m::Scalar { + var $t0: 0x42::m::Scalar var $t1: vector # live vars: 0: $t1 := [0] # live vars: $t1 - 1: $t0 := pack m::Scalar($t1) + 1: $t0 := pack 0x42::m::Scalar($t1) # live vars: $t0 2: return $t0 } @@ -72,19 +72,19 @@ public fun m::scalar_zero(): m::Scalar { ============ after LiveVarAnalysisProcessor: ================ [variant baseline] -public fun m::new_scalar_from_u8($t0: u8): m::Scalar { - var $t1: m::Scalar - var $t2: m::Scalar +public fun m::new_scalar_from_u8($t0: u8): 0x42::m::Scalar { + var $t1: 0x42::m::Scalar + var $t2: 0x42::m::Scalar var $t3: &mut u8 var $t4: &mut vector - var $t5: &mut m::Scalar + var $t5: &mut 0x42::m::Scalar var $t6: u64 # live vars: $t0 0: $t2 := m::scalar_zero() # live vars: $t0, $t2 1: $t5 := borrow_local($t2) # live vars: $t0, $t2, $t5 - 2: $t4 := borrow_field.data($t5) + 2: $t4 := borrow_field<0x42::m::Scalar>.data($t5) # live vars: $t0, $t2, $t4 3: $t6 := 0 # live vars: $t0, $t2, $t4, $t6 @@ -99,13 +99,13 @@ public fun m::new_scalar_from_u8($t0: u8): m::Scalar { [variant baseline] -public fun m::scalar_zero(): m::Scalar { - var $t0: m::Scalar +public fun m::scalar_zero(): 0x42::m::Scalar { + var $t0: 0x42::m::Scalar var $t1: vector # live vars: 0: $t1 := [0] # live vars: $t1 - 1: $t0 := pack m::Scalar($t1) + 1: $t0 := pack 0x42::m::Scalar($t1) # live vars: $t0 2: return $t0 } @@ -113,12 +113,12 @@ public fun m::scalar_zero(): m::Scalar { ============ after ReferenceSafetyProcessor: ================ [variant baseline] -public fun m::new_scalar_from_u8($t0: u8): m::Scalar { - var $t1: m::Scalar - var $t2: m::Scalar +public fun m::new_scalar_from_u8($t0: u8): 0x42::m::Scalar { + var $t1: 0x42::m::Scalar + var $t2: 0x42::m::Scalar var $t3: &mut u8 var $t4: &mut vector - var $t5: &mut m::Scalar + var $t5: &mut 0x42::m::Scalar var $t6: u64 # live vars: $t0 # refs: [] @@ -135,7 +135,7 @@ public fun m::new_scalar_from_u8($t0: u8): m::Scalar { # #root # => (mut) #5 via [local `s`] at line 11 # - 2: $t4 := borrow_field.data($t5) + 2: $t4 := borrow_field<0x42::m::Scalar>.data($t5) # live vars: $t0, $t2, $t4 # refs: [$t4 => #4] # #4 @@ -172,8 +172,8 @@ public fun m::new_scalar_from_u8($t0: u8): m::Scalar { [variant baseline] -public fun m::scalar_zero(): m::Scalar { - var $t0: m::Scalar +public fun m::scalar_zero(): 0x42::m::Scalar { + var $t0: 0x42::m::Scalar var $t1: vector # live vars: # refs: [] @@ -182,7 +182,7 @@ public fun m::scalar_zero(): m::Scalar { # live vars: $t1 # refs: [] # - 1: $t0 := pack m::Scalar($t1) + 1: $t0 := pack 0x42::m::Scalar($t1) # live vars: $t0 # refs: [] # @@ -192,12 +192,12 @@ public fun m::scalar_zero(): m::Scalar { ============ after AbortAnalysisProcessor: ================ [variant baseline] -public fun m::new_scalar_from_u8($t0: u8): m::Scalar { - var $t1: m::Scalar - var $t2: m::Scalar +public fun m::new_scalar_from_u8($t0: u8): 0x42::m::Scalar { + var $t1: 0x42::m::Scalar + var $t2: 0x42::m::Scalar var $t3: &mut u8 var $t4: &mut vector - var $t5: &mut m::Scalar + var $t5: &mut 0x42::m::Scalar var $t6: u64 # abort state: {returns,aborts} # live vars: $t0 @@ -217,7 +217,7 @@ public fun m::new_scalar_from_u8($t0: u8): m::Scalar { # #root # => (mut) #5 via [local `s`] at line 11 # - 2: $t4 := borrow_field.data($t5) + 2: $t4 := borrow_field<0x42::m::Scalar>.data($t5) # abort state: {returns,aborts} # live vars: $t0, $t2, $t4 # refs: [$t4 => #4] @@ -259,8 +259,8 @@ public fun m::new_scalar_from_u8($t0: u8): m::Scalar { [variant baseline] -public fun m::scalar_zero(): m::Scalar { - var $t0: m::Scalar +public fun m::scalar_zero(): 0x42::m::Scalar { + var $t0: 0x42::m::Scalar var $t1: vector # abort state: {returns} # live vars: @@ -271,7 +271,7 @@ public fun m::scalar_zero(): m::Scalar { # live vars: $t1 # refs: [] # - 1: $t0 := pack m::Scalar($t1) + 1: $t0 := pack 0x42::m::Scalar($t1) # abort state: {returns} # live vars: $t0 # refs: [] @@ -282,16 +282,16 @@ public fun m::scalar_zero(): m::Scalar { ============ after AbilityProcessor: ================ [variant baseline] -public fun m::new_scalar_from_u8($t0: u8): m::Scalar { - var $t1: m::Scalar - var $t2: m::Scalar +public fun m::new_scalar_from_u8($t0: u8): 0x42::m::Scalar { + var $t1: 0x42::m::Scalar + var $t2: 0x42::m::Scalar var $t3: &mut u8 var $t4: &mut vector - var $t5: &mut m::Scalar + var $t5: &mut 0x42::m::Scalar var $t6: u64 0: $t2 := m::scalar_zero() 1: $t5 := borrow_local($t2) - 2: $t4 := borrow_field.data($t5) + 2: $t4 := borrow_field<0x42::m::Scalar>.data($t5) 3: $t6 := 0 4: $t3 := vector::borrow_mut($t4, $t6) 5: write_ref($t3, $t0) @@ -301,10 +301,10 @@ public fun m::new_scalar_from_u8($t0: u8): m::Scalar { [variant baseline] -public fun m::scalar_zero(): m::Scalar { - var $t0: m::Scalar +public fun m::scalar_zero(): 0x42::m::Scalar { + var $t0: 0x42::m::Scalar var $t1: vector 0: $t1 := [0] - 1: $t0 := pack m::Scalar($t1) + 1: $t0 := pack 0x42::m::Scalar($t1) 2: return $t0 } diff --git a/third_party/move/move-compiler-v2/tests/abort-analysis/drop_on_abort.exp b/third_party/move/move-compiler-v2/tests/abort-analysis/drop_on_abort.exp index 702e8dcfb42c3..95b75cc0831fd 100644 --- a/third_party/move/move-compiler-v2/tests/abort-analysis/drop_on_abort.exp +++ b/third_party/move/move-compiler-v2/tests/abort-analysis/drop_on_abort.exp @@ -1,8 +1,8 @@ ============ initial bytecode ================ [variant baseline] -public fun m::from_vec<#0>($t0: vector<#0>): m::Option<#0> { - var $t1: m::Option<#0> +public fun m::from_vec<#0>($t0: vector<#0>): 0x42::m::Option<#0> { + var $t1: 0x42::m::Option<#0> var $t2: bool var $t3: u64 var $t4: &vector<#0> @@ -19,15 +19,15 @@ public fun m::from_vec<#0>($t0: vector<#0>): m::Option<#0> { 8: goto 10 9: label L1 10: label L2 - 11: $t1 := pack m::Option<#0>($t0) + 11: $t1 := pack 0x42::m::Option<#0>($t0) 12: return $t1 } ============ after AbortAnalysisProcessor: ================ [variant baseline] -public fun m::from_vec<#0>($t0: vector<#0>): m::Option<#0> { - var $t1: m::Option<#0> +public fun m::from_vec<#0>($t0: vector<#0>): 0x42::m::Option<#0> { + var $t1: 0x42::m::Option<#0> var $t2: bool var $t3: u64 var $t4: &vector<#0> @@ -94,7 +94,7 @@ public fun m::from_vec<#0>($t0: vector<#0>): m::Option<#0> { # live vars: $t0 # refs: [] # - 11: $t1 := pack m::Option<#0>($t0) + 11: $t1 := pack 0x42::m::Option<#0>($t0) # abort state: {returns} # live vars: $t1 # refs: [] diff --git a/third_party/move/move-compiler-v2/tests/abort-analysis/loop_abort.exp b/third_party/move/move-compiler-v2/tests/abort-analysis/loop_abort.exp index 931538cfa9bf7..2e42d922264cd 100644 --- a/third_party/move/move-compiler-v2/tests/abort-analysis/loop_abort.exp +++ b/third_party/move/move-compiler-v2/tests/abort-analysis/loop_abort.exp @@ -2,10 +2,10 @@ [variant baseline] fun Test::test0() { - var $t0: Test::Impotent + var $t0: 0x42::Test::Impotent var $t1: bool 0: $t1 := false - 1: $t0 := pack Test::Impotent($t1) + 1: $t0 := pack 0x42::Test::Impotent($t1) 2: label L0 3: goto 2 4: label L1 @@ -15,11 +15,11 @@ fun Test::test0() { [variant baseline] fun Test::test1() { - var $t0: Test::Impotent + var $t0: 0x42::Test::Impotent var $t1: bool var $t2: bool 0: $t1 := false - 1: $t0 := pack Test::Impotent($t1) + 1: $t0 := pack 0x42::Test::Impotent($t1) 2: label L0 3: $t2 := true 4: if ($t2) goto 5 else goto 7 @@ -36,11 +36,11 @@ fun Test::test1() { [variant baseline] fun Test::test2($t0: bool) { - var $t1: Test::Impotent + var $t1: 0x42::Test::Impotent var $t2: bool var $t3: u64 0: $t2 := false - 1: $t1 := pack Test::Impotent($t2) + 1: $t1 := pack 0x42::Test::Impotent($t2) 2: if ($t0) goto 3 else goto 8 3: label L0 4: label L3 @@ -58,7 +58,7 @@ fun Test::test2($t0: bool) { [variant baseline] fun Test::test0() { - var $t0: Test::Impotent + var $t0: 0x42::Test::Impotent var $t1: bool # abort state: {} # live vars: @@ -69,7 +69,7 @@ fun Test::test0() { # live vars: $t1 # refs: [] # - 1: $t0 := pack Test::Impotent($t1) + 1: $t0 := pack 0x42::Test::Impotent($t1) # abort state: {} # live vars: # refs: [] @@ -91,7 +91,7 @@ fun Test::test0() { [variant baseline] fun Test::test1() { - var $t0: Test::Impotent + var $t0: 0x42::Test::Impotent var $t1: bool var $t2: bool # abort state: {returns} @@ -103,7 +103,7 @@ fun Test::test1() { # live vars: $t1 # refs: [] # - 1: $t0 := pack Test::Impotent($t1) + 1: $t0 := pack 0x42::Test::Impotent($t1) # abort state: {returns} # live vars: # refs: [] @@ -164,7 +164,7 @@ fun Test::test1() { [variant baseline] fun Test::test2($t0: bool) { - var $t1: Test::Impotent + var $t1: 0x42::Test::Impotent var $t2: bool var $t3: u64 # abort state: {aborts} @@ -176,7 +176,7 @@ fun Test::test2($t0: bool) { # live vars: $t0, $t2 # refs: [] # - 1: $t1 := pack Test::Impotent($t2) + 1: $t1 := pack 0x42::Test::Impotent($t2) # abort state: {aborts} # live vars: $t0 # refs: [] diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/assign.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/assign.exp index 61a31095ee499..3c08a832d5864 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/assign.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/assign.exp @@ -5,32 +5,56 @@ module 0x42::assign { } struct S { f: u64, - g: assign::T, + g: 0x42::assign::T, } - private fun assign_field(s: &mut assign::S,f: u64) { - select assign::S.f<&mut assign::S>(s) = f; + private fun assign_field(s: &mut 0x42::assign::S,f: u64) { + select assign::S.f<&mut S>(s) = f; Tuple() } private fun assign_int(x: &mut u64) { x = 42; Tuple() } - private fun assign_pattern(s: assign::S,f: u64,h: u64): u64 { + private fun assign_pattern(s: 0x42::assign::S,f: u64,h: u64): u64 { assign::S{ f, g: assign::T{ h } } = s; Add(f, h) } - private fun assign_struct(s: &mut assign::S) { + private fun assign_struct(s: &mut 0x42::assign::S) { s = pack assign::S(42, pack assign::T(42)); Tuple() } } // end 0x42::assign +// -- Sourcified model before bytecode pipeline +module 0x42::assign { + struct T has drop { + h: u64, + } + struct S has drop { + f: u64, + g: T, + } + fun assign_field(s: &mut S, f: u64) { + s.f = f; + } + fun assign_int(x: &mut u64) { + *x = 42; + } + fun assign_pattern(s: S, f: u64, h: u64): u64 { + S{f: f,g: T{h: h}} = s; + f + h + } + fun assign_struct(s: &mut S) { + *s = S{f: 42,g: T{h: 42}}; + } +} + ============ initial bytecode ================ [variant baseline] -fun assign::assign_field($t0: &mut assign::S, $t1: u64) { +fun assign::assign_field($t0: &mut 0x42::assign::S, $t1: u64) { var $t2: &mut u64 - 0: $t2 := borrow_field.f($t0) + 0: $t2 := borrow_field<0x42::assign::S>.f($t0) 1: write_ref($t2, $t1) 2: return () } @@ -46,26 +70,26 @@ fun assign::assign_int($t0: &mut u64) { [variant baseline] -fun assign::assign_pattern($t0: assign::S, $t1: u64, $t2: u64): u64 { +fun assign::assign_pattern($t0: 0x42::assign::S, $t1: u64, $t2: u64): u64 { var $t3: u64 - var $t4: assign::T - 0: ($t1, $t4) := unpack assign::S($t0) - 1: $t2 := unpack assign::T($t4) + var $t4: 0x42::assign::T + 0: ($t1, $t4) := unpack 0x42::assign::S($t0) + 1: $t2 := unpack 0x42::assign::T($t4) 2: $t3 := +($t1, $t2) 3: return $t3 } [variant baseline] -fun assign::assign_struct($t0: &mut assign::S) { - var $t1: assign::S +fun assign::assign_struct($t0: &mut 0x42::assign::S) { + var $t1: 0x42::assign::S var $t2: u64 - var $t3: assign::T + var $t3: 0x42::assign::T var $t4: u64 0: $t2 := 42 1: $t4 := 42 - 2: $t3 := pack assign::T($t4) - 3: $t1 := pack assign::S($t2, $t3) + 2: $t3 := pack 0x42::assign::T($t4) + 3: $t1 := pack 0x42::assign::S($t2, $t3) 4: write_ref($t0, $t1) 5: return () } diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/assign_inline.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/assign_inline.exp index 29e5c85a6a3a8..4a09468c4d890 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/assign_inline.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/assign_inline.exp @@ -8,6 +8,16 @@ module 0x42::assign { } } // end 0x42::assign +// -- Sourcified model before bytecode pipeline +module 0x42::assign { + public inline fun expose(x: u64): (u64, u64) { + (1, x) + } + public fun main(): (u64, u64) { + (1, 3) + } +} + ============ initial bytecode ================ [variant baseline] diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/borrow.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/borrow.exp index 1c64fb91482d1..aa5da65f26753 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/borrow.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/borrow.exp @@ -17,9 +17,9 @@ module 0x42::borrow { struct S { f: u64, } - private fun field(s: &borrow::S): u64 { + private fun field(s: &0x42::borrow::S): u64 { { - let r: &u64 = Borrow(Immutable)(select borrow::S.f<&borrow::S>(s)); + let r: &u64 = Borrow(Immutable)(select borrow::S.f<&S>(s)); Deref(r) } } @@ -35,9 +35,9 @@ module 0x42::borrow { Deref(r) } } - private fun mut_field(s: &mut borrow::S): u64 { + private fun mut_field(s: &mut 0x42::borrow::S): u64 { { - let r: &mut u64 = Borrow(Mutable)(select borrow::S.f<&mut borrow::S>(s)); + let r: &mut u64 = Borrow(Mutable)(select borrow::S.f<&mut S>(s)); r = 22; Deref(r) } @@ -61,13 +61,48 @@ module 0x42::borrow { } } // end 0x42::borrow +// -- Sourcified model before bytecode pipeline +module 0x42::borrow { + struct S { + f: u64, + } + fun field(s: &S): u64 { + let r = &s.f; + *r + } + fun local(param: u64): u64 { + let r = &33; + *r + } + fun param(param: u64): u64 { + let r = ¶m; + *r + } + fun mut_field(s: &mut S): u64 { + let r = &mut s.f; + *r = 22; + *r + } + fun mut_local(param: u64): u64 { + let local = 33; + let r = &mut local; + *r = 22; + *r + } + fun mut_param(param: u64): u64 { + let r = &mut param; + *r = 22; + *r + } +} + ============ initial bytecode ================ [variant baseline] -fun borrow::field($t0: &borrow::S): u64 { +fun borrow::field($t0: &0x42::borrow::S): u64 { var $t1: u64 var $t2: &u64 - 0: $t2 := borrow_field.f($t0) + 0: $t2 := borrow_field<0x42::borrow::S>.f($t0) 1: $t1 := read_ref($t2) 2: return $t1 } @@ -96,11 +131,11 @@ fun borrow::param($t0: u64): u64 { [variant baseline] -fun borrow::mut_field($t0: &mut borrow::S): u64 { +fun borrow::mut_field($t0: &mut 0x42::borrow::S): u64 { var $t1: u64 var $t2: &mut u64 var $t3: u64 - 0: $t2 := borrow_field.f($t0) + 0: $t2 := borrow_field<0x42::borrow::S>.f($t0) 1: $t3 := 22 2: write_ref($t2, $t3) 3: $t1 := read_ref($t2) diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/borrow_deref_optimize.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/borrow_deref_optimize.exp index a80f9f4e4a890..ae6515bb0501c 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/borrow_deref_optimize.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/borrow_deref_optimize.exp @@ -4,11 +4,11 @@ module 0x42::test { value: bool, } private fun no_optimize_resource(): bool - acquires test::X(*) + acquires 0x42::test::X(*) { { - let x: &mut test::X = Borrow(Mutable)(Deref(BorrowGlobal(Immutable)(0x1))); - select test::X.value<&mut test::X>(x) + let x: &mut X = Borrow(Mutable)(Deref(BorrowGlobal(Immutable)(0x1))); + select test::X.value<&mut X>(x) } } private fun no_optimize_vector() { @@ -18,11 +18,11 @@ module 0x42::test { } } private fun optimize_resource(): bool - acquires test::X(*) + acquires 0x42::test::X(*) { { - let x: &test::X = Borrow(Immutable)(Deref(BorrowGlobal(Immutable)(0x1))); - select test::X.value<&test::X>(x) + let x: &X = Borrow(Immutable)(Deref(BorrowGlobal(Immutable)(0x1))); + select test::X.value<&X>(x) } } private fun optimize_vector() { @@ -36,21 +36,47 @@ module 0x42::test { } } // end 0x42::test +// -- Sourcified model before bytecode pipeline +module 0x42::test { + struct X has copy, drop, key { + value: bool, + } + fun no_optimize_resource(): bool + acquires X + { + let x = &mut *borrow_global(0x1); + x.value + } + fun no_optimize_vector() { + let _ = 0x1::vector::borrow_mut(&mut *0x1::vector::borrow>(&vector[vector[1, 2]], 0), 1); + } + fun optimize_resource(): bool + acquires X + { + let x = &*borrow_global(0x1); + x.value + } + fun optimize_vector() { + let x = vector[vector[1, 2]]; + let _ = 0x1::vector::borrow_mut(&mut *0x1::vector::borrow_mut>(&mut x, 0), 1); + } +} + ============ initial bytecode ================ [variant baseline] fun test::no_optimize_resource(): bool { var $t0: bool - var $t1: &mut test::X - var $t2: test::X - var $t3: &test::X + var $t1: &mut 0x42::test::X + var $t2: 0x42::test::X + var $t3: &0x42::test::X var $t4: address var $t5: &bool 0: $t4 := 0x1 - 1: $t3 := borrow_global($t4) + 1: $t3 := borrow_global<0x42::test::X>($t4) 2: $t2 := read_ref($t3) 3: $t1 := borrow_local($t2) - 4: $t5 := borrow_field.value($t1) + 4: $t5 := borrow_field<0x42::test::X>.value($t1) 5: $t0 := read_ref($t5) 6: return $t0 } @@ -83,12 +109,12 @@ fun test::no_optimize_vector() { [variant baseline] fun test::optimize_resource(): bool { var $t0: bool - var $t1: &test::X + var $t1: &0x42::test::X var $t2: address var $t3: &bool 0: $t2 := 0x1 - 1: $t1 := borrow_global($t2) - 2: $t3 := borrow_field.value($t1) + 1: $t1 := borrow_global<0x42::test::X>($t2) + 2: $t3 := borrow_field<0x42::test::X>.value($t1) 3: $t0 := read_ref($t3) 4: return $t0 } diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/bug_14300_update_variant_select.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/bug_14300_update_variant_select.exp index 0a25e2fb1e722..453eb08801151 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/bug_14300_update_variant_select.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/bug_14300_update_variant_select.exp @@ -16,51 +16,84 @@ module 0x815::m { } private fun update_common_field(): u64 { { - let common: m::CommonFields = pack m::CommonFields::Bar(30, 40, 50); - select_variants m::CommonFields.Foo.x|m::CommonFields.Bar.x(common) = 15; - select_variants m::CommonFields.Foo.x|m::CommonFields.Bar.x(common) + let common: CommonFields = pack m::CommonFields::Bar(30, 40, 50); + select_variants m::CommonFields.Foo.x|m::CommonFields.Bar.x(common) = 15; + select_variants m::CommonFields.Foo.x|m::CommonFields.Bar.x(common) } } private fun update_common_field_different_offset(): u8 { { - let common: m::CommonFields = pack m::CommonFields::Bar(30, 40, 50); - select_variants m::CommonFields.Foo.y|m::CommonFields.Bar.y|m::CommonFields.Baz.y(common) = 15; - select_variants m::CommonFields.Foo.y|m::CommonFields.Bar.y|m::CommonFields.Baz.y(common) + let common: CommonFields = pack m::CommonFields::Bar(30, 40, 50); + select_variants m::CommonFields.Foo.y|m::CommonFields.Bar.y|m::CommonFields.Baz.y(common) = 15; + select_variants m::CommonFields.Foo.y|m::CommonFields.Bar.y|m::CommonFields.Baz.y(common) } } private fun update_non_common_field(): u32 { { - let common: m::CommonFields = pack m::CommonFields::Bar(30, 40, 50); - select_variants m::CommonFields.Bar.z(common) = 15; - select_variants m::CommonFields.Bar.z(common) + let common: CommonFields = pack m::CommonFields::Bar(30, 40, 50); + select_variants m::CommonFields.Bar.z(common) = 15; + select_variants m::CommonFields.Bar.z(common) } } } // end 0x815::m +// -- Sourcified model before bytecode pipeline +module 0x815::m { + enum CommonFields has drop { + Foo { + x: u64, + y: u8, + } + Bar { + x: u64, + y: u8, + z: u32, + } + Baz { + y: u8, + } + } + fun update_common_field(): u64 { + let common = CommonFields::Bar{x: 30,y: 40u8,z: 50u32}; + common.Foo.x = 15; + common.Foo.x + } + fun update_common_field_different_offset(): u8 { + let common = CommonFields::Bar{x: 30,y: 40u8,z: 50u32}; + common.Foo.y = 15u8; + common.Foo.y + } + fun update_non_common_field(): u32 { + let common = CommonFields::Bar{x: 30,y: 40u8,z: 50u32}; + common.Bar.z = 15u32; + common.Bar.z + } +} + ============ initial bytecode ================ [variant baseline] fun m::update_common_field(): u64 { var $t0: u64 - var $t1: m::CommonFields + var $t1: 0x815::m::CommonFields var $t2: u64 var $t3: u8 var $t4: u32 var $t5: u64 var $t6: &mut u64 - var $t7: &mut m::CommonFields - var $t8: &m::CommonFields + var $t7: &mut 0x815::m::CommonFields + var $t8: &0x815::m::CommonFields var $t9: &u64 0: $t2 := 30 1: $t3 := 40 2: $t4 := 50 - 3: $t1 := pack_variant m::CommonFields::Bar($t2, $t3, $t4) + 3: $t1 := pack_variant 0x815::m::CommonFields::Bar($t2, $t3, $t4) 4: $t5 := 15 5: $t7 := borrow_local($t1) - 6: $t6 := borrow_variant_field.x($t7) + 6: $t6 := borrow_variant_field<0x815::m::CommonFields::Foo|Bar>.x($t7) 7: write_ref($t6, $t5) 8: $t8 := borrow_local($t1) - 9: $t9 := borrow_variant_field.x($t8) + 9: $t9 := borrow_variant_field<0x815::m::CommonFields::Foo|Bar>.x($t8) 10: $t0 := read_ref($t9) 11: return $t0 } @@ -69,50 +102,50 @@ fun m::update_common_field(): u64 { [variant baseline] fun m::update_common_field_different_offset(): u8 { var $t0: u8 - var $t1: m::CommonFields + var $t1: 0x815::m::CommonFields var $t2: u64 var $t3: u8 var $t4: u32 var $t5: u8 var $t6: &mut u8 - var $t7: &mut m::CommonFields + var $t7: &mut 0x815::m::CommonFields var $t8: bool - var $t9: &m::CommonFields + var $t9: &0x815::m::CommonFields var $t10: &u8 var $t11: bool 0: $t2 := 30 1: $t3 := 40 2: $t4 := 50 - 3: $t1 := pack_variant m::CommonFields::Bar($t2, $t3, $t4) + 3: $t1 := pack_variant 0x815::m::CommonFields::Bar($t2, $t3, $t4) 4: $t5 := 15 5: $t7 := borrow_local($t1) - 6: $t8 := test_variant m::CommonFields::Foo($t7) + 6: $t8 := test_variant 0x815::m::CommonFields::Foo($t7) 7: if ($t8) goto 13 else goto 8 8: label L3 - 9: $t8 := test_variant m::CommonFields::Bar($t7) + 9: $t8 := test_variant 0x815::m::CommonFields::Bar($t7) 10: if ($t8) goto 13 else goto 11 11: label L4 12: goto 16 13: label L2 - 14: $t6 := borrow_variant_field.y($t7) + 14: $t6 := borrow_variant_field<0x815::m::CommonFields::Foo|Bar>.y($t7) 15: goto 18 16: label L1 - 17: $t6 := borrow_variant_field.y($t7) + 17: $t6 := borrow_variant_field<0x815::m::CommonFields::Baz>.y($t7) 18: label L0 19: write_ref($t6, $t5) 20: $t9 := borrow_local($t1) - 21: $t11 := test_variant m::CommonFields::Foo($t9) + 21: $t11 := test_variant 0x815::m::CommonFields::Foo($t9) 22: if ($t11) goto 28 else goto 23 23: label L8 - 24: $t11 := test_variant m::CommonFields::Bar($t9) + 24: $t11 := test_variant 0x815::m::CommonFields::Bar($t9) 25: if ($t11) goto 28 else goto 26 26: label L9 27: goto 31 28: label L7 - 29: $t10 := borrow_variant_field.y($t9) + 29: $t10 := borrow_variant_field<0x815::m::CommonFields::Foo|Bar>.y($t9) 30: goto 33 31: label L6 - 32: $t10 := borrow_variant_field.y($t9) + 32: $t10 := borrow_variant_field<0x815::m::CommonFields::Baz>.y($t9) 33: label L5 34: $t0 := read_ref($t10) 35: return $t0 @@ -122,25 +155,25 @@ fun m::update_common_field_different_offset(): u8 { [variant baseline] fun m::update_non_common_field(): u32 { var $t0: u32 - var $t1: m::CommonFields + var $t1: 0x815::m::CommonFields var $t2: u64 var $t3: u8 var $t4: u32 var $t5: u32 var $t6: &mut u32 - var $t7: &mut m::CommonFields - var $t8: &m::CommonFields + var $t7: &mut 0x815::m::CommonFields + var $t8: &0x815::m::CommonFields var $t9: &u32 0: $t2 := 30 1: $t3 := 40 2: $t4 := 50 - 3: $t1 := pack_variant m::CommonFields::Bar($t2, $t3, $t4) + 3: $t1 := pack_variant 0x815::m::CommonFields::Bar($t2, $t3, $t4) 4: $t5 := 15 5: $t7 := borrow_local($t1) - 6: $t6 := borrow_variant_field.z($t7) + 6: $t6 := borrow_variant_field<0x815::m::CommonFields::Bar>.z($t7) 7: write_ref($t6, $t5) 8: $t8 := borrow_local($t1) - 9: $t9 := borrow_variant_field.z($t8) + 9: $t9 := borrow_variant_field<0x815::m::CommonFields::Bar>.z($t8) 10: $t0 := read_ref($t9) 11: return $t0 } diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/bug_14300_variant_select_autoref.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/bug_14300_variant_select_autoref.exp index 285f4a28191fe..65b950ae473bf 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/bug_14300_variant_select_autoref.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/bug_14300_variant_select_autoref.exp @@ -10,28 +10,45 @@ module 0x815::m { } private fun test_common_access(): u8 { { - let x: m::Positional = pack m::Positional::A(42); - select_variants m::Positional.A.0|m::Positional.B.0(x) = 19; + let x: Positional = pack m::Positional::A(42); + select_variants m::Positional.A.0|m::Positional.B.0(x) = 19; 20 } } } // end 0x815::m +// -- Sourcified model before bytecode pipeline +module 0x815::m { + enum Positional has drop { + A { + 0: u8, + } + B { + 0: u8, + } + } + fun test_common_access(): u8 { + let x = Positional::A{0: 42u8}; + x.A.0 = 19u8; + 20u8 + } +} + ============ initial bytecode ================ [variant baseline] fun m::test_common_access(): u8 { var $t0: u8 - var $t1: m::Positional + var $t1: 0x815::m::Positional var $t2: u8 var $t3: u8 var $t4: &mut u8 - var $t5: &mut m::Positional + var $t5: &mut 0x815::m::Positional 0: $t2 := 42 - 1: $t1 := pack_variant m::Positional::A($t2) + 1: $t1 := pack_variant 0x815::m::Positional::A($t2) 2: $t3 := 19 3: $t5 := borrow_local($t1) - 4: $t4 := borrow_variant_field.0($t5) + 4: $t4 := borrow_variant_field<0x815::m::Positional::A|B>.0($t5) 5: write_ref($t4, $t3) 6: $t0 := 20 7: return $t0 diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/bug_14471_receiver_inference.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/bug_14471_receiver_inference.exp index c8a13847d8cae..e89706cc35f45 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/bug_14471_receiver_inference.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/bug_14471_receiver_inference.exp @@ -1,7 +1,7 @@ // -- Model dump before bytecode pipeline module 0x815::m { struct MyMap { - table: m::Table, + table: 0x815::m::Table, } struct Table { x: #0, @@ -10,21 +10,21 @@ module 0x815::m { struct ValueWrap { val: u64, } - private fun contains(self: &m::Table<#0, #1>,_key: #0): bool { + private fun contains(self: &0x815::m::Table<#0, #1>,_key: #0): bool { true } - private fun add(self: &mut m::Table<#0, #1>,_key: #0,_val: #1) { + private fun add(self: &mut 0x815::m::Table<#0, #1>,_key: #0,_val: #1) { Tuple() } public fun add_when_missing(key: address,val: u64) - acquires m::MyMap(*) + acquires 0x815::m::MyMap(*) { { - let my_map: &mut m::MyMap = BorrowGlobal(Mutable)(0x815); - if Not(m::contains(Borrow(Immutable)(select m::MyMap.table<&mut m::MyMap>(my_map)), key)) { + let my_map: &mut MyMap = BorrowGlobal(Mutable)(0x815); + if Not(m::contains(Borrow(Immutable)(select m::MyMap.table<&mut MyMap>(my_map)), key)) { { - let wrap: m::ValueWrap = pack m::ValueWrap(val); - m::add(Borrow(Mutable)(select m::MyMap.table<&mut m::MyMap>(my_map)), key, wrap); + let wrap: ValueWrap = pack m::ValueWrap(val); + m::add(Borrow(Mutable)(select m::MyMap.table<&mut MyMap>(my_map)), key, wrap); Tuple() } } else { @@ -34,10 +34,38 @@ module 0x815::m { } } // end 0x815::m +// -- Sourcified model before bytecode pipeline +module 0x815::m { + struct MyMap has key { + table: Table, + } + struct Table has store { + x: T1, + y: T2, + } + struct ValueWrap has drop, store { + val: u64, + } + fun contains(self: &Table, _key: T1): bool { + true + } + fun add(self: &mut Table, _key: T1, _val: T2) { + } + public fun add_when_missing(key: address, val: u64) + acquires MyMap + { + let my_map = borrow_global_mut(0x815); + if (!contains(&my_map.table, key)) { + let wrap = ValueWrap{val: val}; + add(&mut my_map.table, key, wrap); + } + } +} + ============ initial bytecode ================ [variant baseline] -fun m::contains<#0, #1>($t0: &m::Table<#0, #1>, $t1: #0): bool { +fun m::contains<#0, #1>($t0: &0x815::m::Table<#0, #1>, $t1: #0): bool { var $t2: bool 0: $t2 := true 1: return $t2 @@ -45,30 +73,30 @@ fun m::contains<#0, #1>($t0: &m::Table<#0, #1>, $t1: #0): bool { [variant baseline] -fun m::add<#0, #1>($t0: &mut m::Table<#0, #1>, $t1: #0, $t2: #1) { +fun m::add<#0, #1>($t0: &mut 0x815::m::Table<#0, #1>, $t1: #0, $t2: #1) { 0: return () } [variant baseline] public fun m::add_when_missing($t0: address, $t1: u64) { - var $t2: &mut m::MyMap + var $t2: &mut 0x815::m::MyMap var $t3: address var $t4: bool var $t5: bool - var $t6: &m::Table - var $t7: m::ValueWrap - var $t8: &mut m::Table + var $t6: &0x815::m::Table + var $t7: 0x815::m::ValueWrap + var $t8: &mut 0x815::m::Table 0: $t3 := 0x815 - 1: $t2 := borrow_global($t3) - 2: $t6 := borrow_field.table($t2) - 3: $t5 := m::contains($t6, $t0) + 1: $t2 := borrow_global<0x815::m::MyMap>($t3) + 2: $t6 := borrow_field<0x815::m::MyMap>.table($t2) + 3: $t5 := m::contains($t6, $t0) 4: $t4 := !($t5) 5: if ($t4) goto 6 else goto 11 6: label L0 - 7: $t7 := pack m::ValueWrap($t1) - 8: $t8 := borrow_field.table($t2) - 9: m::add($t8, $t0, $t7) + 7: $t7 := pack 0x815::m::ValueWrap($t1) + 8: $t8 := borrow_field<0x815::m::MyMap>.table($t2) + 9: m::add($t8, $t0, $t7) 10: goto 12 11: label L1 12: label L2 diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/conditional_borrow.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/conditional_borrow.exp index 9c7e360aea5b9..ab04f99298c2a 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/conditional_borrow.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/conditional_borrow.exp @@ -47,39 +47,39 @@ module 0x8675::M { } } } - private fun test1b(r: M::S): u64 { + private fun test1b(r: 0x8675::M::S): u64 { { - let x: M::S = pack M::S(3); + let x: S = pack M::S(3); { - let tref: &mut M::S = Borrow(Mutable)(if Lt(select M::S.f(r), 4) { + let tref: &mut S = Borrow(Mutable)(if Lt(select M::S.f(r), 4) { r } else { x }); - select M::S.f(Deref(tref)) = 10; + select M::S.f(Deref(tref)) = 10; { - let y: M::S = r; + let y: S = r; { - let tref2: &mut M::S = Borrow(Mutable)(y); - select M::S.f(Deref(tref2)) = Add(select M::S.f(Deref(tref2)), 1); + let tref2: &mut S = Borrow(Mutable)(y); + select M::S.f(Deref(tref2)) = Add(select M::S.f(Deref(tref2)), 1); { - let z: M::S = y; + let z: S = y; { - let tref3: &mut u64 = Borrow(Mutable)(select M::S.f(z)); + let tref3: &mut u64 = Borrow(Mutable)(select M::S.f(z)); tref3 = Add(Deref(tref3), 1); { - let a: M::S = z; + let a: S = z; { - let tref4: &mut u64 = Borrow(Mutable)(select M::S.f(a)); + let tref4: &mut u64 = Borrow(Mutable)(select M::S.f(a)); tref4 = Add(Deref(tref4), 1); { - let tref5: &mut u64 = Borrow(Mutable)(select M::S.f(a)); + let tref5: &mut u64 = Borrow(Mutable)(select M::S.f(a)); tref5 = Add(Deref(tref5), 8); { let tref6: &mut u64 = Borrow(Mutable)(3; - select M::S.f(a)); + select M::S.f(a)); tref6 = Add(Deref(tref6), 16); - select M::S.f(a) + select M::S.f(a) } } } @@ -96,6 +96,62 @@ module 0x8675::M { } } // end 0x8675::M +// -- Sourcified model before bytecode pipeline +module 0x8675::M { + struct S has copy, drop { + f: u64, + } + public fun test(): u64 { + test1(7) + test1(2) + } + fun test1(r: u64): u64 { + let tref = &mut (if (r < 4) r else 3); + *tref = 10; + let y = r; + let tref2 = &mut y; + *tref2 = *tref2 + 1; + let z = y; + let tref3 = &mut (z + 0); + *tref3 = *tref3 + 2; + let a = z; + let tref4 = &mut a; + *tref4 = *tref4 + 4; + let tref5 = &mut a; + *tref5 = *tref5 + 8; + let tref6 = &mut { + 3; + a + }; + *tref6 = *tref6 + 16; + a + } + fun test1b(r: S): u64 { + let x = S{f: 3}; + let tref = &mut (if (r.f < 4) r else x); + (*tref).f = 10; + let y = r; + let tref2 = &mut y; + (*tref2).f = (*tref2).f + 1; + let z = y; + let tref3 = &mut z.f; + *tref3 = *tref3 + 1; + let a = z; + let tref4 = &mut a.f; + *tref4 = *tref4 + 1; + let tref5 = &mut a.f; + *tref5 = *tref5 + 8; + let tref6 = &mut { + 3; + a.f + }; + *tref6 = *tref6 + 16; + a.f + } + public fun testb(): u64 { + test1b(S{f: 7}) + test1b(S{f: 2}) + } +} + ============ initial bytecode ================ [variant baseline] @@ -203,49 +259,49 @@ fun M::test1($t0: u64): u64 { [variant baseline] -fun M::test1b($t0: M::S): u64 { +fun M::test1b($t0: 0x8675::M::S): u64 { var $t1: u64 - var $t2: M::S + var $t2: 0x8675::M::S var $t3: u64 - var $t4: &mut M::S - var $t5: M::S + var $t4: &mut 0x8675::M::S + var $t5: 0x8675::M::S var $t6: bool var $t7: u64 - var $t8: &M::S + var $t8: &0x8675::M::S var $t9: &u64 var $t10: u64 var $t11: u64 var $t12: &mut u64 - var $t13: M::S - var $t14: &mut M::S - var $t15: M::S - var $t16: &mut M::S + var $t13: 0x8675::M::S + var $t14: &mut 0x8675::M::S + var $t15: 0x8675::M::S + var $t16: &mut 0x8675::M::S var $t17: u64 var $t18: u64 - var $t19: M::S - var $t20: &M::S + var $t19: 0x8675::M::S + var $t20: &0x8675::M::S var $t21: &u64 var $t22: u64 var $t23: &mut u64 - var $t24: M::S - var $t25: &mut M::S - var $t26: M::S + var $t24: 0x8675::M::S + var $t25: &mut 0x8675::M::S + var $t26: 0x8675::M::S var $t27: &mut u64 - var $t28: &mut M::S + var $t28: &mut 0x8675::M::S var $t29: u64 var $t30: u64 var $t31: u64 - var $t32: M::S + var $t32: 0x8675::M::S var $t33: &mut u64 var $t34: u64 - var $t35: &M::S + var $t35: &0x8675::M::S var $t36: &u64 var $t37: u64 var $t38: u64 var $t39: u64 var $t40: &mut u64 var $t41: u64 - var $t42: &M::S + var $t42: &0x8675::M::S var $t43: &u64 var $t44: u64 var $t45: u64 @@ -253,17 +309,17 @@ fun M::test1b($t0: M::S): u64 { var $t47: &mut u64 var $t48: u64 var $t49: u64 - var $t50: &M::S + var $t50: &0x8675::M::S var $t51: &u64 var $t52: u64 var $t53: u64 var $t54: u64 - var $t55: &M::S + var $t55: &0x8675::M::S var $t56: &u64 0: $t3 := 3 - 1: $t2 := pack M::S($t3) + 1: $t2 := pack 0x8675::M::S($t3) 2: $t8 := borrow_local($t0) - 3: $t9 := borrow_field.f($t8) + 3: $t9 := borrow_field<0x8675::M::S>.f($t8) 4: $t7 := read_ref($t9) 5: $t10 := 4 6: $t6 := <($t7, $t10) @@ -278,30 +334,30 @@ fun M::test1b($t0: M::S): u64 { 15: $t11 := 10 16: $t13 := read_ref($t4) 17: $t14 := borrow_local($t13) - 18: $t12 := borrow_field.f($t14) + 18: $t12 := borrow_field<0x8675::M::S>.f($t14) 19: write_ref($t12, $t11) 20: $t15 := infer($t0) 21: $t16 := borrow_local($t15) 22: $t19 := read_ref($t16) 23: $t20 := borrow_local($t19) - 24: $t21 := borrow_field.f($t20) + 24: $t21 := borrow_field<0x8675::M::S>.f($t20) 25: $t18 := read_ref($t21) 26: $t22 := 1 27: $t17 := +($t18, $t22) 28: $t24 := read_ref($t16) 29: $t25 := borrow_local($t24) - 30: $t23 := borrow_field.f($t25) + 30: $t23 := borrow_field<0x8675::M::S>.f($t25) 31: write_ref($t23, $t17) 32: $t26 := infer($t15) 33: $t28 := borrow_local($t26) - 34: $t27 := borrow_field.f($t28) + 34: $t27 := borrow_field<0x8675::M::S>.f($t28) 35: $t30 := read_ref($t27) 36: $t31 := 1 37: $t29 := +($t30, $t31) 38: write_ref($t27, $t29) 39: $t32 := infer($t26) 40: $t35 := borrow_local($t32) - 41: $t36 := borrow_field.f($t35) + 41: $t36 := borrow_field<0x8675::M::S>.f($t35) 42: $t34 := read_ref($t36) 43: $t33 := borrow_local($t34) 44: $t38 := read_ref($t33) @@ -309,7 +365,7 @@ fun M::test1b($t0: M::S): u64 { 46: $t37 := +($t38, $t39) 47: write_ref($t33, $t37) 48: $t42 := borrow_local($t32) - 49: $t43 := borrow_field.f($t42) + 49: $t43 := borrow_field<0x8675::M::S>.f($t42) 50: $t41 := read_ref($t43) 51: $t40 := borrow_local($t41) 52: $t45 := read_ref($t40) @@ -318,7 +374,7 @@ fun M::test1b($t0: M::S): u64 { 55: write_ref($t40, $t44) 56: $t49 := 3 57: $t50 := borrow_local($t32) - 58: $t51 := borrow_field.f($t50) + 58: $t51 := borrow_field<0x8675::M::S>.f($t50) 59: $t48 := read_ref($t51) 60: $t47 := borrow_local($t48) 61: $t53 := read_ref($t47) @@ -326,7 +382,7 @@ fun M::test1b($t0: M::S): u64 { 63: $t52 := +($t53, $t54) 64: write_ref($t47, $t52) 65: $t55 := borrow_local($t32) - 66: $t56 := borrow_field.f($t55) + 66: $t56 := borrow_field<0x8675::M::S>.f($t55) 67: $t1 := read_ref($t56) 68: return $t1 } @@ -336,16 +392,16 @@ fun M::test1b($t0: M::S): u64 { public fun M::testb(): u64 { var $t0: u64 var $t1: u64 - var $t2: M::S + var $t2: 0x8675::M::S var $t3: u64 var $t4: u64 - var $t5: M::S + var $t5: 0x8675::M::S var $t6: u64 0: $t3 := 7 - 1: $t2 := pack M::S($t3) + 1: $t2 := pack 0x8675::M::S($t3) 2: $t1 := M::test1b($t2) 3: $t6 := 2 - 4: $t5 := pack M::S($t6) + 4: $t5 := pack 0x8675::M::S($t6) 5: $t4 := M::test1b($t5) 6: $t0 := +($t1, $t4) 7: return $t0 diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/escape_autoref.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/escape_autoref.exp index 3dfca1c2c5e39..a40f32b864ff6 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/escape_autoref.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/escape_autoref.exp @@ -6,32 +6,59 @@ module 0x42::m { struct ObjectCore { owner: address, } - private fun make(): m::Object { + private fun make(): 0x42::m::Object { Abort(0) } - private fun owner_correct(o: m::Object): address - acquires m::ObjectCore(*) + private fun owner_correct(o: 0x42::m::Object): address + acquires 0x42::m::ObjectCore(*) { { - let addr: address = select m::Object.inner(o); - select m::ObjectCore.owner<&m::ObjectCore>(BorrowGlobal(Immutable)(addr)) + let addr: address = select m::Object.inner(o); + select m::ObjectCore.owner<&ObjectCore>(BorrowGlobal(Immutable)(addr)) } } - private fun owner_read_ref_missing(o: m::Object): address - acquires m::ObjectCore(*) + private fun owner_read_ref_missing(o: 0x42::m::Object): address + acquires 0x42::m::ObjectCore(*) { - select m::ObjectCore.owner<&m::ObjectCore>(BorrowGlobal(Immutable)(select m::Object.inner(o))) + select m::ObjectCore.owner<&ObjectCore>(BorrowGlobal(Immutable)(select m::Object.inner(o))) } private fun will_autoref(): address { - select m::Object.inner(m::make()) + select m::Object.inner(m::make()) } } // end 0x42::m +// -- Sourcified model before bytecode pipeline +module 0x42::m { + struct Object has copy, drop { + inner: address, + } + struct ObjectCore has key { + owner: address, + } + fun make(): Object { + abort 0 + } + fun owner_correct(o: Object): address + acquires ObjectCore + { + let addr = o.inner; + borrow_global(addr).owner + } + fun owner_read_ref_missing(o: Object): address + acquires ObjectCore + { + borrow_global(o.inner).owner + } + fun will_autoref(): address { + make().inner + } +} + ============ initial bytecode ================ [variant baseline] -fun m::make(): m::Object { - var $t0: m::Object +fun m::make(): 0x42::m::Object { + var $t0: 0x42::m::Object var $t1: u64 0: $t1 := 0 1: abort($t1) @@ -40,36 +67,36 @@ fun m::make(): m::Object { [variant baseline] -fun m::owner_correct($t0: m::Object): address { +fun m::owner_correct($t0: 0x42::m::Object): address { var $t1: address var $t2: address - var $t3: &m::Object + var $t3: &0x42::m::Object var $t4: &address - var $t5: &m::ObjectCore + var $t5: &0x42::m::ObjectCore var $t6: &address 0: $t3 := borrow_local($t0) - 1: $t4 := borrow_field.inner($t3) + 1: $t4 := borrow_field<0x42::m::Object>.inner($t3) 2: $t2 := read_ref($t4) - 3: $t5 := borrow_global($t2) - 4: $t6 := borrow_field.owner($t5) + 3: $t5 := borrow_global<0x42::m::ObjectCore>($t2) + 4: $t6 := borrow_field<0x42::m::ObjectCore>.owner($t5) 5: $t1 := read_ref($t6) 6: return $t1 } [variant baseline] -fun m::owner_read_ref_missing($t0: m::Object): address { +fun m::owner_read_ref_missing($t0: 0x42::m::Object): address { var $t1: address - var $t2: &m::ObjectCore + var $t2: &0x42::m::ObjectCore var $t3: address - var $t4: &m::Object + var $t4: &0x42::m::Object var $t5: &address var $t6: &address 0: $t4 := borrow_local($t0) - 1: $t5 := borrow_field.inner($t4) + 1: $t5 := borrow_field<0x42::m::Object>.inner($t4) 2: $t3 := read_ref($t5) - 3: $t2 := borrow_global($t3) - 4: $t6 := borrow_field.owner($t2) + 3: $t2 := borrow_global<0x42::m::ObjectCore>($t3) + 4: $t6 := borrow_field<0x42::m::ObjectCore>.owner($t2) 5: $t1 := read_ref($t6) 6: return $t1 } @@ -78,12 +105,12 @@ fun m::owner_read_ref_missing($t0: m::Object): address { [variant baseline] fun m::will_autoref(): address { var $t0: address - var $t1: m::Object - var $t2: &m::Object + var $t1: 0x42::m::Object + var $t2: &0x42::m::Object var $t3: &address 0: $t1 := m::make() 1: $t2 := borrow_local($t1) - 2: $t3 := borrow_field.inner($t2) + 2: $t3 := borrow_field<0x42::m::Object>.inner($t2) 3: $t0 := read_ref($t3) 4: return $t0 } diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/fields.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/fields.exp index 9a0e87baab823..163b526a45095 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/fields.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/fields.exp @@ -8,125 +8,175 @@ module 0x42::fields { } struct S { f: u64, - g: fields::T, + g: 0x42::fields::T, } - private fun read_generic_val(x: fields::G): u64 { - select fields::G.f>(x) + private fun read_generic_val(x: 0x42::fields::G): u64 { + select fields::G.f>(x) } - private fun read_ref(x: &fields::S): u64 { - select fields::T.h(select fields::S.g<&fields::S>(x)) + private fun read_ref(x: &0x42::fields::S): u64 { + select fields::T.h(select fields::S.g<&S>(x)) } - private fun read_val(x: fields::S): u64 { - select fields::T.h(select fields::S.g(x)) + private fun read_val(x: 0x42::fields::S): u64 { + select fields::T.h(select fields::S.g(x)) } - private fun write_generic_val(x: &mut fields::G,v: u64) { - select fields::G.f<&mut fields::G>(x) = v + private fun write_generic_val(x: &mut 0x42::fields::G,v: u64) { + select fields::G.f<&mut G>(x) = v } - private fun write_local_direct(): fields::S { + private fun write_local_direct(): 0x42::fields::S { { - let x: fields::S = pack fields::S(0, pack fields::T(0)); - select fields::T.h(select fields::S.g(x)) = 42; + let x: S = pack fields::S(0, pack fields::T(0)); + select fields::T.h(select fields::S.g(x)) = 42; x } } - private fun write_local_via_ref(): fields::S { + private fun write_local_via_ref(): 0x42::fields::S { { - let x: fields::S = pack fields::S(0, pack fields::T(0)); + let x: S = pack fields::S(0, pack fields::T(0)); { - let r: &mut fields::S = Borrow(Mutable)(x); - select fields::T.h(select fields::S.g<&mut fields::S>(r)) = 42; + let r: &mut S = Borrow(Mutable)(x); + select fields::T.h(select fields::S.g<&mut S>(r)) = 42; x } } } - private fun write_local_via_ref_2(): fields::S { + private fun write_local_via_ref_2(): 0x42::fields::S { { - let x: fields::S = pack fields::S(0, pack fields::T(0)); + let x: S = pack fields::S(0, pack fields::T(0)); { - let r: &mut u64 = Borrow(Mutable)(select fields::T.h(select fields::S.g(x))); + let r: &mut u64 = Borrow(Mutable)(select fields::T.h(select fields::S.g(x))); r = 42; x } } } - private fun write_param(x: &mut fields::S) { - select fields::T.h(select fields::S.g<&mut fields::S>(x)) = 42; + private fun write_param(x: &mut 0x42::fields::S) { + select fields::T.h(select fields::S.g<&mut S>(x)) = 42; Tuple() } - private fun write_val(x: fields::S): fields::S { - select fields::T.h(select fields::S.g(x)) = 42; + private fun write_val(x: 0x42::fields::S): 0x42::fields::S { + select fields::T.h(select fields::S.g(x)) = 42; x } } // end 0x42::fields +// -- Sourcified model before bytecode pipeline +module 0x42::fields { + struct T has drop { + h: u64, + } + struct G has drop { + f: X, + } + struct S has drop { + f: u64, + g: T, + } + fun read_generic_val(x: G): u64 { + x.f + } + fun read_ref(x: &S): u64 { + x.g.h + } + fun read_val(x: S): u64 { + x.g.h + } + fun write_generic_val(x: &mut G, v: u64) { + x.f = v + } + fun write_local_direct(): S { + let x = S{f: 0,g: T{h: 0}}; + x.g.h = 42; + x + } + fun write_local_via_ref(): S { + let x = S{f: 0,g: T{h: 0}}; + let r = &mut x; + r.g.h = 42; + x + } + fun write_local_via_ref_2(): S { + let x = S{f: 0,g: T{h: 0}}; + let r = &mut x.g.h; + *r = 42; + x + } + fun write_param(x: &mut S) { + x.g.h = 42; + } + fun write_val(x: S): S { + x.g.h = 42; + x + } +} + ============ initial bytecode ================ [variant baseline] -fun fields::read_generic_val($t0: fields::G): u64 { +fun fields::read_generic_val($t0: 0x42::fields::G): u64 { var $t1: u64 - var $t2: &fields::G + var $t2: &0x42::fields::G var $t3: &u64 0: $t2 := borrow_local($t0) - 1: $t3 := borrow_field>.f($t2) + 1: $t3 := borrow_field<0x42::fields::G>.f($t2) 2: $t1 := read_ref($t3) 3: return $t1 } [variant baseline] -fun fields::read_ref($t0: &fields::S): u64 { +fun fields::read_ref($t0: &0x42::fields::S): u64 { var $t1: u64 - var $t2: &fields::T + var $t2: &0x42::fields::T var $t3: &u64 - 0: $t2 := borrow_field.g($t0) - 1: $t3 := borrow_field.h($t2) + 0: $t2 := borrow_field<0x42::fields::S>.g($t0) + 1: $t3 := borrow_field<0x42::fields::T>.h($t2) 2: $t1 := read_ref($t3) 3: return $t1 } [variant baseline] -fun fields::read_val($t0: fields::S): u64 { +fun fields::read_val($t0: 0x42::fields::S): u64 { var $t1: u64 - var $t2: &fields::T - var $t3: &fields::S + var $t2: &0x42::fields::T + var $t3: &0x42::fields::S var $t4: &u64 0: $t3 := borrow_local($t0) - 1: $t2 := borrow_field.g($t3) - 2: $t4 := borrow_field.h($t2) + 1: $t2 := borrow_field<0x42::fields::S>.g($t3) + 2: $t4 := borrow_field<0x42::fields::T>.h($t2) 3: $t1 := read_ref($t4) 4: return $t1 } [variant baseline] -fun fields::write_generic_val($t0: &mut fields::G, $t1: u64) { +fun fields::write_generic_val($t0: &mut 0x42::fields::G, $t1: u64) { var $t2: &mut u64 - 0: $t2 := borrow_field>.f($t0) + 0: $t2 := borrow_field<0x42::fields::G>.f($t0) 1: write_ref($t2, $t1) 2: return () } [variant baseline] -fun fields::write_local_direct(): fields::S { - var $t0: fields::S - var $t1: fields::S +fun fields::write_local_direct(): 0x42::fields::S { + var $t0: 0x42::fields::S + var $t1: 0x42::fields::S var $t2: u64 - var $t3: fields::T + var $t3: 0x42::fields::T var $t4: u64 var $t5: u64 var $t6: &mut u64 - var $t7: &mut fields::T - var $t8: &mut fields::S + var $t7: &mut 0x42::fields::T + var $t8: &mut 0x42::fields::S 0: $t2 := 0 1: $t4 := 0 - 2: $t3 := pack fields::T($t4) - 3: $t1 := pack fields::S($t2, $t3) + 2: $t3 := pack 0x42::fields::T($t4) + 3: $t1 := pack 0x42::fields::S($t2, $t3) 4: $t5 := 42 5: $t8 := borrow_local($t1) - 6: $t7 := borrow_field.g($t8) - 7: $t6 := borrow_field.h($t7) + 6: $t7 := borrow_field<0x42::fields::S>.g($t8) + 7: $t6 := borrow_field<0x42::fields::T>.h($t7) 8: write_ref($t6, $t5) 9: $t0 := infer($t1) 10: return $t0 @@ -134,24 +184,24 @@ fun fields::write_local_direct(): fields::S { [variant baseline] -fun fields::write_local_via_ref(): fields::S { - var $t0: fields::S - var $t1: fields::S +fun fields::write_local_via_ref(): 0x42::fields::S { + var $t0: 0x42::fields::S + var $t1: 0x42::fields::S var $t2: u64 - var $t3: fields::T + var $t3: 0x42::fields::T var $t4: u64 - var $t5: &mut fields::S + var $t5: &mut 0x42::fields::S var $t6: u64 var $t7: &mut u64 - var $t8: &mut fields::T + var $t8: &mut 0x42::fields::T 0: $t2 := 0 1: $t4 := 0 - 2: $t3 := pack fields::T($t4) - 3: $t1 := pack fields::S($t2, $t3) + 2: $t3 := pack 0x42::fields::T($t4) + 3: $t1 := pack 0x42::fields::S($t2, $t3) 4: $t5 := borrow_local($t1) 5: $t6 := 42 - 6: $t8 := borrow_field.g($t5) - 7: $t7 := borrow_field.h($t8) + 6: $t8 := borrow_field<0x42::fields::S>.g($t5) + 7: $t7 := borrow_field<0x42::fields::T>.h($t8) 8: write_ref($t7, $t6) 9: $t0 := infer($t1) 10: return $t0 @@ -159,23 +209,23 @@ fun fields::write_local_via_ref(): fields::S { [variant baseline] -fun fields::write_local_via_ref_2(): fields::S { - var $t0: fields::S - var $t1: fields::S +fun fields::write_local_via_ref_2(): 0x42::fields::S { + var $t0: 0x42::fields::S + var $t1: 0x42::fields::S var $t2: u64 - var $t3: fields::T + var $t3: 0x42::fields::T var $t4: u64 var $t5: &mut u64 - var $t6: &mut fields::T - var $t7: &mut fields::S + var $t6: &mut 0x42::fields::T + var $t7: &mut 0x42::fields::S var $t8: u64 0: $t2 := 0 1: $t4 := 0 - 2: $t3 := pack fields::T($t4) - 3: $t1 := pack fields::S($t2, $t3) + 2: $t3 := pack 0x42::fields::T($t4) + 3: $t1 := pack 0x42::fields::S($t2, $t3) 4: $t7 := borrow_local($t1) - 5: $t6 := borrow_field.g($t7) - 6: $t5 := borrow_field.h($t6) + 5: $t6 := borrow_field<0x42::fields::S>.g($t7) + 6: $t5 := borrow_field<0x42::fields::T>.h($t6) 7: $t8 := 42 8: write_ref($t5, $t8) 9: $t0 := infer($t1) @@ -184,29 +234,29 @@ fun fields::write_local_via_ref_2(): fields::S { [variant baseline] -fun fields::write_param($t0: &mut fields::S) { +fun fields::write_param($t0: &mut 0x42::fields::S) { var $t1: u64 var $t2: &mut u64 - var $t3: &mut fields::T + var $t3: &mut 0x42::fields::T 0: $t1 := 42 - 1: $t3 := borrow_field.g($t0) - 2: $t2 := borrow_field.h($t3) + 1: $t3 := borrow_field<0x42::fields::S>.g($t0) + 2: $t2 := borrow_field<0x42::fields::T>.h($t3) 3: write_ref($t2, $t1) 4: return () } [variant baseline] -fun fields::write_val($t0: fields::S): fields::S { - var $t1: fields::S +fun fields::write_val($t0: 0x42::fields::S): 0x42::fields::S { + var $t1: 0x42::fields::S var $t2: u64 var $t3: &mut u64 - var $t4: &mut fields::T - var $t5: &mut fields::S + var $t4: &mut 0x42::fields::T + var $t5: &mut 0x42::fields::S 0: $t2 := 42 1: $t5 := borrow_local($t0) - 2: $t4 := borrow_field.g($t5) - 3: $t3 := borrow_field.h($t4) + 2: $t4 := borrow_field<0x42::fields::S>.g($t5) + 3: $t3 := borrow_field<0x42::fields::T>.h($t4) 4: write_ref($t3, $t2) 5: $t1 := infer($t0) 6: return $t1 diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/fields_invalid.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/fields_invalid.exp index b8cd6367f2bae..073c71cfa0aa0 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/fields_invalid.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/fields_invalid.exp @@ -5,17 +5,31 @@ module 0x42::fields { } struct S { f: u64, - g: fields::T, + g: 0x42::fields::T, } - private fun write_ref(x: &fields::S) { - select fields::T.h(select fields::S.g<&fields::S>(x)) = 42; + private fun write_ref(x: &0x42::fields::S) { + select fields::T.h(select fields::S.g<&S>(x)) = 42; Tuple() } } // end 0x42::fields +// -- Sourcified model before bytecode pipeline +module 0x42::fields { + struct T { + h: u64, + } + struct S { + f: u64, + g: T, + } + fun write_ref(x: &S) { + x.g.h = 42; + } +} + Diagnostics: -error: expected `&mut` but found `&fields::S` +error: expected `&mut` but found `&S` ┌─ tests/bytecode-generator/fields_invalid.move:13:9 │ 13 │ x.g.h = 42; diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/freeze_mut_ref.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/freeze_mut_ref.exp index 4e123090b3f54..2ac56bce08722 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/freeze_mut_ref.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/freeze_mut_ref.exp @@ -30,7 +30,7 @@ module 0x42::freeze_mut_ref { Tuple() } } - private fun t1(s: &mut freeze_mut_ref::S): &freeze_mut_ref::S { + private fun t1(s: &mut 0x42::freeze_mut_ref::S): &0x42::freeze_mut_ref::S { Freeze(false)(s) } private fun t2(u1: &mut u64,u2: &mut u64): (&u64, &mut u64) { @@ -46,14 +46,14 @@ module 0x42::freeze_mut_ref { } } } - public fun t5(s: &mut freeze_mut_ref::G) { + public fun t5(s: &mut 0x42::freeze_mut_ref::G) { { let x: u64 = 0; { - let f: &mut u64 = Borrow(Mutable)(select freeze_mut_ref::G.f<&mut freeze_mut_ref::G>(x: u64 = Add(x, 1); + let f: &mut u64 = Borrow(Mutable)(select freeze_mut_ref::G.f<&mut G>(x: u64 = Add(x, 1); s)); { - let g: &mut u64 = Borrow(Mutable)(select freeze_mut_ref::G.f<&mut freeze_mut_ref::G>(x: u64 = Add(x, 1); + let g: &mut u64 = Borrow(Mutable)(select freeze_mut_ref::G.f<&mut G>(x: u64 = Add(x, 1); s)); { let y: &mut u64 = Borrow(Mutable)(2); @@ -69,21 +69,21 @@ module 0x42::freeze_mut_ref { } } } - private fun t6(cond: bool,s: &mut freeze_mut_ref::S,other: &freeze_mut_ref::S) { + private fun t6(cond: bool,s: &mut 0x42::freeze_mut_ref::S,other: &0x42::freeze_mut_ref::S) { { - let x: &freeze_mut_ref::S; + let x: &S; if cond { - x: &freeze_mut_ref::S = Freeze(false)(Copy(s)) + x: &S = Freeze(false)(Copy(s)) } else { - x: &freeze_mut_ref::S = other + x: &S = other }; Tuple() } } - private fun t7(cond: bool,s: &mut freeze_mut_ref::S,other: &freeze_mut_ref::S) { + private fun t7(cond: bool,s: &mut 0x42::freeze_mut_ref::S,other: &0x42::freeze_mut_ref::S) { { - let _x: &freeze_mut_ref::S; - _x: &freeze_mut_ref::S = if cond { + let _x: &S; + _x: &S = if cond { Freeze(false)(s) } else { other @@ -91,9 +91,9 @@ module 0x42::freeze_mut_ref { Tuple() } } - private fun t8(cond: bool,s: &mut freeze_mut_ref::S,other: &freeze_mut_ref::S) { + private fun t8(cond: bool,s: &mut 0x42::freeze_mut_ref::S,other: &0x42::freeze_mut_ref::S) { { - let _x: &freeze_mut_ref::S = if cond { + let _x: &S = if cond { Freeze(false)(s) } else { other @@ -103,6 +103,71 @@ module 0x42::freeze_mut_ref { } } // end 0x42::freeze_mut_ref +// -- Sourcified model before bytecode pipeline +module 0x42::freeze_mut_ref { + struct G { + f: u64, + } + struct S has drop { + } + public fun borrow_mut(map: &mut vector): &Element { + /*freeze*/0x1::vector::borrow_mut(map, 0) + } + public fun borrow_mut2(v: &mut Element): &Element { + /*freeze*/v + } + public fun borrow_mut3(v1: &mut Element, v2: &Element): &Element { + if (true) /*freeze*/v1 else v2 + } + public fun borrow_mut4(v: &mut Element): &Element { + /*freeze*/v + } + fun t0() { + let x = /*freeze*/&mut 0; + x; + } + fun t1(s: &mut S): &S { + /*freeze*/s + } + fun t2(u1: &mut u64, u2: &mut u64): (&u64, &mut u64) { + (/*freeze*/u1, u2) + } + public fun t4() { + let x; + let y; + (x,y) = (/*freeze*/&mut 0, /*freeze*/&mut 0); + } + public fun t5(s: &mut G) { + let x = 0; + let f = &mut { + x = x + 1; + s + }.f; + let g = &mut { + x = x + 1; + s + }.f; + let y = &mut 2; + let z; + *{ + *f = 0; + z = /*freeze*/y; + g + } = 2; + } + fun t6(cond: bool, s: &mut S, other: &S) { + let x; + if (cond) x = /*freeze*/copy s else x = other; + } + fun t7(cond: bool, s: &mut S, other: &S) { + let _x; + _x = if (cond) /*freeze*/s else other; + } + fun t8(cond: bool, s: &mut S, other: &S) { + let _x = if (cond) /*freeze*/s else other; + } +} + ============ initial bytecode ================ [variant baseline] @@ -165,8 +230,8 @@ fun freeze_mut_ref::t0() { [variant baseline] -fun freeze_mut_ref::t1($t0: &mut freeze_mut_ref::S): &freeze_mut_ref::S { - var $t1: &freeze_mut_ref::S +fun freeze_mut_ref::t1($t0: &mut 0x42::freeze_mut_ref::S): &0x42::freeze_mut_ref::S { + var $t1: &0x42::freeze_mut_ref::S 0: $t1 := freeze_ref(implicit)($t0) 1: return $t1 } @@ -205,14 +270,14 @@ public fun freeze_mut_ref::t4() { [variant baseline] -public fun freeze_mut_ref::t5($t0: &mut freeze_mut_ref::G) { +public fun freeze_mut_ref::t5($t0: &mut 0x42::freeze_mut_ref::G) { var $t1: u64 var $t2: &mut u64 - var $t3: &mut freeze_mut_ref::G + var $t3: &mut 0x42::freeze_mut_ref::G var $t4: u64 var $t5: u64 var $t6: &mut u64 - var $t7: &mut freeze_mut_ref::G + var $t7: &mut 0x42::freeze_mut_ref::G var $t8: u64 var $t9: u64 var $t10: &mut u64 @@ -227,12 +292,12 @@ public fun freeze_mut_ref::t5($t0: &mut freeze_mut_ref::G) { 2: $t4 := +($t1, $t5) 3: $t1 := infer($t4) 4: $t3 := infer($t0) - 5: $t2 := borrow_field.f($t3) + 5: $t2 := borrow_field<0x42::freeze_mut_ref::G>.f($t3) 6: $t9 := 1 7: $t8 := +($t1, $t9) 8: $t1 := infer($t8) 9: $t7 := infer($t0) - 10: $t6 := borrow_field.f($t7) + 10: $t6 := borrow_field<0x42::freeze_mut_ref::G>.f($t7) 11: $t11 := 2 12: $t10 := borrow_local($t11) 13: $t13 := 2 @@ -247,10 +312,10 @@ public fun freeze_mut_ref::t5($t0: &mut freeze_mut_ref::G) { [variant baseline] -fun freeze_mut_ref::t6($t0: bool, $t1: &mut freeze_mut_ref::S, $t2: &freeze_mut_ref::S) { - var $t3: &freeze_mut_ref::S - var $t4: &freeze_mut_ref::S - var $t5: &mut freeze_mut_ref::S +fun freeze_mut_ref::t6($t0: bool, $t1: &mut 0x42::freeze_mut_ref::S, $t2: &0x42::freeze_mut_ref::S) { + var $t3: &0x42::freeze_mut_ref::S + var $t4: &0x42::freeze_mut_ref::S + var $t5: &mut 0x42::freeze_mut_ref::S 0: if ($t0) goto 1 else goto 6 1: label L0 2: $t5 := copy($t1) @@ -265,9 +330,9 @@ fun freeze_mut_ref::t6($t0: bool, $t1: &mut freeze_mut_ref::S, $t2: &freeze_mut_ [variant baseline] -fun freeze_mut_ref::t7($t0: bool, $t1: &mut freeze_mut_ref::S, $t2: &freeze_mut_ref::S) { - var $t3: &freeze_mut_ref::S - var $t4: &freeze_mut_ref::S +fun freeze_mut_ref::t7($t0: bool, $t1: &mut 0x42::freeze_mut_ref::S, $t2: &0x42::freeze_mut_ref::S) { + var $t3: &0x42::freeze_mut_ref::S + var $t4: &0x42::freeze_mut_ref::S 0: if ($t0) goto 1 else goto 4 1: label L0 2: $t4 := freeze_ref(implicit)($t1) @@ -281,8 +346,8 @@ fun freeze_mut_ref::t7($t0: bool, $t1: &mut freeze_mut_ref::S, $t2: &freeze_mut_ [variant baseline] -fun freeze_mut_ref::t8($t0: bool, $t1: &mut freeze_mut_ref::S, $t2: &freeze_mut_ref::S) { - var $t3: &freeze_mut_ref::S +fun freeze_mut_ref::t8($t0: bool, $t1: &mut 0x42::freeze_mut_ref::S, $t2: &0x42::freeze_mut_ref::S) { + var $t3: &0x42::freeze_mut_ref::S 0: if ($t0) goto 1 else goto 4 1: label L0 2: $t3 := freeze_ref(implicit)($t1) diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/globals.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/globals.exp index 5015f6fb1c18f..60f8155f1393d 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/globals.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/globals.exp @@ -12,48 +12,74 @@ module 0x42::globals { f: u64, } private fun check(a: address): bool { - exists(a) + exists(a) } private fun publish(s: &signer) { - MoveTo(s, pack globals::R(1)); + MoveTo(s, pack globals::R(1)); Tuple() } private fun read(a: address): u64 - acquires globals::R(*) + acquires 0x42::globals::R(*) { { - let r: &globals::R = BorrowGlobal(Immutable)(a); - select globals::R.f<&globals::R>(r) + let r: &R = BorrowGlobal(Immutable)(a); + select globals::R.f<&R>(r) } } private fun write(a: address,x: u64): u64 - acquires globals::R(*) + acquires 0x42::globals::R(*) { { - let r: &mut globals::R = BorrowGlobal(Mutable)(a); - select globals::R.f<&mut globals::R>(r) = 2; + let r: &mut R = BorrowGlobal(Mutable)(a); + select globals::R.f<&mut R>(r) = 2; 9 } } } // end 0x42::globals +// -- Sourcified model before bytecode pipeline +module 0x42::globals { + struct R has store, key { + f: u64, + } + fun check(a: address): bool { + exists(a) + } + fun publish(s: &signer) { + move_to(s, R{f: 1}); + } + fun read(a: address): u64 + acquires R + { + let r = borrow_global(a); + r.f + } + fun write(a: address, x: u64): u64 + acquires R + { + let r = borrow_global_mut(a); + r.f = 2; + 9 + } +} + ============ initial bytecode ================ [variant baseline] fun globals::check($t0: address): bool { var $t1: bool - 0: $t1 := exists($t0) + 0: $t1 := exists<0x42::globals::R>($t0) 1: return $t1 } [variant baseline] fun globals::publish($t0: &signer) { - var $t1: globals::R + var $t1: 0x42::globals::R var $t2: u64 0: $t2 := 1 - 1: $t1 := pack globals::R($t2) - 2: move_to($t0, $t1) + 1: $t1 := pack 0x42::globals::R($t2) + 2: move_to<0x42::globals::R>($t0, $t1) 3: return () } @@ -61,10 +87,10 @@ fun globals::publish($t0: &signer) { [variant baseline] fun globals::read($t0: address): u64 { var $t1: u64 - var $t2: &globals::R + var $t2: &0x42::globals::R var $t3: &u64 - 0: $t2 := borrow_global($t0) - 1: $t3 := borrow_field.f($t2) + 0: $t2 := borrow_global<0x42::globals::R>($t0) + 1: $t3 := borrow_field<0x42::globals::R>.f($t2) 2: $t1 := read_ref($t3) 3: return $t1 } @@ -73,12 +99,12 @@ fun globals::read($t0: address): u64 { [variant baseline] fun globals::write($t0: address, $t1: u64): u64 { var $t2: u64 - var $t3: &mut globals::R + var $t3: &mut 0x42::globals::R var $t4: u64 var $t5: &mut u64 - 0: $t3 := borrow_global($t0) + 0: $t3 := borrow_global<0x42::globals::R>($t0) 1: $t4 := 2 - 2: $t5 := borrow_field.f($t3) + 2: $t5 := borrow_field<0x42::globals::R>.f($t3) 3: write_ref($t5, $t4) 4: $t2 := 9 5: return $t2 diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/if_else.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/if_else.exp index b8f50f7ed5fbf..a8faa766b2a7a 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/if_else.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/if_else.exp @@ -20,6 +20,16 @@ module 0x42::if_else { } } // end 0x42::if_else +// -- Sourcified model before bytecode pipeline +module 0x42::if_else { + fun if_else(cond: bool, x: u64): u64 { + if (cond) x + 1 else x - 1 + } + fun if_else_nested(cond: bool, x: u64): u64 { + if ((if (cond) x + 1 else x - 1) > 10) x * 2 else x / 2 + } +} + ============ initial bytecode ================ [variant baseline] diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/inline_specs.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/inline_specs.exp index 523f94760adc5..2f77eb1351425 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/inline_specs.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/inline_specs.exp @@ -20,6 +20,30 @@ module 0x42::inline_specs { } } // end 0x42::inline_specs +// -- Sourcified model before bytecode pipeline +module 0x42::inline_specs { + fun specs(): u64 { + let x = 0; + + /* spec { + assert Eq(x, 0); + } + */ + ; + x = succ(x); + + /* spec { + assert Eq(x, 1); + } + */ + ; + x + } + fun succ(x: u64): u64 { + x + 1 + } +} + ============ initial bytecode ================ [variant baseline] diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/loop.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/loop.exp index 7c1cc30de33ce..85bca4397bfc9 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/loop.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/loop.exp @@ -55,6 +55,35 @@ module 0x42::loops { } } // end 0x42::loops +// -- Sourcified model before bytecode pipeline +module 0x42::loops { + fun nested_loop(x: u64): u64 { + while (x > 0) { + while (x > 10) { + x = x - 1; + break; + }; + x = x - 1; + continue; + }; + x + } + fun while_loop(x: u64): u64 { + while (x > 0) { + x = x - 1; + }; + x + } + fun while_loop_with_break_and_continue(x: u64): u64 { + while (x > 0) { + if (x == 42) break; + if (x == 21) continue; + x = x - 1; + }; + x + } +} + ============ initial bytecode ================ [variant baseline] diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/loop_invalid.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/loop_invalid.exp index ba517bb313e92..d5397a3b06b12 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/loop_invalid.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/loop_invalid.exp @@ -24,6 +24,20 @@ module 0x42::loop_invalid { } } // end 0x42::loop_invalid +// -- Sourcified model before bytecode pipeline +module 0x42::loop_invalid { + fun misplaced_break(x: u64): u64 { + while (x > 0) break; + break; + x + } + fun misplaced_continue(x: u64): u64 { + continue; + while (x > 0) continue; + x + } +} + Diagnostics: error: missing enclosing loop statement diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/matching_ability_err.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/matching_ability_err.exp index efb2eb10cc3cd..0651beefd376c 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/matching_ability_err.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/matching_ability_err.exp @@ -15,25 +15,25 @@ module 0xc0ffee::m { enum Outer { None, One { - i: m::Inner, + i: 0xc0ffee::m::Inner, } Two { - i: m::Inner, - b: m::Box, + i: 0xc0ffee::m::Inner, + b: 0xc0ffee::m::Box, } } - public fun condition_requires_copy(o: m::Outer): m::Outer { + public fun condition_requires_copy(o: 0xc0ffee::m::Outer): 0xc0ffee::m::Outer { match (o) { m::Outer::One{ i } if m::consume(i) => { pack m::Outer::One(i) } - o: m::Outer => { + o: Outer => { o } } } - private fun consume(self: m::Inner): bool { + private fun consume(self: 0xc0ffee::m::Inner): bool { match (self) { m::Inner::Inner1{ x: _ } => { Tuple() @@ -45,12 +45,12 @@ module 0xc0ffee::m { ; true } - public fun matched_value_not_consumed(o: m::Outer) { + public fun matched_value_not_consumed(o: 0xc0ffee::m::Outer) { match (o) { m::Outer::One{ i: _ } => { Tuple() } - _: m::Outer => { + _: Outer => { Tuple() } } @@ -58,29 +58,74 @@ module 0xc0ffee::m { } } // end 0xc0ffee::m +// -- Sourcified model before bytecode pipeline +module 0xc0ffee::m { + struct Box has drop { + x: u64, + } + enum Inner { + Inner1 { + x: u64, + } + Inner2 { + x: u64, + y: u64, + } + } + enum Outer { + None, + One { + i: Inner, + } + Two { + i: Inner, + b: Box, + } + } + public fun condition_requires_copy(o: Outer): Outer { + match (o) { + Outer::One{i: i} if consume(i) => Outer::One{i: i}, + o => o, + } + } + fun consume(self: Inner): bool { + match (self) { + Inner::Inner1{x: _} => (), + Inner::Inner2{x: _,y: _} => (), + }; + true + } + public fun matched_value_not_consumed(o: Outer) { + match (o) { + Outer::One{i: _} => (), + _ => (), + } + } +} + ============ initial bytecode ================ [variant baseline] -public fun m::condition_requires_copy($t0: m::Outer): m::Outer { - var $t1: m::Outer - var $t2: &m::Outer +public fun m::condition_requires_copy($t0: 0xc0ffee::m::Outer): 0xc0ffee::m::Outer { + var $t1: 0xc0ffee::m::Outer + var $t2: &0xc0ffee::m::Outer var $t3: bool - var $t4: &m::Inner - var $t5: m::Inner - var $t6: m::Inner - var $t7: m::Outer + var $t4: &0xc0ffee::m::Inner + var $t5: 0xc0ffee::m::Inner + var $t6: 0xc0ffee::m::Inner + var $t7: 0xc0ffee::m::Outer var $t8: u64 0: $t2 := borrow_local($t0) - 1: $t3 := test_variant m::Outer::One($t2) + 1: $t3 := test_variant 0xc0ffee::m::Outer::One($t2) 2: if ($t3) goto 3 else goto 12 3: label L2 - 4: $t4 := borrow_variant_field.i($t2) + 4: $t4 := borrow_variant_field<0xc0ffee::m::Outer::One>.i($t2) 5: $t5 := read_ref($t4) 6: $t3 := m::consume($t5) 7: if ($t3) goto 8 else goto 12 8: label L3 - 9: $t6 := unpack_variant m::Outer::One($t0) - 10: $t1 := pack_variant m::Outer::One($t6) + 9: $t6 := unpack_variant 0xc0ffee::m::Outer::One($t0) + 10: $t1 := pack_variant 0xc0ffee::m::Outer::One($t6) 11: goto 19 12: label L1 13: $t7 := infer($t0) @@ -95,25 +140,25 @@ public fun m::condition_requires_copy($t0: m::Outer): m::Outer { [variant baseline] -fun m::consume($t0: m::Inner): bool { +fun m::consume($t0: 0xc0ffee::m::Inner): bool { var $t1: bool - var $t2: &m::Inner + var $t2: &0xc0ffee::m::Inner var $t3: bool var $t4: u64 var $t5: u64 var $t6: u64 var $t7: u64 0: $t2 := borrow_local($t0) - 1: $t3 := test_variant m::Inner::Inner1($t2) + 1: $t3 := test_variant 0xc0ffee::m::Inner::Inner1($t2) 2: if ($t3) goto 3 else goto 6 3: label L2 - 4: $t4 := unpack_variant m::Inner::Inner1($t0) + 4: $t4 := unpack_variant 0xc0ffee::m::Inner::Inner1($t0) 5: goto 15 6: label L1 - 7: $t3 := test_variant m::Inner::Inner2($t2) + 7: $t3 := test_variant 0xc0ffee::m::Inner::Inner2($t2) 8: if ($t3) goto 9 else goto 12 9: label L4 - 10: ($t5, $t6) := unpack_variant m::Inner::Inner2($t0) + 10: ($t5, $t6) := unpack_variant 0xc0ffee::m::Inner::Inner2($t0) 11: goto 15 12: label L3 13: $t7 := 14566554180833181697 @@ -125,17 +170,17 @@ fun m::consume($t0: m::Inner): bool { [variant baseline] -public fun m::matched_value_not_consumed($t0: m::Outer) { - var $t1: &m::Outer +public fun m::matched_value_not_consumed($t0: 0xc0ffee::m::Outer) { + var $t1: &0xc0ffee::m::Outer var $t2: bool - var $t3: m::Inner - var $t4: m::Outer + var $t3: 0xc0ffee::m::Inner + var $t4: 0xc0ffee::m::Outer var $t5: u64 0: $t1 := borrow_local($t0) - 1: $t2 := test_variant m::Outer::One($t1) + 1: $t2 := test_variant 0xc0ffee::m::Outer::One($t1) 2: if ($t2) goto 3 else goto 6 3: label L2 - 4: $t3 := unpack_variant m::Outer::One($t0) + 4: $t3 := unpack_variant 0xc0ffee::m::Outer::One($t0) 5: goto 12 6: label L1 7: $t4 := infer($t0) @@ -149,19 +194,19 @@ public fun m::matched_value_not_consumed($t0: m::Outer) { Diagnostics: -error: value of type `m::Inner` does not have the `drop` ability +error: value of type `Inner` does not have the `drop` ability ┌─ tests/bytecode-generator/matching_ability_err.move:28:13 │ 28 │ One{i: _} => {} │ ^^^^^^^^^ implicitly dropped here since it is no longer used -error: value of type `m::Outer` does not have the `drop` ability +error: value of type `Outer` does not have the `drop` ability ┌─ tests/bytecode-generator/matching_ability_err.move:29:13 │ 29 │ _ => {} │ ^ implicitly dropped here since it is no longer used -error: local `i` of type `m::Inner` does not have the `copy` ability +error: local `i` of type `Inner` does not have the `copy` ability ┌─ tests/bytecode-generator/matching_ability_err.move:35:31 │ 35 │ One{i} if consume(i) => Outer::One{i}, diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/matching_coverage_err.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/matching_coverage_err.exp index bd94845343123..e8f9edfc18894 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/matching_coverage_err.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/matching_coverage_err.exp @@ -15,25 +15,25 @@ module 0xc0ffee::m { enum Outer { None, One { - i: m::Inner, + i: 0xc0ffee::m::Inner, } Two { - i: m::Inner, - b: m::Box, + i: 0xc0ffee::m::Inner, + b: 0xc0ffee::m::Box, } } - public fun exhaustive_tuple(i: &m::Inner) { + public fun exhaustive_tuple(i: &0xc0ffee::m::Inner) { match (Tuple(i, i)) { - (m::Inner::Inner1{ x: _ }, _: &m::Inner): (&m::Inner, &m::Inner) => { + (m::Inner::Inner1{ x: _ }, _: &Inner): (&Inner, &Inner) => { Tuple() } - (m::Inner::Inner2{ x: _, y: _ }, _: &m::Inner): (&m::Inner, &m::Inner) => { + (m::Inner::Inner2{ x: _, y: _ }, _: &Inner): (&Inner, &Inner) => { Tuple() } } } - public fun exhaustive_via_merge(o: &m::Outer) { + public fun exhaustive_via_merge(o: &0xc0ffee::m::Outer) { match (o) { m::Outer::None => { Tuple() @@ -50,7 +50,7 @@ module 0xc0ffee::m { } } - public fun non_exhaustive(o: &m::Outer) { + public fun non_exhaustive(o: &0xc0ffee::m::Outer) { match (o) { m::Outer::None => { Tuple() @@ -61,7 +61,7 @@ module 0xc0ffee::m { } } - public fun non_exhaustive_because_of_cond(o: &m::Outer) { + public fun non_exhaustive_because_of_cond(o: &0xc0ffee::m::Outer) { match (o) { m::Outer::None => { Tuple() @@ -69,13 +69,13 @@ module 0xc0ffee::m { m::Outer::One{ i: _ } => { Tuple() } - m::Outer::Two{ i: _, b } if Gt(select m::Box.x<&m::Box>(b), 0) => { + m::Outer::Two{ i: _, b } if Gt(select m::Box.x<&Box>(b), 0) => { Tuple() } } } - public fun non_exhaustive_because_of_nested(o: &m::Outer) { + public fun non_exhaustive_because_of_nested(o: &0xc0ffee::m::Outer) { match (o) { m::Outer::None => { Tuple() @@ -89,26 +89,26 @@ module 0xc0ffee::m { } } - public fun non_exhaustive_tuple(i: &m::Inner) { + public fun non_exhaustive_tuple(i: &0xc0ffee::m::Inner) { match (Tuple(i, i)) { - (m::Inner::Inner1{ x: _ }, _: &m::Inner): (&m::Inner, &m::Inner) => { + (m::Inner::Inner1{ x: _ }, _: &Inner): (&Inner, &Inner) => { Tuple() } } } - public fun non_exhaustive_tuple2(i: &m::Inner) { + public fun non_exhaustive_tuple2(i: &0xc0ffee::m::Inner) { match (Tuple(i, i)) { - (m::Inner::Inner1{ x: _ }, _: &m::Inner): (&m::Inner, &m::Inner) => { + (m::Inner::Inner1{ x: _ }, _: &Inner): (&Inner, &Inner) => { Tuple() } - (_: &m::Inner, m::Inner::Inner2{ x: _, y: _ }): (&m::Inner, &m::Inner) => { + (_: &Inner, m::Inner::Inner2{ x: _, y: _ }): (&Inner, &Inner) => { Tuple() } } } - public fun unreachable(o: &m::Outer) { + public fun unreachable(o: &0xc0ffee::m::Outer) { match (o) { m::Outer::None => { Tuple() @@ -119,13 +119,13 @@ module 0xc0ffee::m { m::Outer::Two{ i: _, b: _ } => { Tuple() } - _: &m::Outer => { + _: &Outer => { Tuple() } } } - public fun unreachable_via_overlaying_pattern(o: &m::Outer) { + public fun unreachable_via_overlaying_pattern(o: &0xc0ffee::m::Outer) { match (o) { m::Outer::None => { Tuple() @@ -139,13 +139,13 @@ module 0xc0ffee::m { m::Outer::One{ i: m::Inner::Inner1{ x: _ } } => { Tuple() } - _: &m::Outer => { + _: &Outer => { Tuple() } } } - public fun unreachable_via_repeated_pattern(o: &m::Outer) { + public fun unreachable_via_repeated_pattern(o: &0xc0ffee::m::Outer) { match (o) { m::Outer::None => { Tuple() @@ -156,7 +156,7 @@ module 0xc0ffee::m { m::Outer::One{ i: _ } => { Tuple() } - _: &m::Outer => { + _: &Outer => { Tuple() } } @@ -164,6 +164,102 @@ module 0xc0ffee::m { } } // end 0xc0ffee::m +// -- Sourcified model before bytecode pipeline +module 0xc0ffee::m { + struct Box has drop { + x: u64, + } + enum Inner { + Inner1 { + x: u64, + } + Inner2 { + x: u64, + y: u64, + } + } + enum Outer { + None, + One { + i: Inner, + } + Two { + i: Inner, + b: Box, + } + } + public fun exhaustive_tuple(i: &Inner) { + match ((i, i)) { + (Inner::Inner1{x: _},_) => (), + (Inner::Inner2{x: _,y: _},_) => (), + } + } + public fun exhaustive_via_merge(o: &Outer) { + match (o) { + Outer::None{} => (), + Outer::One{i: Inner::Inner1{x: _}} => (), + Outer::One{i: Inner::Inner2{x: _,y: _}} => (), + Outer::Two{i: _,b: _} => (), + } + } + public fun non_exhaustive(o: &Outer) { + match (o) { + Outer::None{} => (), + Outer::One{i: _} => (), + } + } + public fun non_exhaustive_because_of_cond(o: &Outer) { + match (o) { + Outer::None{} => (), + Outer::One{i: _} => (), + Outer::Two{i: _,b: b} if b.x > 0 => (), + } + } + public fun non_exhaustive_because_of_nested(o: &Outer) { + match (o) { + Outer::None{} => (), + Outer::One{i: Inner::Inner1{x: _}} => (), + Outer::Two{i: _,b: _} => (), + } + } + public fun non_exhaustive_tuple(i: &Inner) { + match ((i, i)) { + (Inner::Inner1{x: _},_) => (), + } + } + public fun non_exhaustive_tuple2(i: &Inner) { + match ((i, i)) { + (Inner::Inner1{x: _},_) => (), + (_,Inner::Inner2{x: _,y: _}) => (), + } + } + public fun unreachable(o: &Outer) { + match (o) { + Outer::None{} => (), + Outer::One{i: _} => (), + Outer::Two{i: _,b: _} => (), + _ => (), + } + } + public fun unreachable_via_overlaying_pattern(o: &Outer) { + match (o) { + Outer::None{} => (), + Outer::One{i: Inner::Inner1{x: _}} => (), + Outer::One{i: _} => (), + Outer::One{i: Inner::Inner1{x: _}} => (), + _ => (), + } + } + public fun unreachable_via_repeated_pattern(o: &Outer) { + match (o) { + Outer::None{} => (), + Outer::One{i: _} => (), + Outer::One{i: _} => (), + _ => (), + } + } +} + Diagnostics: error: match not exhaustive diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/matching_ok.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/matching_ok.exp index 27c69ad451e84..859d8147944cc 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/matching_ok.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/matching_ok.exp @@ -48,14 +48,14 @@ module 0xc0ffee::m { enum Outer { None, One { - i: m::Inner, + i: 0xc0ffee::m::Inner, } Two { - i: m::Inner, - b: m::Box, + i: 0xc0ffee::m::Inner, + b: 0xc0ffee::m::Box, } } - public fun inner_value(self: m::Inner): u64 { + public fun inner_value(self: 0xc0ffee::m::Inner): u64 { match (self) { m::Inner::Inner1{ x } => { x @@ -66,18 +66,18 @@ module 0xc0ffee::m { } } - public fun is_inner1(self: &m::Inner): bool { + public fun is_inner1(self: &0xc0ffee::m::Inner): bool { match (self) { m::Inner::Inner1{ x: _ } => { true } - _: &m::Inner => { + _: &Inner => { false } } } - public fun is_some(x: &m::Option<#0>): bool { + public fun is_some(x: &0xc0ffee::m::Option<#0>): bool { match (x) { m::Option::None => { false @@ -88,32 +88,32 @@ module 0xc0ffee::m { } } - public fun is_some_dropped(x: m::Option<#0>): bool { + public fun is_some_dropped(x: 0xc0ffee::m::Option<#0>): bool { match (x) { m::Option::None => { false } - _: m::Option => { + _: Option => { true } } } - public fun is_some_specialized(x: &m::Option>): bool { + public fun is_some_specialized(x: &0xc0ffee::m::Option<0xc0ffee::m::Option>): bool { match (x) { - m::Option::None> => { + m::Option::None> => { false } - m::Option::Some>{ value: m::Option::None } => { + m::Option::Some>{ value: m::Option::None } => { false } - m::Option::Some>{ value: m::Option::Some{ value: _ } } => { + m::Option::Some>{ value: m::Option::Some{ value: _ } } => { true } } } - public fun outer_value(o: m::Outer): u64 { + public fun outer_value(o: 0xc0ffee::m::Outer): u64 { match (o) { m::Outer::None => { 0 @@ -122,12 +122,12 @@ module 0xc0ffee::m { m::inner_value(i) } m::Outer::Two{ i, b } => { - Add(m::inner_value(i), select m::Box.x(b)) + Add(m::inner_value(i), select m::Box.x(b)) } } } - public fun outer_value_nested(o: m::Outer): u64 { + public fun outer_value_nested(o: 0xc0ffee::m::Outer): u64 { match (o) { m::Outer::None => { 0 @@ -139,12 +139,12 @@ module 0xc0ffee::m { m::inner_value(i) } m::Outer::Two{ i, b } => { - Add(m::inner_value(i), select m::Box.x(b)) + Add(m::inner_value(i), select m::Box.x(b)) } } } - public fun outer_value_with_cond(o: m::Outer): u64 { + public fun outer_value_with_cond(o: 0xc0ffee::m::Outer): u64 { match (o) { m::Outer::None => { 0 @@ -156,12 +156,12 @@ module 0xc0ffee::m { m::inner_value(i) } m::Outer::Two{ i, b } => { - Add(m::inner_value(i), select m::Box.x(b)) + Add(m::inner_value(i), select m::Box.x(b)) } } } - public fun outer_value_with_cond_ref(o: &m::Outer): bool { + public fun outer_value_with_cond_ref(o: &0xc0ffee::m::Outer): bool { match (o) { m::Outer::None => { false @@ -178,8 +178,8 @@ module 0xc0ffee::m { } } - private fun select_common_fields(s: m::CommonFields): u64 { - Add(select_variants m::CommonFields.Foo.x|m::CommonFields.Bar.x(s), match (s) { + private fun select_common_fields(s: 0xc0ffee::m::CommonFields): u64 { + Add(select_variants m::CommonFields.Foo.x|m::CommonFields.Bar.x(s), match (s) { m::CommonFields::Foo{ x: _, y } => { y } @@ -189,40 +189,176 @@ module 0xc0ffee::m { } ) } - private fun select_common_fields_different_offset(s: m::CommonFieldsAtDifferentOffset): u64 { - select_variants m::CommonFieldsAtDifferentOffset.Bar.z|m::CommonFieldsAtDifferentOffset.Baz.z|m::CommonFieldsAtDifferentOffset.Balt.z(s) + private fun select_common_fields_different_offset(s: 0xc0ffee::m::CommonFieldsAtDifferentOffset): u64 { + select_variants m::CommonFieldsAtDifferentOffset.Bar.z|m::CommonFieldsAtDifferentOffset.Baz.z|m::CommonFieldsAtDifferentOffset.Balt.z(s) } - private fun test_common(s: m::CommonFields): bool { + private fun test_common(s: 0xc0ffee::m::CommonFields): bool { test_variants m::CommonFields::Foo|Bar(s) } - private fun test_common_ref(s: &m::CommonFields): bool { + private fun test_common_ref(s: &0xc0ffee::m::CommonFields): bool { test_variants m::CommonFields::Foo|Bar(s) } } // end 0xc0ffee::m +// -- Sourcified model before bytecode pipeline +module 0xc0ffee::m { + struct Box has drop { + x: u64, + } + enum CommonFields { + Foo { + x: u64, + y: u64, + } + Bar { + x: u64, + z: u64, + } + } + enum CommonFieldsAtDifferentOffset has drop { + Foo { + x: u64, + y: u64, + } + Bar { + x: u64, + z: u64, + } + Baz { + z: u64, + } + Balt { + foo: u8, + z: u64, + } + } + enum Inner { + Inner1 { + x: u64, + } + Inner2 { + x: u64, + y: u64, + } + } + enum Option has drop { + None, + Some { + value: A, + } + } + enum Outer { + None, + One { + i: Inner, + } + Two { + i: Inner, + b: Box, + } + } + public fun inner_value(self: Inner): u64 { + match (self) { + Inner::Inner1{x: x} => x, + Inner::Inner2{x: x,y: y} => x + y, + } + } + public fun is_inner1(self: &Inner): bool { + match (self) { + Inner::Inner1{x: _} => true, + _ => false, + } + } + public fun is_some(x: &Option): bool { + match (x) { + Option::None{} => false, + Option::Some{value: _} => true, + } + } + public fun is_some_dropped(x: Option): bool { + match (x) { + Option::None{} => false, + _ => true, + } + } + public fun is_some_specialized(x: &Option>): bool { + match (x) { + Option::None>{} => false, + Option::Some>{value: Option::None{}} => false, + Option::Some>{value: Option::Some{value: _}} => true, + } + } + public fun outer_value(o: Outer): u64 { + match (o) { + Outer::None{} => 0, + Outer::One{i: i} => inner_value(i), + Outer::Two{i: i,b: b} => inner_value(i) + b.x, + } + } + public fun outer_value_nested(o: Outer): u64 { + match (o) { + Outer::None{} => 0, + Outer::One{i: Inner::Inner1{x: x}} => x, + Outer::One{i: i} => inner_value(i), + Outer::Two{i: i,b: b} => inner_value(i) + b.x, + } + } + public fun outer_value_with_cond(o: Outer): u64 { + match (o) { + Outer::None{} => 0, + Outer::One{i: i} if is_inner1(&i) => inner_value(i) % 2, + Outer::One{i: i} => inner_value(i), + Outer::Two{i: i,b: b} => inner_value(i) + b.x, + } + } + public fun outer_value_with_cond_ref(o: &Outer): bool { + match (o) { + Outer::None{} => false, + Outer::One{i: i} if is_inner1(i) => true, + Outer::One{i: i} => is_inner1(i), + Outer::Two{i: i,b: _} => is_inner1(i), + } + } + fun select_common_fields(s: CommonFields): u64 { + s.Foo.x + (match (s) { + CommonFields::Foo{x: _,y: y} => y, + CommonFields::Bar{x: _,z: z} => z, + }) + } + fun select_common_fields_different_offset(s: CommonFieldsAtDifferentOffset): u64 { + s.Bar.z + } + fun test_common(s: CommonFields): bool { + s is Foo | Bar + } + fun test_common_ref(s: &CommonFields): bool { + s is Foo | Bar + } +} + ============ initial bytecode ================ [variant baseline] -public fun m::inner_value($t0: m::Inner): u64 { +public fun m::inner_value($t0: 0xc0ffee::m::Inner): u64 { var $t1: u64 - var $t2: &m::Inner + var $t2: &0xc0ffee::m::Inner var $t3: bool var $t4: u64 var $t5: u64 var $t6: u64 var $t7: u64 0: $t2 := borrow_local($t0) - 1: $t3 := test_variant m::Inner::Inner1($t2) + 1: $t3 := test_variant 0xc0ffee::m::Inner::Inner1($t2) 2: if ($t3) goto 3 else goto 7 3: label L2 - 4: $t4 := unpack_variant m::Inner::Inner1($t0) + 4: $t4 := unpack_variant 0xc0ffee::m::Inner::Inner1($t0) 5: $t1 := infer($t4) 6: goto 17 7: label L1 - 8: $t3 := test_variant m::Inner::Inner2($t2) + 8: $t3 := test_variant 0xc0ffee::m::Inner::Inner2($t2) 9: if ($t3) goto 10 else goto 14 10: label L4 - 11: ($t5, $t6) := unpack_variant m::Inner::Inner2($t0) + 11: ($t5, $t6) := unpack_variant 0xc0ffee::m::Inner::Inner2($t0) 12: $t1 := +($t5, $t6) 13: goto 17 14: label L3 @@ -234,12 +370,12 @@ public fun m::inner_value($t0: m::Inner): u64 { [variant baseline] -public fun m::is_inner1($t0: &m::Inner): bool { +public fun m::is_inner1($t0: &0xc0ffee::m::Inner): bool { var $t1: bool var $t2: bool - var $t3: &m::Inner + var $t3: &0xc0ffee::m::Inner var $t4: u64 - 0: $t2 := test_variant m::Inner::Inner1($t0) + 0: $t2 := test_variant 0xc0ffee::m::Inner::Inner1($t0) 1: if ($t2) goto 2 else goto 5 2: label L2 3: $t1 := true @@ -257,17 +393,17 @@ public fun m::is_inner1($t0: &m::Inner): bool { [variant baseline] -public fun m::is_some<#0>($t0: &m::Option<#0>): bool { +public fun m::is_some<#0>($t0: &0xc0ffee::m::Option<#0>): bool { var $t1: bool var $t2: bool var $t3: u64 - 0: $t2 := test_variant m::Option<#0>::None($t0) + 0: $t2 := test_variant 0xc0ffee::m::Option<#0>::None($t0) 1: if ($t2) goto 2 else goto 5 2: label L2 3: $t1 := false 4: goto 14 5: label L1 - 6: $t2 := test_variant m::Option<#0>::Some($t0) + 6: $t2 := test_variant 0xc0ffee::m::Option<#0>::Some($t0) 7: if ($t2) goto 8 else goto 11 8: label L4 9: $t1 := true @@ -281,17 +417,17 @@ public fun m::is_some<#0>($t0: &m::Option<#0>): bool { [variant baseline] -public fun m::is_some_dropped<#0>($t0: m::Option<#0>): bool { +public fun m::is_some_dropped<#0>($t0: 0xc0ffee::m::Option<#0>): bool { var $t1: bool - var $t2: &m::Option<#0> + var $t2: &0xc0ffee::m::Option<#0> var $t3: bool - var $t4: m::Option<#0> + var $t4: 0xc0ffee::m::Option<#0> var $t5: u64 0: $t2 := borrow_local($t0) - 1: $t3 := test_variant m::Option<#0>::None($t2) + 1: $t3 := test_variant 0xc0ffee::m::Option<#0>::None($t2) 2: if ($t3) goto 3 else goto 7 3: label L2 - 4: unpack_variant m::Option<#0>::None($t0) + 4: unpack_variant 0xc0ffee::m::Option<#0>::None($t0) 5: $t1 := false 6: goto 14 7: label L1 @@ -307,33 +443,33 @@ public fun m::is_some_dropped<#0>($t0: m::Option<#0>): bool { [variant baseline] -public fun m::is_some_specialized($t0: &m::Option>): bool { +public fun m::is_some_specialized($t0: &0xc0ffee::m::Option<0xc0ffee::m::Option>): bool { var $t1: bool var $t2: bool - var $t3: &m::Option - var $t4: &m::Option + var $t3: &0xc0ffee::m::Option + var $t4: &0xc0ffee::m::Option var $t5: u64 - 0: $t2 := test_variant m::Option>::None($t0) + 0: $t2 := test_variant 0xc0ffee::m::Option<0xc0ffee::m::Option>::None($t0) 1: if ($t2) goto 2 else goto 5 2: label L2 3: $t1 := false 4: goto 28 5: label L1 - 6: $t2 := test_variant m::Option>::Some($t0) + 6: $t2 := test_variant 0xc0ffee::m::Option<0xc0ffee::m::Option>::Some($t0) 7: if ($t2) goto 8 else goto 15 8: label L4 - 9: $t3 := borrow_variant_field>::Some>.value($t0) - 10: $t2 := test_variant m::Option::None($t3) + 9: $t3 := borrow_variant_field<0xc0ffee::m::Option<0xc0ffee::m::Option>::Some>.value($t0) + 10: $t2 := test_variant 0xc0ffee::m::Option::None($t3) 11: if ($t2) goto 12 else goto 15 12: label L5 13: $t1 := false 14: goto 28 15: label L3 - 16: $t2 := test_variant m::Option>::Some($t0) + 16: $t2 := test_variant 0xc0ffee::m::Option<0xc0ffee::m::Option>::Some($t0) 17: if ($t2) goto 18 else goto 25 18: label L7 - 19: $t4 := borrow_variant_field>::Some>.value($t0) - 20: $t2 := test_variant m::Option::Some($t4) + 19: $t4 := borrow_variant_field<0xc0ffee::m::Option<0xc0ffee::m::Option>::Some>.value($t0) + 20: $t2 := test_variant 0xc0ffee::m::Option::Some($t4) 21: if ($t2) goto 22 else goto 25 22: label L8 23: $t1 := true @@ -347,40 +483,40 @@ public fun m::is_some_specialized($t0: &m::Option>): bool { [variant baseline] -public fun m::outer_value($t0: m::Outer): u64 { +public fun m::outer_value($t0: 0xc0ffee::m::Outer): u64 { var $t1: u64 - var $t2: &m::Outer + var $t2: &0xc0ffee::m::Outer var $t3: bool - var $t4: m::Inner - var $t5: m::Inner - var $t6: m::Box + var $t4: 0xc0ffee::m::Inner + var $t5: 0xc0ffee::m::Inner + var $t6: 0xc0ffee::m::Box var $t7: u64 var $t8: u64 - var $t9: &m::Box + var $t9: &0xc0ffee::m::Box var $t10: &u64 var $t11: u64 0: $t2 := borrow_local($t0) - 1: $t3 := test_variant m::Outer::None($t2) + 1: $t3 := test_variant 0xc0ffee::m::Outer::None($t2) 2: if ($t3) goto 3 else goto 7 3: label L2 - 4: unpack_variant m::Outer::None($t0) + 4: unpack_variant 0xc0ffee::m::Outer::None($t0) 5: $t1 := 0 6: goto 28 7: label L1 - 8: $t3 := test_variant m::Outer::One($t2) + 8: $t3 := test_variant 0xc0ffee::m::Outer::One($t2) 9: if ($t3) goto 10 else goto 14 10: label L4 - 11: $t4 := unpack_variant m::Outer::One($t0) + 11: $t4 := unpack_variant 0xc0ffee::m::Outer::One($t0) 12: $t1 := m::inner_value($t4) 13: goto 28 14: label L3 - 15: $t3 := test_variant m::Outer::Two($t2) + 15: $t3 := test_variant 0xc0ffee::m::Outer::Two($t2) 16: if ($t3) goto 17 else goto 25 17: label L6 - 18: ($t5, $t6) := unpack_variant m::Outer::Two($t0) + 18: ($t5, $t6) := unpack_variant 0xc0ffee::m::Outer::Two($t0) 19: $t7 := m::inner_value($t5) 20: $t9 := borrow_local($t6) - 21: $t10 := borrow_field.x($t9) + 21: $t10 := borrow_field<0xc0ffee::m::Box>.x($t9) 22: $t8 := read_ref($t10) 23: $t1 := +($t7, $t8) 24: goto 28 @@ -393,55 +529,55 @@ public fun m::outer_value($t0: m::Outer): u64 { [variant baseline] -public fun m::outer_value_nested($t0: m::Outer): u64 { +public fun m::outer_value_nested($t0: 0xc0ffee::m::Outer): u64 { var $t1: u64 - var $t2: &m::Outer + var $t2: &0xc0ffee::m::Outer var $t3: bool - var $t4: &m::Inner + var $t4: &0xc0ffee::m::Inner var $t5: u64 - var $t6: m::Inner - var $t7: m::Inner - var $t8: m::Inner - var $t9: m::Box + var $t6: 0xc0ffee::m::Inner + var $t7: 0xc0ffee::m::Inner + var $t8: 0xc0ffee::m::Inner + var $t9: 0xc0ffee::m::Box var $t10: u64 var $t11: u64 - var $t12: &m::Box + var $t12: &0xc0ffee::m::Box var $t13: &u64 var $t14: u64 0: $t2 := borrow_local($t0) - 1: $t3 := test_variant m::Outer::None($t2) + 1: $t3 := test_variant 0xc0ffee::m::Outer::None($t2) 2: if ($t3) goto 3 else goto 7 3: label L2 - 4: unpack_variant m::Outer::None($t0) + 4: unpack_variant 0xc0ffee::m::Outer::None($t0) 5: $t1 := 0 6: goto 40 7: label L1 - 8: $t3 := test_variant m::Outer::One($t2) + 8: $t3 := test_variant 0xc0ffee::m::Outer::One($t2) 9: if ($t3) goto 10 else goto 19 10: label L4 - 11: $t4 := borrow_variant_field.i($t2) - 12: $t3 := test_variant m::Inner::Inner1($t4) + 11: $t4 := borrow_variant_field<0xc0ffee::m::Outer::One>.i($t2) + 12: $t3 := test_variant 0xc0ffee::m::Inner::Inner1($t4) 13: if ($t3) goto 14 else goto 19 14: label L5 - 15: $t6 := unpack_variant m::Outer::One($t0) - 16: $t5 := unpack_variant m::Inner::Inner1($t6) + 15: $t6 := unpack_variant 0xc0ffee::m::Outer::One($t0) + 16: $t5 := unpack_variant 0xc0ffee::m::Inner::Inner1($t6) 17: $t1 := infer($t5) 18: goto 40 19: label L3 - 20: $t3 := test_variant m::Outer::One($t2) + 20: $t3 := test_variant 0xc0ffee::m::Outer::One($t2) 21: if ($t3) goto 22 else goto 26 22: label L7 - 23: $t7 := unpack_variant m::Outer::One($t0) + 23: $t7 := unpack_variant 0xc0ffee::m::Outer::One($t0) 24: $t1 := m::inner_value($t7) 25: goto 40 26: label L6 - 27: $t3 := test_variant m::Outer::Two($t2) + 27: $t3 := test_variant 0xc0ffee::m::Outer::Two($t2) 28: if ($t3) goto 29 else goto 37 29: label L9 - 30: ($t8, $t9) := unpack_variant m::Outer::Two($t0) + 30: ($t8, $t9) := unpack_variant 0xc0ffee::m::Outer::Two($t0) 31: $t10 := m::inner_value($t8) 32: $t12 := borrow_local($t9) - 33: $t13 := borrow_field.x($t12) + 33: $t13 := borrow_field<0xc0ffee::m::Box>.x($t12) 34: $t11 := read_ref($t13) 35: $t1 := +($t10, $t11) 36: goto 40 @@ -454,59 +590,59 @@ public fun m::outer_value_nested($t0: m::Outer): u64 { [variant baseline] -public fun m::outer_value_with_cond($t0: m::Outer): u64 { +public fun m::outer_value_with_cond($t0: 0xc0ffee::m::Outer): u64 { var $t1: u64 - var $t2: &m::Outer + var $t2: &0xc0ffee::m::Outer var $t3: bool - var $t4: &m::Inner - var $t5: &m::Inner - var $t6: m::Inner + var $t4: &0xc0ffee::m::Inner + var $t5: &0xc0ffee::m::Inner + var $t6: 0xc0ffee::m::Inner var $t7: u64 var $t8: u64 - var $t9: m::Inner - var $t10: m::Inner - var $t11: m::Box + var $t9: 0xc0ffee::m::Inner + var $t10: 0xc0ffee::m::Inner + var $t11: 0xc0ffee::m::Box var $t12: u64 var $t13: u64 - var $t14: &m::Box + var $t14: &0xc0ffee::m::Box var $t15: &u64 var $t16: u64 0: $t2 := borrow_local($t0) - 1: $t3 := test_variant m::Outer::None($t2) + 1: $t3 := test_variant 0xc0ffee::m::Outer::None($t2) 2: if ($t3) goto 3 else goto 7 3: label L2 - 4: unpack_variant m::Outer::None($t0) + 4: unpack_variant 0xc0ffee::m::Outer::None($t0) 5: $t1 := 0 6: goto 42 7: label L1 - 8: $t3 := test_variant m::Outer::One($t2) + 8: $t3 := test_variant 0xc0ffee::m::Outer::One($t2) 9: if ($t3) goto 10 else goto 21 10: label L4 - 11: $t4 := borrow_variant_field.i($t2) + 11: $t4 := borrow_variant_field<0xc0ffee::m::Outer::One>.i($t2) 12: $t5 := infer($t4) 13: $t3 := m::is_inner1($t5) 14: if ($t3) goto 15 else goto 21 15: label L5 - 16: $t6 := unpack_variant m::Outer::One($t0) + 16: $t6 := unpack_variant 0xc0ffee::m::Outer::One($t0) 17: $t7 := m::inner_value($t6) 18: $t8 := 2 19: $t1 := %($t7, $t8) 20: goto 42 21: label L3 - 22: $t3 := test_variant m::Outer::One($t2) + 22: $t3 := test_variant 0xc0ffee::m::Outer::One($t2) 23: if ($t3) goto 24 else goto 28 24: label L7 - 25: $t9 := unpack_variant m::Outer::One($t0) + 25: $t9 := unpack_variant 0xc0ffee::m::Outer::One($t0) 26: $t1 := m::inner_value($t9) 27: goto 42 28: label L6 - 29: $t3 := test_variant m::Outer::Two($t2) + 29: $t3 := test_variant 0xc0ffee::m::Outer::Two($t2) 30: if ($t3) goto 31 else goto 39 31: label L9 - 32: ($t10, $t11) := unpack_variant m::Outer::Two($t0) + 32: ($t10, $t11) := unpack_variant 0xc0ffee::m::Outer::Two($t0) 33: $t12 := m::inner_value($t10) 34: $t14 := borrow_local($t11) - 35: $t15 := borrow_field.x($t14) + 35: $t15 := borrow_field<0xc0ffee::m::Box>.x($t14) 36: $t13 := read_ref($t15) 37: $t1 := +($t12, $t13) 38: goto 42 @@ -519,40 +655,40 @@ public fun m::outer_value_with_cond($t0: m::Outer): u64 { [variant baseline] -public fun m::outer_value_with_cond_ref($t0: &m::Outer): bool { +public fun m::outer_value_with_cond_ref($t0: &0xc0ffee::m::Outer): bool { var $t1: bool var $t2: bool - var $t3: &m::Inner - var $t4: &m::Inner - var $t5: &m::Inner + var $t3: &0xc0ffee::m::Inner + var $t4: &0xc0ffee::m::Inner + var $t5: &0xc0ffee::m::Inner var $t6: u64 - 0: $t2 := test_variant m::Outer::None($t0) + 0: $t2 := test_variant 0xc0ffee::m::Outer::None($t0) 1: if ($t2) goto 2 else goto 5 2: label L2 3: $t1 := false 4: goto 32 5: label L1 - 6: $t2 := test_variant m::Outer::One($t0) + 6: $t2 := test_variant 0xc0ffee::m::Outer::One($t0) 7: if ($t2) goto 8 else goto 15 8: label L4 - 9: $t3 := borrow_variant_field.i($t0) + 9: $t3 := borrow_variant_field<0xc0ffee::m::Outer::One>.i($t0) 10: $t2 := m::is_inner1($t3) 11: if ($t2) goto 12 else goto 15 12: label L5 13: $t1 := true 14: goto 32 15: label L3 - 16: $t2 := test_variant m::Outer::One($t0) + 16: $t2 := test_variant 0xc0ffee::m::Outer::One($t0) 17: if ($t2) goto 18 else goto 22 18: label L7 - 19: $t4 := borrow_variant_field.i($t0) + 19: $t4 := borrow_variant_field<0xc0ffee::m::Outer::One>.i($t0) 20: $t1 := m::is_inner1($t4) 21: goto 32 22: label L6 - 23: $t2 := test_variant m::Outer::Two($t0) + 23: $t2 := test_variant 0xc0ffee::m::Outer::Two($t0) 24: if ($t2) goto 25 else goto 29 25: label L9 - 26: $t5 := borrow_variant_field.i($t0) + 26: $t5 := borrow_variant_field<0xc0ffee::m::Outer::Two>.i($t0) 27: $t1 := m::is_inner1($t5) 28: goto 32 29: label L8 @@ -564,13 +700,13 @@ public fun m::outer_value_with_cond_ref($t0: &m::Outer): bool { [variant baseline] -fun m::select_common_fields($t0: m::CommonFields): u64 { +fun m::select_common_fields($t0: 0xc0ffee::m::CommonFields): u64 { var $t1: u64 var $t2: u64 - var $t3: &m::CommonFields + var $t3: &0xc0ffee::m::CommonFields var $t4: &u64 var $t5: u64 - var $t6: &m::CommonFields + var $t6: &0xc0ffee::m::CommonFields var $t7: bool var $t8: u64 var $t9: u64 @@ -578,20 +714,20 @@ fun m::select_common_fields($t0: m::CommonFields): u64 { var $t11: u64 var $t12: u64 0: $t3 := borrow_local($t0) - 1: $t4 := borrow_variant_field.x($t3) + 1: $t4 := borrow_variant_field<0xc0ffee::m::CommonFields::Foo|Bar>.x($t3) 2: $t2 := read_ref($t4) 3: $t6 := borrow_local($t0) - 4: $t7 := test_variant m::CommonFields::Foo($t6) + 4: $t7 := test_variant 0xc0ffee::m::CommonFields::Foo($t6) 5: if ($t7) goto 6 else goto 10 6: label L2 - 7: ($t9, $t8) := unpack_variant m::CommonFields::Foo($t0) + 7: ($t9, $t8) := unpack_variant 0xc0ffee::m::CommonFields::Foo($t0) 8: $t5 := infer($t8) 9: goto 20 10: label L1 - 11: $t7 := test_variant m::CommonFields::Bar($t6) + 11: $t7 := test_variant 0xc0ffee::m::CommonFields::Bar($t6) 12: if ($t7) goto 13 else goto 17 13: label L4 - 14: ($t11, $t10) := unpack_variant m::CommonFields::Bar($t0) + 14: ($t11, $t10) := unpack_variant 0xc0ffee::m::CommonFields::Bar($t0) 15: $t5 := infer($t10) 16: goto 20 17: label L3 @@ -604,24 +740,24 @@ fun m::select_common_fields($t0: m::CommonFields): u64 { [variant baseline] -fun m::select_common_fields_different_offset($t0: m::CommonFieldsAtDifferentOffset): u64 { +fun m::select_common_fields_different_offset($t0: 0xc0ffee::m::CommonFieldsAtDifferentOffset): u64 { var $t1: u64 - var $t2: &m::CommonFieldsAtDifferentOffset + var $t2: &0xc0ffee::m::CommonFieldsAtDifferentOffset var $t3: &u64 var $t4: bool 0: $t2 := borrow_local($t0) - 1: $t4 := test_variant m::CommonFieldsAtDifferentOffset::Bar($t2) + 1: $t4 := test_variant 0xc0ffee::m::CommonFieldsAtDifferentOffset::Bar($t2) 2: if ($t4) goto 8 else goto 3 3: label L3 - 4: $t4 := test_variant m::CommonFieldsAtDifferentOffset::Balt($t2) + 4: $t4 := test_variant 0xc0ffee::m::CommonFieldsAtDifferentOffset::Balt($t2) 5: if ($t4) goto 8 else goto 6 6: label L4 7: goto 11 8: label L2 - 9: $t3 := borrow_variant_field.z($t2) + 9: $t3 := borrow_variant_field<0xc0ffee::m::CommonFieldsAtDifferentOffset::Bar|Balt>.z($t2) 10: goto 13 11: label L1 - 12: $t3 := borrow_variant_field.z($t2) + 12: $t3 := borrow_variant_field<0xc0ffee::m::CommonFieldsAtDifferentOffset::Baz>.z($t2) 13: label L0 14: $t1 := read_ref($t3) 15: return $t1 @@ -629,14 +765,14 @@ fun m::select_common_fields_different_offset($t0: m::CommonFieldsAtDifferentOffs [variant baseline] -fun m::test_common($t0: m::CommonFields): bool { +fun m::test_common($t0: 0xc0ffee::m::CommonFields): bool { var $t1: bool - var $t2: &m::CommonFields + var $t2: &0xc0ffee::m::CommonFields 0: $t2 := borrow_local($t0) - 1: $t1 := test_variant m::CommonFields::Foo($t2) + 1: $t1 := test_variant 0xc0ffee::m::CommonFields::Foo($t2) 2: if ($t1) goto 7 else goto 3 3: label L1 - 4: $t1 := test_variant m::CommonFields::Bar($t2) + 4: $t1 := test_variant 0xc0ffee::m::CommonFields::Bar($t2) 5: if ($t1) goto 7 else goto 6 6: label L2 7: label L0 @@ -645,12 +781,12 @@ fun m::test_common($t0: m::CommonFields): bool { [variant baseline] -fun m::test_common_ref($t0: &m::CommonFields): bool { +fun m::test_common_ref($t0: &0xc0ffee::m::CommonFields): bool { var $t1: bool - 0: $t1 := test_variant m::CommonFields::Foo($t0) + 0: $t1 := test_variant 0xc0ffee::m::CommonFields::Foo($t0) 1: if ($t1) goto 6 else goto 2 2: label L1 - 3: $t1 := test_variant m::CommonFields::Bar($t0) + 3: $t1 := test_variant 0xc0ffee::m::CommonFields::Bar($t0) 4: if ($t1) goto 6 else goto 5 5: label L2 6: label L0 @@ -659,7 +795,7 @@ fun m::test_common_ref($t0: &m::CommonFields): bool { Diagnostics: -error: local `s` of type `m::CommonFields` does not have the `drop` ability +error: local `s` of type `CommonFields` does not have the `drop` ability ┌─ tests/bytecode-generator/matching_ok.move:128:10 │ 128 │ (s is Foo|Bar) diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/matching_refutable_err.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/matching_refutable_err.exp index 2072c014526ea..c7e4acb12ac00 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/matching_refutable_err.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/matching_refutable_err.exp @@ -6,7 +6,7 @@ module 0x815::m { 0: u64, } } - private fun t(self: m::E): u64 { + private fun t(self: 0x815::m::E): u64 { { let m::E::Some{ 0: x } = self; x @@ -14,13 +14,27 @@ module 0x815::m { } } // end 0x815::m +// -- Sourcified model before bytecode pipeline +module 0x815::m { + enum E { + None, + Some { + 0: u64, + } + } + fun t(self: E): u64 { + let E::Some{0: x} = self; + x + } +} + ============ initial bytecode ================ [variant baseline] -fun m::t($t0: m::E): u64 { +fun m::t($t0: 0x815::m::E): u64 { var $t1: u64 var $t2: u64 - 0: $t2 := unpack_variant m::E::Some($t0) + 0: $t2 := unpack_variant 0x815::m::E::Some($t0) 1: $t1 := infer($t2) 2: return $t1 } diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/moved_var_not_simplified3.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/moved_var_not_simplified3.exp index fa669c34cd583..b46e5b602e42e 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/moved_var_not_simplified3.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/moved_var_not_simplified3.exp @@ -14,6 +14,16 @@ module 0xc0ffee::m { } } // end 0xc0ffee::m +// -- Sourcified model before bytecode pipeline +module 0xc0ffee::m { + public fun test(): u8 { + let x = 40u8; + let y = move x; + let _ = x; + y + } +} + ============ initial bytecode ================ [variant baseline] diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/mutate_immutable_cmp.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/mutate_immutable_cmp.exp index 7acf2de5d5ae7..367381c68d0ce 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/mutate_immutable_cmp.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/mutate_immutable_cmp.exp @@ -1,7 +1,7 @@ // -- Model dump before bytecode pipeline module 0x8675309::M { struct T { - s: M::S, + s: 0x8675309::M::S, } struct G { dummy_field: bool, @@ -9,7 +9,7 @@ module 0x8675309::M { struct S { f: u64, } - private fun t0(s: &mut M::S) { + private fun t0(s: &mut 0x8675309::M::S) { s = pack M::S(2); s = pack M::S(0); Borrow(Immutable)(0) = 1; @@ -21,20 +21,20 @@ module 0x8675309::M { let x_ref: &u64 = Freeze(false)(x_ref); x_ref = 0; { - let g: M::S = pack M::S(0); + let g: S = pack M::S(0); { - let g_ref: &mut M::S = Borrow(Mutable)(g); + let g_ref: &mut S = Borrow(Mutable)(g); g_ref = pack M::S(2); { - let t: M::T = pack M::T(g); + let t: T = pack M::T(g); { - let t_ref: &mut M::T = Borrow(Mutable)(t); + let t_ref: &mut T = Borrow(Mutable)(t); { - let g: M::S = pack M::S(2); - select M::T.s<&mut M::T>(t_ref) = g; + let g: S = pack M::S(2); + select M::T.s<&mut T>(t_ref) = g; { - let g: M::S = pack M::S(3); - select M::T.s<&M::T>(t_ref) = g; + let g: S = pack M::S(3); + select M::T.s<&T>(t_ref) = g; Tuple() } } @@ -55,9 +55,43 @@ module 0x8675309::M { } } // end 0x8675309::M +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct T has drop { + s: S, + } + struct G has drop, key { + } + struct S has drop { + f: u64, + } + fun t0(s: &mut S) { + *s = S{f: 2}; + *s = S{f: 0}; + *&0 = 1; + let x = 0; + let x_ref = &mut x; + let x_ref = /*freeze*/x_ref; + *x_ref = 0; + let g = S{f: 0}; + let g_ref = &mut g; + *g_ref = S{f: 2}; + let t = T{s: g}; + let t_ref = &mut t; + let g = S{f: 2}; + t_ref.s = g; + let g = S{f: 3}; + t_ref.s = g; + } + fun t1() { + let x = 3; + *&mut x = 5; + } +} + Diagnostics: -error: expected `&mut` but found `&M::S` +error: expected `&mut` but found `&S` ┌─ tests/bytecode-generator/mutate_immutable_cmp.move:7:11 │ 7 │ *(s: &S) = S { f: 0 }; // this is not OK @@ -75,13 +109,13 @@ error: expected `&mut` but found `&u64` 12 │ *x_ref = 0; │ ^^^^^ -error: expected `&mut` but found `&M::S` +error: expected `&mut` but found `&S` ┌─ tests/bytecode-generator/mutate_immutable_cmp.move:15:11 │ 15 │ *(g_ref: &S) = S {f : 2}; │ ^^^^^ -error: expected `&mut` but found `&M::T` +error: expected `&mut` but found `&T` ┌─ tests/bytecode-generator/mutate_immutable_cmp.move:21:10 │ 21 │ (t_ref: &T).s = g; // this is not OK diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/operators.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/operators.exp index 0dad714bc08b3..3582d351ad0b5 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/operators.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/operators.exp @@ -20,6 +20,28 @@ module 0x42::operators { } } // end 0x42::operators +// -- Sourcified model before bytecode pipeline +module 0x42::operators { + fun arithm(x: u64, y: u64): u64 { + x + y / (x - y) * y % x + } + fun bits(x: u64, y: u8): u64 { + x << y & x + } + fun bools(x: bool, y: bool): bool { + x && y || x && !y || !x && y || !x && !y + } + fun equality(x: T, y: T): bool { + x == y + } + fun inequality(x: T, y: T): bool { + x != y + } + fun order(x: u64, y: u64): bool { + x < y && x <= y && !(x > y) && !(x >= y) + } +} + ============ initial bytecode ================ [variant baseline] diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/pack_order.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/pack_order.exp index 813c92392ef60..f68992472d90f 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/pack_order.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/pack_order.exp @@ -5,10 +5,10 @@ module 0x42::pack_unpack { f2: u8, f3: u8, } - private fun pack1(x: u8,y: u8,z: u8): pack_unpack::S { + private fun pack1(x: u8,y: u8,z: u8): 0x42::pack_unpack::S { pack pack_unpack::S(x, y, z) } - private fun pack2(x: u8,y: u8,z: u8): pack_unpack::S { + private fun pack2(x: u8,y: u8,z: u8): 0x42::pack_unpack::S { { let $f1: u8 = x; { @@ -17,13 +17,13 @@ module 0x42::pack_unpack { } } } - private fun pack3(x: u8,y: u8,z: u8): pack_unpack::S { + private fun pack3(x: u8,y: u8,z: u8): 0x42::pack_unpack::S { { let $f2: u8 = x; pack pack_unpack::S(y, $f2, z) } } - private fun pack4(x: u8,y: u8,z: u8): pack_unpack::S { + private fun pack4(x: u8,y: u8,z: u8): 0x42::pack_unpack::S { { let $f2: u8 = x; { @@ -32,13 +32,13 @@ module 0x42::pack_unpack { } } } - private fun pack5(x: u8,y: u8,z: u8): pack_unpack::S { + private fun pack5(x: u8,y: u8,z: u8): 0x42::pack_unpack::S { { let $f3: u8 = x; pack pack_unpack::S(y, z, $f3) } } - private fun pack6(x: u8,y: u8,z: u8): pack_unpack::S { + private fun pack6(x: u8,y: u8,z: u8): 0x42::pack_unpack::S { { let $f3: u8 = x; { @@ -49,68 +49,103 @@ module 0x42::pack_unpack { } } // end 0x42::pack_unpack +// -- Sourcified model before bytecode pipeline +module 0x42::pack_unpack { + struct S { + f1: u8, + f2: u8, + f3: u8, + } + fun pack1(x: u8, y: u8, z: u8): S { + S{f1: x,f2: y,f3: z} + } + fun pack2(x: u8, y: u8, z: u8): S { + let $f1 = x; + let $f3 = y; + S{f1: $f1,f2: z,f3: $f3} + } + fun pack3(x: u8, y: u8, z: u8): S { + let $f2 = x; + S{f1: y,f2: $f2,f3: z} + } + fun pack4(x: u8, y: u8, z: u8): S { + let $f2 = x; + let $f3 = y; + S{f1: z,f2: $f2,f3: $f3} + } + fun pack5(x: u8, y: u8, z: u8): S { + let $f3 = x; + S{f1: y,f2: z,f3: $f3} + } + fun pack6(x: u8, y: u8, z: u8): S { + let $f3 = x; + let $f2 = y; + S{f1: z,f2: $f2,f3: $f3} + } +} + ============ initial bytecode ================ [variant baseline] -fun pack_unpack::pack1($t0: u8, $t1: u8, $t2: u8): pack_unpack::S { - var $t3: pack_unpack::S - 0: $t3 := pack pack_unpack::S($t0, $t1, $t2) +fun pack_unpack::pack1($t0: u8, $t1: u8, $t2: u8): 0x42::pack_unpack::S { + var $t3: 0x42::pack_unpack::S + 0: $t3 := pack 0x42::pack_unpack::S($t0, $t1, $t2) 1: return $t3 } [variant baseline] -fun pack_unpack::pack2($t0: u8, $t1: u8, $t2: u8): pack_unpack::S { - var $t3: pack_unpack::S +fun pack_unpack::pack2($t0: u8, $t1: u8, $t2: u8): 0x42::pack_unpack::S { + var $t3: 0x42::pack_unpack::S var $t4: u8 var $t5: u8 0: $t4 := infer($t0) 1: $t5 := infer($t1) - 2: $t3 := pack pack_unpack::S($t4, $t2, $t5) + 2: $t3 := pack 0x42::pack_unpack::S($t4, $t2, $t5) 3: return $t3 } [variant baseline] -fun pack_unpack::pack3($t0: u8, $t1: u8, $t2: u8): pack_unpack::S { - var $t3: pack_unpack::S +fun pack_unpack::pack3($t0: u8, $t1: u8, $t2: u8): 0x42::pack_unpack::S { + var $t3: 0x42::pack_unpack::S var $t4: u8 0: $t4 := infer($t0) - 1: $t3 := pack pack_unpack::S($t1, $t4, $t2) + 1: $t3 := pack 0x42::pack_unpack::S($t1, $t4, $t2) 2: return $t3 } [variant baseline] -fun pack_unpack::pack4($t0: u8, $t1: u8, $t2: u8): pack_unpack::S { - var $t3: pack_unpack::S +fun pack_unpack::pack4($t0: u8, $t1: u8, $t2: u8): 0x42::pack_unpack::S { + var $t3: 0x42::pack_unpack::S var $t4: u8 var $t5: u8 0: $t4 := infer($t0) 1: $t5 := infer($t1) - 2: $t3 := pack pack_unpack::S($t2, $t4, $t5) + 2: $t3 := pack 0x42::pack_unpack::S($t2, $t4, $t5) 3: return $t3 } [variant baseline] -fun pack_unpack::pack5($t0: u8, $t1: u8, $t2: u8): pack_unpack::S { - var $t3: pack_unpack::S +fun pack_unpack::pack5($t0: u8, $t1: u8, $t2: u8): 0x42::pack_unpack::S { + var $t3: 0x42::pack_unpack::S var $t4: u8 0: $t4 := infer($t0) - 1: $t3 := pack pack_unpack::S($t1, $t2, $t4) + 1: $t3 := pack 0x42::pack_unpack::S($t1, $t2, $t4) 2: return $t3 } [variant baseline] -fun pack_unpack::pack6($t0: u8, $t1: u8, $t2: u8): pack_unpack::S { - var $t3: pack_unpack::S +fun pack_unpack::pack6($t0: u8, $t1: u8, $t2: u8): 0x42::pack_unpack::S { + var $t3: 0x42::pack_unpack::S var $t4: u8 var $t5: u8 0: $t4 := infer($t0) 1: $t5 := infer($t1) - 2: $t3 := pack pack_unpack::S($t2, $t5, $t4) + 2: $t3 := pack 0x42::pack_unpack::S($t2, $t5, $t4) 3: return $t3 } diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/pack_unpack.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/pack_unpack.exp index 2bb77b7ee5e8e..538ca510e66cd 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/pack_unpack.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/pack_unpack.exp @@ -5,12 +5,12 @@ module 0x42::pack_unpack { } struct S { f: u64, - g: pack_unpack::T, + g: 0x42::pack_unpack::T, } - private fun pack(x: u64,y: u64): pack_unpack::S { + private fun pack(x: u64,y: u64): 0x42::pack_unpack::S { pack pack_unpack::S(x, pack pack_unpack::T(y)) } - private fun unpack(s: pack_unpack::S): (u64, u64) { + private fun unpack(s: 0x42::pack_unpack::S): (u64, u64) { { let pack_unpack::S{ f, g: pack_unpack::T{ h } } = s; Tuple(f, h) @@ -18,27 +18,45 @@ module 0x42::pack_unpack { } } // end 0x42::pack_unpack +// -- Sourcified model before bytecode pipeline +module 0x42::pack_unpack { + struct T { + h: u64, + } + struct S { + f: u64, + g: T, + } + fun pack(x: u64, y: u64): S { + S{f: x,g: T{h: y}} + } + fun unpack(s: S): (u64, u64) { + let S{f: f,g: T{h: h}} = s; + (f, h) + } +} + ============ initial bytecode ================ [variant baseline] -fun pack_unpack::pack($t0: u64, $t1: u64): pack_unpack::S { - var $t2: pack_unpack::S - var $t3: pack_unpack::T - 0: $t3 := pack pack_unpack::T($t1) - 1: $t2 := pack pack_unpack::S($t0, $t3) +fun pack_unpack::pack($t0: u64, $t1: u64): 0x42::pack_unpack::S { + var $t2: 0x42::pack_unpack::S + var $t3: 0x42::pack_unpack::T + 0: $t3 := pack 0x42::pack_unpack::T($t1) + 1: $t2 := pack 0x42::pack_unpack::S($t0, $t3) 2: return $t2 } [variant baseline] -fun pack_unpack::unpack($t0: pack_unpack::S): (u64, u64) { +fun pack_unpack::unpack($t0: 0x42::pack_unpack::S): (u64, u64) { var $t1: u64 var $t2: u64 var $t3: u64 var $t4: u64 - var $t5: pack_unpack::T - 0: ($t3, $t5) := unpack pack_unpack::S($t0) - 1: $t4 := unpack pack_unpack::T($t5) + var $t5: 0x42::pack_unpack::T + 0: ($t3, $t5) := unpack 0x42::pack_unpack::S($t0) + 1: $t4 := unpack 0x42::pack_unpack::T($t5) 2: $t1 := infer($t3) 3: $t2 := infer($t4) 4: return ($t1, $t2) diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/reference_conversion.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/reference_conversion.exp index 406be0d625315..587b47b31883a 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/reference_conversion.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/reference_conversion.exp @@ -15,6 +15,19 @@ module 0x42::reference_conversion { } } // end 0x42::reference_conversion +// -- Sourcified model before bytecode pipeline +module 0x42::reference_conversion { + fun deref(r: &u64): u64 { + *r + } + fun use_it(): u64 { + let x = 42; + let r = &mut x; + *r = 43; + deref(/*freeze*/r) + } +} + ============ initial bytecode ================ [variant baseline] diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/spec_construct.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/spec_construct.exp index d304b793db035..65f990e067324 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/spec_construct.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/spec_construct.exp @@ -5,26 +5,39 @@ module 0x42::m { k: u8, } struct S { - data: vector, + data: vector<0x42::m::E>, } - public fun foo(v: &m::S): u8 { - select m::E.k<&m::E>(vector::borrow(Borrow(Immutable)(select m::S.data<&m::S>(v)), 0)) + public fun foo(v: &0x42::m::S): u8 { + select m::E.k<&E>(vector::borrow(Borrow(Immutable)(select m::S.data<&S>(v)), 0)) } } // end 0x42::m +// -- Sourcified model before bytecode pipeline +module 0x42::m { + struct E { + k: u8, + } + struct S { + data: vector, + } + public fun foo(v: &S): u8 { + 0x1::vector::borrow(&v.data, 0).k + } +} + ============ initial bytecode ================ [variant baseline] -public fun m::foo($t0: &m::S): u8 { +public fun m::foo($t0: &0x42::m::S): u8 { var $t1: u8 - var $t2: &m::E - var $t3: &vector + var $t2: &0x42::m::E + var $t3: &vector<0x42::m::E> var $t4: u64 var $t5: &u8 - 0: $t3 := borrow_field.data($t0) + 0: $t3 := borrow_field<0x42::m::S>.data($t0) 1: $t4 := 0 - 2: $t2 := vector::borrow($t3, $t4) - 3: $t5 := borrow_field.k($t2) + 2: $t2 := vector::borrow<0x42::m::E>($t3, $t4) + 3: $t5 := borrow_field<0x42::m::E>.k($t2) 4: $t1 := read_ref($t5) 5: return $t1 } diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/v1-commands/break_outside_loop.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/v1-commands/break_outside_loop.exp index 65d9bf167c6fb..30aff0255e225 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/v1-commands/break_outside_loop.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/v1-commands/break_outside_loop.exp @@ -5,6 +5,13 @@ module _0 { } } // end _0 +// -- Sourcified model before bytecode pipeline +script { + fun main() { + break + } +} + Diagnostics: error: missing enclosing loop statement diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/v1-commands/break_outside_loop_in_else.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/v1-commands/break_outside_loop_in_else.exp index fd3592ca4a473..d527f8cbda14d 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/v1-commands/break_outside_loop_in_else.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/v1-commands/break_outside_loop_in_else.exp @@ -10,6 +10,13 @@ module _0 { } } // end _0 +// -- Sourcified model before bytecode pipeline +script { + fun main() { + if (false) () else break; + } +} + Diagnostics: error: missing enclosing loop statement diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/v1-commands/break_outside_loop_in_if.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/v1-commands/break_outside_loop_in_if.exp index 4ba118a1a902b..37b5c4c56ce10 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/v1-commands/break_outside_loop_in_if.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/v1-commands/break_outside_loop_in_if.exp @@ -9,6 +9,13 @@ module _0 { } } // end _0 +// -- Sourcified model before bytecode pipeline +script { + fun main() { + if (true) break + } +} + Diagnostics: error: missing enclosing loop statement diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/v1-commands/continue_outside_loop.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/v1-commands/continue_outside_loop.exp index dd49daa2df427..53b0d1c9d22b9 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/v1-commands/continue_outside_loop.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/v1-commands/continue_outside_loop.exp @@ -5,6 +5,13 @@ module _0 { } } // end _0 +// -- Sourcified model before bytecode pipeline +script { + fun main() { + continue + } +} + Diagnostics: error: missing enclosing loop statement diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/v1-commands/continue_outside_loop_in_if.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/v1-commands/continue_outside_loop_in_if.exp index 9bca0da5da53c..5d59d11e23937 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/v1-commands/continue_outside_loop_in_if.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/v1-commands/continue_outside_loop_in_if.exp @@ -10,6 +10,13 @@ module _0 { } } // end _0 +// -- Sourcified model before bytecode pipeline +script { + fun main() { + if (true) continue; + } +} + Diagnostics: error: missing enclosing loop statement diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/v1-typing/global_invalid.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/v1-typing/global_invalid.exp index 21c2baac2a0de..34f06097556ec 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/v1-typing/global_invalid.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/v1-typing/global_invalid.exp @@ -14,6 +14,15 @@ module 0x42::m { } } // end 0x42::m +// -- Sourcified model before bytecode pipeline +module 0x42::m { + fun invalid(addr: address) { + if (exists(addr)) () else abort 0; + let _ = borrow_global(addr); + move_from(addr); + } +} + Diagnostics: error: Expected a struct type. Global storage operations are restricted to struct types declared in the current module. Found: 'T' diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/v1-typing/mutate_immutable.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/v1-typing/mutate_immutable.exp index 6f70d7b27924b..f5a7cc7aba81a 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/v1-typing/mutate_immutable.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/v1-typing/mutate_immutable.exp @@ -3,7 +3,7 @@ module 0x8675309::M { struct S { f: u64, } - private fun t0(s: &mut M::S) { + private fun t0(s: &mut 0x8675309::M::S) { s = pack M::S(0); Borrow(Immutable)(0) = 1; { @@ -20,9 +20,24 @@ module 0x8675309::M { } } // end 0x8675309::M +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct S has drop { + f: u64, + } + fun t0(s: &mut S) { + *s = S{f: 0}; + *&0 = 1; + let x = 0; + let x_ref = &mut x; + let x_ref = /*freeze*/x_ref; + *x_ref = 0; + } +} + Diagnostics: -error: expected `&mut` but found `&M::S` +error: expected `&mut` but found `&S` ┌─ tests/bytecode-generator/v1-typing/mutate_immutable.move:5:11 │ 5 │ *(s: &S) = S { f: 0 }; diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/vector.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/vector.exp index 278b6ca0e9eda..8843ffc5a4ac7 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/vector.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/vector.exp @@ -5,6 +5,13 @@ module 0x42::vector { } } // end 0x42::vector +// -- Sourcified model before bytecode pipeline +module 0x42::vector { + fun create(): vector { + vector[1, 2, 3] + } +} + ============ initial bytecode ================ [variant baseline] diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard2.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard2.exp index dd31701d7fac8..ac8b896a9e622 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard2.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard2.exp @@ -11,6 +11,14 @@ module 0xc0ffee::m { } } // end 0xc0ffee::m +// -- Sourcified model before bytecode pipeline +module 0xc0ffee::m { + public fun baz() { + let x; + let _ = x; + } +} + ============ initial bytecode ================ [variant baseline] diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard3.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard3.exp index 8b17531c4b9e8..ce586a539c721 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard3.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard3.exp @@ -5,51 +5,64 @@ module 0xc0ffee::m { } public fun bar() { { - let s: m::S = pack m::S(false); + let s: S = pack m::S(false); { - let _: m::S = s; + let _: S = s; Tuple() } } } - public fun foo(s: m::S) { + public fun foo(s: 0xc0ffee::m::S) { { - let _: m::S = s; + let _: S = s; Tuple() } } } // end 0xc0ffee::m +// -- Sourcified model before bytecode pipeline +module 0xc0ffee::m { + struct S { + } + public fun bar() { + let s = S{}; + let _ = s; + } + public fun foo(s: S) { + let _ = s; + } +} + ============ initial bytecode ================ [variant baseline] public fun m::bar() { - var $t0: m::S + var $t0: 0xc0ffee::m::S var $t1: bool - var $t2: m::S + var $t2: 0xc0ffee::m::S 0: $t1 := false - 1: $t0 := pack m::S($t1) + 1: $t0 := pack 0xc0ffee::m::S($t1) 2: $t2 := infer($t0) 3: return () } [variant baseline] -public fun m::foo($t0: m::S) { - var $t1: m::S +public fun m::foo($t0: 0xc0ffee::m::S) { + var $t1: 0xc0ffee::m::S 0: $t1 := infer($t0) 1: return () } Diagnostics: -error: value of type `m::S` does not have the `drop` ability +error: value of type `S` does not have the `drop` ability ┌─ tests/bytecode-generator/wildcard3.move:5:13 │ 5 │ let _ = s; │ ^ implicitly dropped here since it is no longer used -error: value of type `m::S` does not have the `drop` ability +error: value of type `S` does not have the `drop` ability ┌─ tests/bytecode-generator/wildcard3.move:10:13 │ 10 │ let _ = s; diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard4.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard4.exp index 10580ab9b060f..60d6ee1b6c7c2 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard4.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard4.exp @@ -18,6 +18,17 @@ module 0xc0ffee::m { } } // end 0xc0ffee::m +// -- Sourcified model before bytecode pipeline +module 0xc0ffee::m { + fun test() { + let x = 3; + let r = &mut x; + let y = &mut x; + let _ = /*freeze*/y; + *r = 4; + } +} + ============ initial bytecode ================ [variant baseline] diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard5.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard5.exp index 1608427e72ff7..44dca347d8756 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard5.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard5.exp @@ -6,7 +6,7 @@ module 0xc0ffee::m { } public fun test() { { - let s: m::S = pack m::S(3, 4); + let s: S = pack m::S(3, 4); { let m::S{ x: _, y: _ } = s; Tuple() @@ -15,19 +15,31 @@ module 0xc0ffee::m { } } // end 0xc0ffee::m +// -- Sourcified model before bytecode pipeline +module 0xc0ffee::m { + struct S { + x: u64, + y: u64, + } + public fun test() { + let s = S{x: 3,y: 4}; + let S{x: _,y: _} = s; + } +} + ============ initial bytecode ================ [variant baseline] public fun m::test() { - var $t0: m::S + var $t0: 0xc0ffee::m::S var $t1: u64 var $t2: u64 var $t3: u64 var $t4: u64 0: $t1 := 3 1: $t2 := 4 - 2: $t0 := pack m::S($t1, $t2) - 3: ($t3, $t4) := unpack m::S($t0) + 2: $t0 := pack 0xc0ffee::m::S($t1, $t2) + 3: ($t3, $t4) := unpack 0xc0ffee::m::S($t0) 4: return () } diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard6.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard6.exp index a7e13399a8a0e..da81e9dba809e 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard6.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard6.exp @@ -11,6 +11,15 @@ module 0xc0ffee::m { } } // end 0xc0ffee::m +// -- Sourcified model before bytecode pipeline +module 0xc0ffee::m { + public fun test2(): u64 { + let x = 40; + let (y,_) = (move x, x); + y + } +} + ============ initial bytecode ================ [variant baseline] diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard7.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard7.exp index 86431acca3905..255518c657e76 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard7.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard7.exp @@ -22,6 +22,16 @@ module 0xc0ffee::m { } } // end 0xc0ffee::m +// -- Sourcified model before bytecode pipeline +module 0xc0ffee::m { + public fun test(): u8 { + let x = 40u8; + let y = move x; + let (_,q) = (x, 30); + y + } +} + ============ initial bytecode ================ [variant baseline] diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard8.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard8.exp index 5b6d62f20943e..f564b6003d986 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard8.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard8.exp @@ -11,6 +11,14 @@ module 0xc0ffee::m { } } // end 0xc0ffee::m +// -- Sourcified model before bytecode pipeline +module 0xc0ffee::m { + public fun test() { + let x; + let (_,_) = (x, x); + } +} + ============ initial bytecode ================ [variant baseline] diff --git a/third_party/move/move-compiler-v2/tests/checking-lang-v1/entry_inline_err_no_report.exp b/third_party/move/move-compiler-v2/tests/checking-lang-v1/entry_inline_err_no_report.exp index 65d74465d64d0..3483724ff69a6 100644 --- a/third_party/move/move-compiler-v2/tests/checking-lang-v1/entry_inline_err_no_report.exp +++ b/third_party/move/move-compiler-v2/tests/checking-lang-v1/entry_inline_err_no_report.exp @@ -12,3 +12,16 @@ module 0x123::b { b::a() } } // end 0x123::b + +// -- Sourcified model before bytecode pipeline +module 0x123::a { + friend entry fun a() { + } +} +module 0x123::b { + entry fun a() { + } + fun b() { + a() + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking-lang-v1/eq_inline_typed.exp b/third_party/move/move-compiler-v2/tests/checking-lang-v1/eq_inline_typed.exp index 7eecb2c8d0891..13aa78ff14597 100644 --- a/third_party/move/move-compiler-v2/tests/checking-lang-v1/eq_inline_typed.exp +++ b/third_party/move/move-compiler-v2/tests/checking-lang-v1/eq_inline_typed.exp @@ -16,3 +16,12 @@ module 0x42::m { Tuple() } } // end 0x42::m + +// -- Sourcified model before bytecode pipeline +module 0x42::m { + inline fun foo(f: |&u64|) { + } + fun g() { + (); + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking-lang-v1/use_struct_overlap_with_module.exp b/third_party/move/move-compiler-v2/tests/checking-lang-v1/use_struct_overlap_with_module.exp index 8b717c666f02b..e9e0328eb51f1 100644 --- a/third_party/move/move-compiler-v2/tests/checking-lang-v1/use_struct_overlap_with_module.exp +++ b/third_party/move/move-compiler-v2/tests/checking-lang-v1/use_struct_overlap_with_module.exp @@ -6,8 +6,21 @@ module 0x2::X { } // end 0x2::X module 0x2::M { use 0x2::X::{Self, S as X}; // resolved as: 0x2::X + struct A { + f1: 0x2::X::S, + f2: 0x2::X::S, + } +} // end 0x2::M + +// -- Sourcified model before bytecode pipeline +module 0x2::X { + struct S { + } +} +module 0x2::M { + use 0x2::X; struct A { f1: X::S, f2: X::S, } -} // end 0x2::M +} diff --git a/third_party/move/move-compiler-v2/tests/checking/abilities/tuple.exp b/third_party/move/move-compiler-v2/tests/checking/abilities/tuple.exp index 132846113b36a..9179e41d22c3a 100644 --- a/third_party/move/move-compiler-v2/tests/checking/abilities/tuple.exp +++ b/third_party/move/move-compiler-v2/tests/checking/abilities/tuple.exp @@ -3,13 +3,27 @@ module 0x42::tuple { struct S { f: u64, } - private fun tuple(x: u64): (u64, tuple::S) { + private fun tuple(x: u64): (u64, 0x42::tuple::S) { Tuple(x, pack tuple::S(Add(x, 1))) } private fun use_tuple(x: u64): u64 { { - let (x: u64, tuple::S{ f: y }): (u64, tuple::S) = tuple::tuple(x); + let (x: u64, tuple::S{ f: y }): (u64, S) = tuple::tuple(x); Add(x, y) } } } // end 0x42::tuple + +// -- Sourcified model before bytecode pipeline +module 0x42::tuple { + struct S { + f: u64, + } + fun tuple(x: u64): (u64, S) { + (x, S{f: x + 1}) + } + fun use_tuple(x: u64): u64 { + let (x,S{f: y}) = tuple(x); + x + y + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/abilities/v1/ability_constraints.exp b/third_party/move/move-compiler-v2/tests/checking/abilities/v1/ability_constraints.exp index 93bcfd12e634f..dcaf90f90259f 100644 --- a/third_party/move/move-compiler-v2/tests/checking/abilities/v1/ability_constraints.exp +++ b/third_party/move/move-compiler-v2/tests/checking/abilities/v1/ability_constraints.exp @@ -125,75 +125,75 @@ module 0x42::M { let M::Ssk{ dummy_field: _ } = pack M::Ssk(false); { let M::Scds{ dummy_field: _ } = pack M::Scds(false); - M::c(); - M::c>(); - M::c, M::S>>(); - M::d(); - M::d>(); - M::d, M::S>>(); - M::s(); - M::s(); - M::s>(); - M::s>(); - M::s, M::S>>(); - M::s>>>(); - M::k(); - M::k>(); - M::k>>(); - M::k>>>(); - M::sk(); - M::sk>(); - M::sk>>(); - M::sk>>>(); - M::cds(); - M::cds>(); - M::cds, M::S>>(); + M::c(); + M::c>(); + M::c, S>>(); + M::d(); + M::d>(); + M::d, S>>(); + M::s(); + M::s(); + M::s>(); + M::s>(); + M::s, S>>(); + M::s>>>(); + M::k(); + M::k>(); + M::k>>(); + M::k>>>(); + M::sk(); + M::sk>(); + M::sk>>(); + M::sk>>>(); + M::cds(); + M::cds>(); + M::cds, S>>(); { - let M::Sc{ dummy_field: _ } = pack M::Sc(false); + let M::Sc{ dummy_field: _ } = pack M::Sc(false); { - let M::Sc>{ dummy_field: _ } = pack M::Sc>(false); + let M::Sc>{ dummy_field: _ } = pack M::Sc>(false); { - let M::Sc, M::S>>{ dummy_field: _ } = pack M::Sc, M::S>>(false); + let M::Sc, S>>{ dummy_field: _ } = pack M::Sc, S>>(false); { - let M::Sd{ dummy_field: _ } = pack M::Sd(false); + let M::Sd{ dummy_field: _ } = pack M::Sd(false); { - let M::Sd>{ dummy_field: _ } = pack M::Sd>(false); + let M::Sd>{ dummy_field: _ } = pack M::Sd>(false); { - let M::Sd, M::S>>{ dummy_field: _ } = pack M::Sd, M::S>>(false); + let M::Sd, S>>{ dummy_field: _ } = pack M::Sd, S>>(false); { - let M::Ss{ dummy_field: _ } = pack M::Ss(false); + let M::Ss{ dummy_field: _ } = pack M::Ss(false); { - let M::Ss{ dummy_field: _ } = pack M::Ss(false); + let M::Ss{ dummy_field: _ } = pack M::Ss(false); { - let M::Ss>{ dummy_field: _ } = pack M::Ss>(false); + let M::Ss>{ dummy_field: _ } = pack M::Ss>(false); { - let M::Ss>{ dummy_field: _ } = pack M::Ss>(false); + let M::Ss>{ dummy_field: _ } = pack M::Ss>(false); { - let M::Ss, M::S>>{ dummy_field: _ } = pack M::Ss, M::S>>(false); + let M::Ss, S>>{ dummy_field: _ } = pack M::Ss, S>>(false); { - let M::Ss>>>{ dummy_field: _ } = pack M::Ss>>>(false); + let M::Ss>>>{ dummy_field: _ } = pack M::Ss>>>(false); { - let M::Sk{ dummy_field: _ } = pack M::Sk(false); + let M::Sk{ dummy_field: _ } = pack M::Sk(false); { - let M::Sk>{ dummy_field: _ } = pack M::Sk>(false); + let M::Sk>{ dummy_field: _ } = pack M::Sk>(false); { - let M::Sk>>{ dummy_field: _ } = pack M::Sk>>(false); + let M::Sk>>{ dummy_field: _ } = pack M::Sk>>(false); { - let M::Sk>>>{ dummy_field: _ } = pack M::Sk>>>(false); + let M::Sk>>>{ dummy_field: _ } = pack M::Sk>>>(false); { - let M::Ssk{ dummy_field: _ } = pack M::Ssk(false); + let M::Ssk{ dummy_field: _ } = pack M::Ssk(false); { - let M::Ssk>{ dummy_field: _ } = pack M::Ssk>(false); + let M::Ssk>{ dummy_field: _ } = pack M::Ssk>(false); { - let M::Ssk>>{ dummy_field: _ } = pack M::Ssk>>(false); + let M::Ssk>>{ dummy_field: _ } = pack M::Ssk>>(false); { - let M::Ssk>>>{ dummy_field: _ } = pack M::Ssk>>>(false); + let M::Ssk>>>{ dummy_field: _ } = pack M::Ssk>>>(false); { - let M::Scds{ dummy_field: _ } = pack M::Scds(false); + let M::Scds{ dummy_field: _ } = pack M::Scds(false); { - let M::Scds>{ dummy_field: _ } = pack M::Scds>(false); + let M::Scds>{ dummy_field: _ } = pack M::Scds>(false); { - let M::Scds, M::S>>{ dummy_field: _ } = pack M::Scds, M::S>>(false); + let M::Scds, S>>{ dummy_field: _ } = pack M::Scds, S>>(false); Tuple() } } @@ -245,3 +245,140 @@ module 0x42::M { } } } // end 0x42::M + +// -- Sourcified model before bytecode pipeline +module 0x42::M { + struct Box has copy, drop, store, key { + f: T, + } + struct Pair has copy, drop, store, key { + f1: T1, + f2: T2, + } + struct R has store, key { + } + struct S has copy, drop, store, key { + } + struct Sc { + } + struct Scds { + } + struct Sd { + } + struct Sk { + } + struct Ss { + } + struct Ssk { + } + fun c() { + } + fun cds() { + } + fun d() { + } + fun k() { + } + fun s() { + } + fun sk() { + } + fun t1() { + c(); + d(); + s(); + cds
(); + c>(); + d>(); + s>(); + cds>(); + let Sc{} = Sc{}; + let Sd{} = Sd{}; + let Ss{} = Ss{}; + let Scds
{} = Scds
{}; + let Sc>{} = Sc>{}; + let Sd>{} = Sd>{}; + let Ss>{} = Ss>{}; + let Scds>{} = Scds>{}; + c(); + c(); + c(); + c(); + d(); + d(); + d(); + d(); + s(); + s(); + s(); + s(); + s(); + k(); + k(); + sk(); + cds(); + let Sc{} = Sc{}; + let Sc{} = Sc{}; + let Sc{} = Sc{}; + let Sc{} = Sc{}; + let Sd{} = Sd{}; + let Sd{} = Sd{}; + let Sd{} = Sd{}; + let Sd{} = Sd{}; + let Ss{} = Ss{}; + let Ss{} = Ss{}; + let Ss{} = Ss{}; + let Ss{} = Ss{}; + let Ss{} = Ss{}; + let Sk{} = Sk{}; + let Sk{} = Sk{}; + let Ssk{} = Ssk{}; + let Scds{} = Scds{}; + c(); + c>(); + c, S>>(); + d(); + d>(); + d, S>>(); + s(); + s(); + s>(); + s>(); + s, S>>(); + s>>>(); + k(); + k>(); + k>>(); + k>>>(); + sk(); + sk>(); + sk>>(); + sk>>>(); + cds(); + cds>(); + cds, S>>(); + let Sc{} = Sc{}; + let Sc>{} = Sc>{}; + let Sc, S>>{} = Sc, S>>{}; + let Sd{} = Sd{}; + let Sd>{} = Sd>{}; + let Sd, S>>{} = Sd, S>>{}; + let Ss{} = Ss{}; + let Ss{} = Ss{}; + let Ss>{} = Ss>{}; + let Ss>{} = Ss>{}; + let Ss, S>>{} = Ss, S>>{}; + let Ss>>>{} = Ss>>>{}; + let Sk{} = Sk{}; + let Sk>{} = Sk>{}; + let Sk>>{} = Sk>>{}; + let Sk>>>{} = Sk>>>{}; + let Ssk{} = Ssk{}; + let Ssk>{} = Ssk>{}; + let Ssk>>{} = Ssk>>{}; + let Ssk>>>{} = Ssk>>>{}; + let Scds{} = Scds{}; + let Scds>{} = Scds>{}; + let Scds, S>>{} = Scds, S>>{}; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/abilities/v1/phantom_param_op_abilities.exp b/third_party/move/move-compiler-v2/tests/checking/abilities/v1/phantom_param_op_abilities.exp index 438f27a7322ab..65fc58b4fccf4 100644 --- a/third_party/move/move-compiler-v2/tests/checking/abilities/v1/phantom_param_op_abilities.exp +++ b/third_party/move/move-compiler-v2/tests/checking/abilities/v1/phantom_param_op_abilities.exp @@ -18,33 +18,79 @@ module 0x42::M { struct RequireStore { a: #0, } - private fun f1(ref: &mut M::HasDrop) { - ref = pack M::HasDrop(1); + private fun f1(ref: &mut 0x42::M::HasDrop<0x42::M::NoAbilities, u64>) { + ref = pack M::HasDrop(1); Tuple() } private fun f2() { - _: M::HasDrop = pack M::HasDrop(1); + _: HasDrop = pack M::HasDrop(1); Tuple() } - private fun f3(_x: M::HasDrop) { + private fun f3(_x: 0x42::M::HasDrop<0x42::M::NoAbilities, u64>) { Tuple() } - private fun f4(x: M::HasCopy): (M::HasCopy, M::HasCopy) { + private fun f4(x: 0x42::M::HasCopy<0x42::M::NoAbilities, u64>): (0x42::M::HasCopy<0x42::M::NoAbilities, u64>, 0x42::M::HasCopy<0x42::M::NoAbilities, u64>) { Tuple(Copy(x), x) } - private fun f5(s: &signer,x: M::HasKey) { - MoveTo>(s, x); + private fun f5(s: &signer,x: 0x42::M::HasKey<0x42::M::NoAbilities, u64>) { + MoveTo>(s, x); Tuple() } - private fun f6(): M::HasKey - acquires M::HasKey(*) + private fun f6(): 0x42::M::HasKey<0x42::M::NoAbilities, u64> + acquires 0x42::M::HasKey(*) { - MoveFrom>(0x0) + MoveFrom>(0x0) } private fun f7(): bool { - exists>(0x0) + exists>(0x0) } - private fun f8(): M::RequireStore> { - pack M::RequireStore>(pack M::HasStore(1)) + private fun f8(): 0x42::M::RequireStore<0x42::M::HasStore<0x42::M::NoAbilities, u64>> { + pack M::RequireStore>(pack M::HasStore(1)) } } // end 0x42::M + +// -- Sourcified model before bytecode pipeline +module 0x42::M { + struct HasCopy has copy { + a: T2, + } + struct HasDrop has drop { + a: T2, + } + struct HasKey has key { + a: T2, + } + struct HasStore has store { + a: T2, + } + struct NoAbilities { + } + struct RequireStore { + a: T, + } + fun f1(ref: &mut HasDrop) { + *ref = HasDrop{a: 1}; + } + fun f2() { + _ = HasDrop{a: 1}; + } + fun f3(_x: HasDrop) { + } + fun f4(x: HasCopy): (HasCopy, HasCopy) { + (copy x, x) + } + fun f5(s: &signer, x: HasKey) { + move_to>(s, x); + } + fun f6(): HasKey + acquires HasKey + { + move_from>(0x0) + } + fun f7(): bool { + exists>(0x0) + } + fun f8(): RequireStore> { + RequireStore>{a: HasStore{a: 1}} + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/abilities/v1/phantom_params_constraint_abilities.exp b/third_party/move/move-compiler-v2/tests/checking/abilities/v1/phantom_params_constraint_abilities.exp index cbc230acd5142..5666042391855 100644 --- a/third_party/move/move-compiler-v2/tests/checking/abilities/v1/phantom_params_constraint_abilities.exp +++ b/third_party/move/move-compiler-v2/tests/checking/abilities/v1/phantom_params_constraint_abilities.exp @@ -22,7 +22,7 @@ module 0x42::M { a: #0, } struct S2 { - a: M::S1>, + a: 0x42::M::S1<0x42::M::HasAbilities<0x42::M::NoAbilities, u64>>, } struct S3 { a: #0, @@ -31,20 +31,67 @@ module 0x42::M { d: #3, } struct S4 { - a: M::S3, M::HasCopy, M::HasStore, M::HasKey>, + a: 0x42::M::S3<0x42::M::HasDrop<0x42::M::NoAbilities, u64>, 0x42::M::HasCopy<0x42::M::NoAbilities, u64>, 0x42::M::HasStore<0x42::M::NoAbilities, u64>, 0x42::M::HasKey<0x42::M::NoAbilities, u64>>, } private fun f1() { Tuple() } private fun f2() { - M::f1>(); + M::f1>(); Tuple() } private fun f3() { Tuple() } private fun f4() { - M::f3, M::HasCopy, M::HasStore, M::HasKey>(); + M::f3, HasCopy, HasStore, HasKey>(); Tuple() } } // end 0x42::M + +// -- Sourcified model before bytecode pipeline +module 0x42::M { + struct HasAbilities has copy, drop, store, key { + a: T2, + } + struct HasCopy has copy { + a: T2, + } + struct HasDrop has drop { + a: T2, + } + struct HasKey has key { + a: T2, + } + struct HasStore has store { + a: T2, + } + struct NoAbilities { + a: bool, + } + struct S1 { + a: T, + } + struct S2 { + a: S1>, + } + struct S3 { + a: T1, + b: T2, + c: T3, + d: T4, + } + struct S4 { + a: S3, HasCopy, HasStore, HasKey>, + } + fun f1() { + } + fun f2() { + f1>(); + } + fun f3() { + } + fun f4() { + f3,HasCopy,HasStore,HasKey>(); + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/abilities/v1/phantom_params_field_abilities.exp b/third_party/move/move-compiler-v2/tests/checking/abilities/v1/phantom_params_field_abilities.exp index bfa5c712d716a..c9c9943eb3973 100644 --- a/third_party/move/move-compiler-v2/tests/checking/abilities/v1/phantom_params_field_abilities.exp +++ b/third_party/move/move-compiler-v2/tests/checking/abilities/v1/phantom_params_field_abilities.exp @@ -16,15 +16,45 @@ module 0x42::M { dummy_field: bool, } struct S1 { - a: M::HasDrop, + a: 0x42::M::HasDrop<0x42::M::NoAbilities, u64>, } struct S2 { - a: M::HasCopy, + a: 0x42::M::HasCopy<0x42::M::NoAbilities, u64>, } struct S3 { - a: M::HasStore, + a: 0x42::M::HasStore<0x42::M::NoAbilities, u64>, } struct S4 { - a: M::HasStore, + a: 0x42::M::HasStore<0x42::M::NoAbilities, u64>, } } // end 0x42::M + +// -- Sourcified model before bytecode pipeline +module 0x42::M { + struct HasCopy has copy { + a: T2, + } + struct HasDrop has drop { + a: T2, + } + struct HasKey has key { + a: T2, + } + struct HasStore has store { + a: T2, + } + struct NoAbilities { + } + struct S1 has drop { + a: HasDrop, + } + struct S2 has copy { + a: HasCopy, + } + struct S3 has store { + a: HasStore, + } + struct S4 has key { + a: HasStore, + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/access_specifiers/access_ok.exp b/third_party/move/move-compiler-v2/tests/checking/access_specifiers/access_ok.exp index b2e3bc2231280..6482442cfa288 100644 --- a/third_party/move/move-compiler-v2/tests/checking/access_specifiers/access_ok.exp +++ b/third_party/move/move-compiler-v2/tests/checking/access_specifiers/access_ok.exp @@ -33,7 +33,7 @@ module 0x42::m { dummy_field: bool, } private fun f1() - acquires m::S(*) + acquires 0x42::m::S(*) { Tuple() } @@ -53,17 +53,17 @@ module 0x42::m { Tuple() } private fun f2() - reads m::S(*) + reads 0x42::m::S(*) { Tuple() } private fun f3() - writes m::S(*) + writes 0x42::m::S(*) { Tuple() } private fun f4() - acquires m::S(*) + acquires 0x42::m::S(*) { Tuple() } @@ -93,11 +93,11 @@ module 0x42::m { Tuple() } private fun f_multiple() - acquires m::R(*) - reads m::R(*) - writes m::T(*) - writes m::S(*) - reads m::G(*) + acquires 0x42::m::R(*) + reads 0x42::m::R(*) + writes 0x42::m::T(*) + writes 0x42::m::S(*) + reads 0x42::m::G(*) { Tuple() } @@ -105,3 +105,75 @@ module 0x42::m { 0x42 } } // end 0x42::m + +// -- Sourcified model before bytecode pipeline +module 0x42::m { + struct T has store { + } + struct G has store { + } + struct R has store { + } + struct S has store { + } + fun f1() + acquires S + { + } + fun f10(x: u64) + acquires *(m::make_up_address(x)) + + { + } + fun f11() + !reads *(0x42) + !reads *(0x43) + + { + } + fun f12() + + { + } + fun f2() + reads S + { + } + fun f3() + writes S + { + } + fun f4() + acquires S + { + } + fun f5() + acquires 0x42::* + { + } + fun f6() + acquires 0x42::m::* + { + } + fun f7() + acquires * + { + } + fun f8() + acquires *(0x42) + + { + } + fun f9(a: address) + acquires *(a) + + { + } + fun f_multiple() + acquires Rreads Rwrites Twrites Sreads G + { + } + fun make_up_address(x: u64): address { + 0x42 + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/access_specifiers/acquires_list_generic.exp b/third_party/move/move-compiler-v2/tests/checking/access_specifiers/acquires_list_generic.exp index fa0d50a8ea13d..1c78e50c8f0b2 100644 --- a/third_party/move/move-compiler-v2/tests/checking/access_specifiers/acquires_list_generic.exp +++ b/third_party/move/move-compiler-v2/tests/checking/access_specifiers/acquires_list_generic.exp @@ -10,8 +10,23 @@ module 0x42::M { dummy_field: bool, } private fun foo() - acquires M::B>(*) + acquires 0x42::M::B<0x42::M::CupC<0x42::M::R>>(*) { Abort(0) } } // end 0x42::M + +// -- Sourcified model before bytecode pipeline +module 0x42::M { + struct B { + } + struct CupC { + } + struct R { + } + fun foo() + acquires B> + { + abort 0 + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/attributes/aptos_stdlib_attributes2.exp b/third_party/move/move-compiler-v2/tests/checking/attributes/aptos_stdlib_attributes2.exp index 094f58d19cec5..0b0e0375c67f8 100644 --- a/third_party/move/move-compiler-v2/tests/checking/attributes/aptos_stdlib_attributes2.exp +++ b/third_party/move/move-compiler-v2/tests/checking/attributes/aptos_stdlib_attributes2.exp @@ -15,3 +15,11 @@ module 0x1::M { Tuple() } } // end 0x1::M + +// -- Sourcified model before bytecode pipeline +module 0x1::M { + fun bar() { + } + fun foo() { + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/attributes/attribute_placement.exp b/third_party/move/move-compiler-v2/tests/checking/attributes/attribute_placement.exp index 9798299691c27..082f863b09a34 100644 --- a/third_party/move/move-compiler-v2/tests/checking/attributes/attribute_placement.exp +++ b/third_party/move/move-compiler-v2/tests/checking/attributes/attribute_placement.exp @@ -106,3 +106,24 @@ module _0 { Tuple() } } // end _0 + +// -- Sourcified model before bytecode pipeline +module 0x42::N { + friend 0x42::M; + public fun bar() { + } +} +module 0x42::M { + use 0x42::N; + struct S { + } + public fun foo() { + N::bar() + } +} +script { + use 0x42::M; + fun main() { + M::foo(); + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/attributes/attribute_variants.exp b/third_party/move/move-compiler-v2/tests/checking/attributes/attribute_variants.exp index c8f499f0d0cbe..9f6a73399eca2 100644 --- a/third_party/move/move-compiler-v2/tests/checking/attributes/attribute_variants.exp +++ b/third_party/move/move-compiler-v2/tests/checking/attributes/attribute_variants.exp @@ -63,3 +63,7 @@ warning: unknown attribute // -- Model dump before bytecode pipeline module 0x42::M { } // end 0x42::M + +// -- Sourcified model before bytecode pipeline +module 0x42::M { +} diff --git a/third_party/move/move-compiler-v2/tests/checking/control_flow/loop_after_loop.exp b/third_party/move/move-compiler-v2/tests/checking/control_flow/loop_after_loop.exp index 08bf31d7ac079..74054ff1f182e 100644 --- a/third_party/move/move-compiler-v2/tests/checking/control_flow/loop_after_loop.exp +++ b/third_party/move/move-compiler-v2/tests/checking/control_flow/loop_after_loop.exp @@ -9,3 +9,11 @@ module _0 { } } } // end _0 + +// -- Sourcified model before bytecode pipeline +script { + fun main() { + loop break; + loop () + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/dotdot/dotdot_valid.exp b/third_party/move/move-compiler-v2/tests/checking/dotdot/dotdot_valid.exp index cd061f4b76d74..38c97b75a97a8 100644 --- a/third_party/move/move-compiler-v2/tests/checking/dotdot/dotdot_valid.exp +++ b/third_party/move/move-compiler-v2/tests/checking/dotdot/dotdot_valid.exp @@ -10,7 +10,7 @@ module 0x42::test { } C { x: u8, - y: test::S1, + y: 0x42::test::S1, } } struct S0 { @@ -21,7 +21,7 @@ module 0x42::test { } struct S2 { 0: bool, - 1: test::S0, + 1: 0x42::test::S0, } struct S3 { x: bool, @@ -29,7 +29,7 @@ module 0x42::test { } struct S4 { x: #0, - y: test::S3, + y: 0x42::test::S3, } struct S5 { 0: #0, @@ -45,13 +45,13 @@ module 0x42::test { 2: u32, 3: u64, } - private inline fun lambda_param(f: |test::S2|bool): bool { + private inline fun lambda_param(f: |0x42::test::S2|bool): bool { { - let x: test::S2 = pack test::S2(true, pack test::S0(false)); + let x: S2 = pack test::S2(true, pack test::S0(false)); (f)(x) } } - private fun nested1(x: test::S4) { + private fun nested1(x: 0x42::test::S4) { { let test::S4{ x: _x, y: _ } = x; { @@ -75,7 +75,7 @@ module 0x42::test { } } } - private fun nested1_ref(x: &test::S4) { + private fun nested1_ref(x: &0x42::test::S4) { { let test::S4{ x: _x, y: _ } = x; { @@ -99,67 +99,67 @@ module 0x42::test { } } } - private fun nested2(x: test::S5) { + private fun nested2(x: 0x42::test::S5) { { - let test::S5{ 0: _, 1: test::S1{ 0: _ } } = x; + let test::S5{ 0: _, 1: test::S1{ 0: _ } } = x; Tuple() } } - private fun nested2_ref(x: &test::S5) { + private fun nested2_ref(x: &0x42::test::S5) { { - let test::S5{ 0: _, 1: test::S1{ 0: _ } } = x; + let test::S5{ 0: _, 1: test::S1{ 0: _ } } = x; Tuple() } } - private fun nested3(x: test::S5>) { + private fun nested3(x: 0x42::test::S5>) { { - let test::S5>{ 0: _, 1: test::S4{ x: _, y: _ } } = x; + let test::S5>{ 0: _, 1: test::S4{ x: _, y: _ } } = x; Tuple() } } - private fun nested3_ref(x: &test::S5>) { + private fun nested3_ref(x: &0x42::test::S5>) { { - let test::S5>{ 0: _, 1: test::S4{ x: _, y: _ } } = x; + let test::S5>{ 0: _, 1: test::S4{ x: _, y: _ } } = x; Tuple() } } - private fun nested4(x: test::S4) { + private fun nested4(x: 0x42::test::S4<0x42::test::S1>) { { - let test::S4{ x: test::S1{ 0: _ }, y: _ } = x; + let test::S4{ x: test::S1{ 0: _ }, y: _ } = x; Tuple() } } - private fun nested4_ref(x: &test::S4) { + private fun nested4_ref(x: &0x42::test::S4<0x42::test::S1>) { { - let test::S4{ x: test::S1{ 0: _ }, y: _ } = x; + let test::S4{ x: test::S1{ 0: _ }, y: _ } = x; Tuple() } } - private fun simple_0(x: test::S0) { + private fun simple_0(x: 0x42::test::S0) { { let test::S0{ dummy_field: _ } = x; Tuple() } } - private fun simple_0_ref(x: &test::S0) { + private fun simple_0_ref(x: &0x42::test::S0) { { let test::S0{ dummy_field: _ } = x; Tuple() } } - private fun simple_1(x: test::S1) { + private fun simple_1(x: 0x42::test::S1) { { let test::S1{ 0: _ } = x; Tuple() } } - private fun simple_1_ref(x: &mut test::S1) { + private fun simple_1_ref(x: &mut 0x42::test::S1) { { let test::S1{ 0: _ } = x; Tuple() } } - private fun simple_2(x: test::S2) { + private fun simple_2(x: 0x42::test::S2) { { let test::S2{ 0: _, 1: _ } = x; { @@ -186,7 +186,7 @@ module 0x42::test { } } } - private fun simple_2_ref(x: &test::S2) { + private fun simple_2_ref(x: &0x42::test::S2) { { let test::S2{ 0: _, 1: _ } = x; { @@ -213,7 +213,7 @@ module 0x42::test { } } } - private fun simple_3(x: test::S3) { + private fun simple_3(x: 0x42::test::S3) { { let test::S3{ x: _, y: _ } = x; { @@ -225,7 +225,7 @@ module 0x42::test { } } } - private fun simple_3_ref(x: test::S3) { + private fun simple_3_ref(x: 0x42::test::S3) { { let test::S3{ x: _, y: _ } = x; { @@ -237,7 +237,7 @@ module 0x42::test { } } } - private fun simple_4(x: test::E1): u8 { + private fun simple_4(x: 0x42::test::E1): u8 { match (x) { test::E1::A{ 0: x, 1: _ } => { x @@ -251,7 +251,7 @@ module 0x42::test { } } - private fun simple_4_ref(x: &test::E1): &u8 { + private fun simple_4_ref(x: &0x42::test::E1): &u8 { match (x) { test::E1::A{ 0: x, 1: _ } => { x @@ -262,7 +262,7 @@ module 0x42::test { } } - private fun simple_5(x: test::E1): u8 { + private fun simple_5(x: 0x42::test::E1): u8 { match (x) { test::E1::A{ 0: _, 1: y } => { if y { @@ -280,7 +280,7 @@ module 0x42::test { } } - private fun simple_6(x: &test::S7) { + private fun simple_6(x: &0x42::test::S7) { { let test::S7{ 0: _w, 1: _, 2: _, 3: _z } = x; { @@ -291,15 +291,174 @@ module 0x42::test { } private fun test_lambda_param(): bool { { - let x: test::S2 = pack test::S2(true, pack test::S0(false)); + let x: S2 = pack test::S2(true, pack test::S0(false)); { - let (test::S2{ 0: x, 1: _ }): (test::S2) = Tuple(x); + let (test::S2{ 0: x, 1: _ }): (S2) = Tuple(x); x } } } } // end 0x42::test +// -- Sourcified model before bytecode pipeline +module 0x42::test { + enum E1 has drop { + A { + 0: u8, + 1: bool, + } + B { + 0: u8, + } + C { + x: u8, + y: S1, + } + } + struct S0 has copy { + } + struct S1 has copy, drop { + 0: u8, + } + struct S2 has copy { + 0: bool, + 1: S0, + } + struct S3 has copy { + x: bool, + y: u8, + } + struct S4 has copy { + 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, + } + inline fun lambda_param(f: |S2|bool): bool { + let x = S2{0: true,1: S0{}}; + f(x) + } + fun nested1(x: S4) { + let S4{x: _x,y: _} = x; + let S4{x: _,y: _y} = x; + let S4{x: _,y: S3{x: _,y: _}} = x; + let S4{x: _,y: S3{x: _x,y: _}} = x; + let S4{x: _x2,y: S3{x: _x1,y: _}} = x; + let S4{x: _,y: S3{x: _,y: _y}} = x; + let S4{x: _x2,y: S3{x: _x1,y: _}} = x; + } + fun nested1_ref(x: &S4) { + let S4{x: _x,y: _} = x; + let S4{x: _,y: _y} = x; + let S4{x: _,y: S3{x: _,y: _}} = x; + let S4{x: _,y: S3{x: _x,y: _}} = x; + let S4{x: _x2,y: S3{x: _x1,y: _}} = x; + let S4{x: _,y: S3{x: _,y: _y}} = x; + let S4{x: _x2,y: S3{x: _x1,y: _}} = x; + } + fun nested2(x: S5) { + let S5{0: _,1: S1{0: _}} = x; + } + fun nested2_ref(x: &S5) { + let S5{0: _,1: S1{0: _}} = x; + } + fun nested3(x: S5>) { + let S5>{0: _,1: S4{x: _,y: _}} = x; + } + fun nested3_ref(x: &S5>) { + let S5>{0: _,1: S4{x: _,y: _}} = x; + } + fun nested4(x: S4) { + let S4{x: S1{0: _},y: _} = x; + } + fun nested4_ref(x: &S4) { + let S4{x: S1{0: _},y: _} = x; + } + fun simple_0(x: S0) { + let S0{} = x; + } + fun simple_0_ref(x: &S0) { + let S0{} = x; + } + fun simple_1(x: S1) { + let S1{0: _} = x; + } + fun simple_1_ref(x: &mut S1) { + let S1{0: _} = x; + } + fun simple_2(x: S2) { + let S2{0: _,1: _} = x; + let S2{0: _x,1: _} = x; + let S2{0: _,1: _x} = x; + let S2{0: _,1: _} = x; + let S2{0: _,1: _} = x; + let S2{0: _x,1: _y} = x; + let S2{0: _x,1: _y} = x; + let S2{0: _x,1: _y} = x; + } + fun simple_2_ref(x: &S2) { + let S2{0: _,1: _} = x; + let S2{0: _x,1: _} = x; + let S2{0: _,1: _x} = x; + let S2{0: _,1: _} = x; + let S2{0: _,1: _} = x; + let S2{0: _x,1: _y} = x; + let S2{0: _x,1: _y} = x; + let S2{0: _x,1: _y} = x; + } + fun simple_3(x: S3) { + let S3{x: _,y: _} = x; + let S3{x: _x,y: _} = x; + let S3{x: _,y: _y} = x; + } + fun simple_3_ref(x: S3) { + let S3{x: _,y: _} = x; + let S3{x: _x,y: _} = x; + let S3{x: _,y: _y} = x; + } + fun simple_4(x: E1): u8 { + match (x) { + E1::A{0: x,1: _} => x, + E1::B{0: x} => x, + E1::C{x: x,y: _} => x, + } + } + fun simple_4_ref(x: &E1): &u8 { + match (x) { + E1::A{0: x,1: _} => x, + E1::B{0: x} => x, + } + } + fun simple_5(x: E1): u8 { + match (x) { + E1::A{0: _,1: y} => if (y) 1u8 else 0u8, + E1::B{0: x} => x, + E1::C{x: _,y: S1{0: x}} => x, + } + } + fun simple_6(x: &S7) { + let S7{0: _w,1: _,2: _,3: _z} = x; + let S7{0: _w,1: _x,2: _y,3: _z} = x; + } + fun test_lambda_param(): bool { + let x = S2{0: true,1: S0{}}; + let (S2{0: x,1: _}) = (x); + x + } +} + Diagnostics: error: match not exhaustive diff --git a/third_party/move/move-compiler-v2/tests/checking/dotdot/extra_dotdot.exp b/third_party/move/move-compiler-v2/tests/checking/dotdot/extra_dotdot.exp index d772036e3fe4c..5628d8db32cbb 100644 --- a/third_party/move/move-compiler-v2/tests/checking/dotdot/extra_dotdot.exp +++ b/third_party/move/move-compiler-v2/tests/checking/dotdot/extra_dotdot.exp @@ -10,7 +10,7 @@ module 0x42::test { 1: u8, 2: address, } - private fun extra_dotdot(x: test::S,y: test::T) { + private fun extra_dotdot(x: 0x42::test::S,y: 0x42::test::T) { { let test::S{ 0: _x, 1: _, 2: _ } = x; { @@ -26,3 +26,23 @@ module 0x42::test { } } } // end 0x42::test + +// -- Sourcified model before bytecode pipeline +module 0x42::test { + struct T { + x: bool, + y: u8, + z: address, + } + struct S { + 0: bool, + 1: u8, + 2: address, + } + fun extra_dotdot(x: S, y: T) { + let S{0: _x,1: _,2: _} = x; + let S{0: _,1: _,2: _} = x; + let S{0: _,1: _,2: _} = x; + let T{x: _,y: _,z: _} = y; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/indexing/examples_book.exp b/third_party/move/move-compiler-v2/tests/checking/indexing/examples_book.exp index db8a5d33f66f5..225201e7eb6d2 100644 --- a/third_party/move/move-compiler-v2/tests/checking/indexing/examples_book.exp +++ b/third_party/move/move-compiler-v2/tests/checking/indexing/examples_book.exp @@ -4,18 +4,18 @@ module 0x1::m { value: bool, } private fun f1() - acquires m::R(*) + acquires 0x1::m::R(*) { { - let x: &mut m::R = BorrowGlobal(Mutable)(0x1); - select m::R.value<&mut m::R>(x) = false; - if Eq(select m::R.value(BorrowGlobal(Immutable)(0x1)), false) { + let x: &mut R = BorrowGlobal(Mutable)(0x1); + select m::R.value<&mut R>(x) = false; + if Eq(select m::R.value(BorrowGlobal(Immutable)(0x1)), false) { Tuple() } else { Abort(1) }; - select m::R.value(BorrowGlobal(Mutable)(0x1)) = true; - if Eq(select m::R.value(BorrowGlobal(Immutable)(0x1)), true) { + select m::R.value(BorrowGlobal(Mutable)(0x1)) = true; + if Eq(select m::R.value(BorrowGlobal(Immutable)(0x1)), true) { Tuple() } else { Abort(2) @@ -24,3 +24,19 @@ module 0x1::m { } } } // end 0x1::m + +// -- Sourcified model before bytecode pipeline +module 0x1::m { + struct R has drop, key { + value: bool, + } + fun f1() + acquires R + { + let x = borrow_global_mut(0x1); + x.value = false; + if (borrow_global(0x1).value == false) () else abort 1; + borrow_global_mut(0x1).value = true; + if (borrow_global(0x1).value == true) () else abort 2; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/inlining/bug_11112.exp b/third_party/move/move-compiler-v2/tests/checking/inlining/bug_11112.exp index 2d26e677fd493..fb79d81744afa 100644 --- a/third_party/move/move-compiler-v2/tests/checking/inlining/bug_11112.exp +++ b/third_party/move/move-compiler-v2/tests/checking/inlining/bug_11112.exp @@ -35,5 +35,26 @@ module 0xcafe::vectors { } } // end 0xcafe::vectors +// -- Sourcified model before bytecode pipeline +module 0xcafe::vectors { + fun test_for_each_mut() { + let v = vector[1, 2, 3]; + let s = 2; + { + let (v) = (&mut v); + let i = 0; + while (i < 0x1::vector::length(/*freeze*/v)) { + { + let (e) = (0x1::vector::borrow_mut(v, i)); + *e = s; + s = s + 1 + }; + i = i + 1 + } + }; + if (v == vector[2, 3, 4]) () else abort 0; + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/checking/inlining/bug_11223.exp b/third_party/move/move-compiler-v2/tests/checking/inlining/bug_11223.exp index 88ecb0c6d4f29..cd772a8c8663b 100644 --- a/third_party/move/move-compiler-v2/tests/checking/inlining/bug_11223.exp +++ b/third_party/move/move-compiler-v2/tests/checking/inlining/bug_11223.exp @@ -18,5 +18,16 @@ module 0xcafe::vectors { } } // end 0xcafe::vectors +// -- Sourcified model before bytecode pipeline +module 0xcafe::vectors { + public entry fun guess_flips_break2(flips: vector): u64 { + let flipsref5 = &flips; + let _v = copy flips; + let _v2 = flips; + let x = flipsref5; + 0x1::vector::length(x) + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/checking/inlining/bug_9717.exp b/third_party/move/move-compiler-v2/tests/checking/inlining/bug_9717.exp index 6f66dccff2e22..5462c607e72ad 100644 --- a/third_party/move/move-compiler-v2/tests/checking/inlining/bug_9717.exp +++ b/third_party/move/move-compiler-v2/tests/checking/inlining/bug_9717.exp @@ -169,5 +169,80 @@ module 0xcafe::vectors { } } // end 0xcafe::vectors +// -- Sourcified model before bytecode pipeline +module 0xcafe::vectors { + public entry fun guess_flips(flips: vector) { + { + let (flips) = (&flips); + let i = 0; + while (i < 0x1::vector::length(flips)) { + if (*0x1::vector::borrow(flips, i) != 0u8) break; + i = i + 1; + }; + }; + let _v = copy flips; + let _v2 = flips; + } + public entry fun guess_flips_directly(flips: vector) { + let i = 0; + while (i < 0x1::vector::length(&flips)) { + if (*0x1::vector::borrow(&flips, i) != 0u8) break; + i = i + 1; + }; + let _v = copy flips; + let _v2 = flips; + } + public entry fun guess_with_break_without_inline(flips: vector) { + loops_with_break_no_inline(&flips); + let _v = copy flips; + let _v2 = flips; + } + public entry fun guess_without_break_with_inline(flips: vector) { + { + let (flips) = (&flips); + let i = 0; + while (i < 0x1::vector::length(flips)) { + if (*0x1::vector::borrow(flips, i) == 0u8) () else abort 3; + i = i + 1; + }; + }; + let _v = flips; + let _v2 = copy flips; + } + inline fun loops_with_break(flips: &vector) { + let i = 0; + while (i < 0x1::vector::length(flips)) { + if (*0x1::vector::borrow(flips, i) != 0u8) break; + i = i + 1; + }; + } + fun loops_with_break_no_inline(flips: &vector) { + let i = 0; + while (i < 0x1::vector::length(flips)) { + if (*0x1::vector::borrow(flips, i) != 0u8) break; + i = i + 1; + }; + } + inline fun loops_without_break(flips: &vector) { + let i = 0; + while (i < 0x1::vector::length(flips)) { + if (*0x1::vector::borrow(flips, i) == 0u8) () else abort 3; + i = i + 1; + }; + } + fun test_guess_directly() { + guess_flips_directly(vector[0u8, 0u8, 0u8, 0u8]); + } + fun test_guess_with_break_no_inline() { + guess_with_break_without_inline(vector[0u8, 0u8, 0u8, 0u8]); + } + fun test_guess_with_inline_break() { + guess_flips(vector[0u8, 0u8, 0u8, 0u8]); + } + fun test_guess_without_break() { + guess_without_break_with_inline(vector[0u8, 0u8, 0u8, 0u8]); + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/checking/inlining/bug_9717_looponly.exp b/third_party/move/move-compiler-v2/tests/checking/inlining/bug_9717_looponly.exp index 0e16c76cedfe5..a0ccb34192e63 100644 --- a/third_party/move/move-compiler-v2/tests/checking/inlining/bug_9717_looponly.exp +++ b/third_party/move/move-compiler-v2/tests/checking/inlining/bug_9717_looponly.exp @@ -39,5 +39,22 @@ module 0xcafe::vectors { } } // end 0xcafe::vectors +// -- Sourcified model before bytecode pipeline +module 0xcafe::vectors { + public entry fun guess_flips_break2(flips: vector): u64 { + let i = 0; + let flipsref5 = &flips; + while (i < 0x1::vector::length(flipsref5)) { + if (*0x1::vector::borrow(flipsref5, i) != 0u8) break; + i = i + 1; + if (*0x1::vector::borrow(flipsref5, i) == 5u8) break; + }; + let _v = copy flips; + let _v2 = flips; + let x = flipsref5; + 0x1::vector::length(x) + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/checking/inlining/continue_without_loop.exp b/third_party/move/move-compiler-v2/tests/checking/inlining/continue_without_loop.exp index 858b6714484a5..881149b8ba3ce 100644 --- a/third_party/move/move-compiler-v2/tests/checking/inlining/continue_without_loop.exp +++ b/third_party/move/move-compiler-v2/tests/checking/inlining/continue_without_loop.exp @@ -6,6 +6,13 @@ module 0xc0ffee::m { } } // end 0xc0ffee::m +// -- Sourcified model before bytecode pipeline +module 0xc0ffee::m { + fun continued() { + continue; + } +} + Diagnostics: error: missing enclosing loop statement diff --git a/third_party/move/move-compiler-v2/tests/checking/inlining/deep_exp.exp b/third_party/move/move-compiler-v2/tests/checking/inlining/deep_exp.exp index 5651a5e32c294..9d4e0ede67812 100644 --- a/third_party/move/move-compiler-v2/tests/checking/inlining/deep_exp.exp +++ b/third_party/move/move-compiler-v2/tests/checking/inlining/deep_exp.exp @@ -2930,5 +2930,2549 @@ module 0x42::Test { } } // end 0x42::Test +// -- Sourcified model before bytecode pipeline +module 0x42::Test { + inline fun f1(x: u64): u64 { + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + } + inline fun f2(x: u64): u64 { + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + } + inline fun f3(x: u64): u64 { + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + } + inline fun f4(x: u64): u64 { + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + } + inline fun f5(x: u64): u64 { + x + 1 + } + public fun test(): u64 { + 625 + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/checking/inlining/double_nesting.exp b/third_party/move/move-compiler-v2/tests/checking/inlining/double_nesting.exp index 704e33333decc..013e348b7560a 100644 --- a/third_party/move/move-compiler-v2/tests/checking/inlining/double_nesting.exp +++ b/third_party/move/move-compiler-v2/tests/checking/inlining/double_nesting.exp @@ -22,5 +22,24 @@ module 0x42::test { } } // end 0x42::test +// -- Sourcified model before bytecode pipeline +module 0x42::mathtest2 { + public inline fun fun2(a: u64, b: u64, c: u64): u64 { + 7u128 * (a as u128) + 11u128 * (b as u128) + 13u128 * (c as u128) as u64 + } +} +module 0x42::mathtest { + public inline fun fun1(a: u64, b: u64, c: u64): u64 { + 2u128 * (a as u128) + 3u128 * (b as u128) + 5u128 * (c as u128) as u64 + } +} +module 0x42::test { + use 0x42::mathtest2; + use 0x42::mathtest; + fun test_nested_fun1() { + if (true) () else abort 0; + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/checking/inlining/inline_accessing_constant.exp b/third_party/move/move-compiler-v2/tests/checking/inlining/inline_accessing_constant.exp index 92bb26104541b..c7758a90c4508 100644 --- a/third_party/move/move-compiler-v2/tests/checking/inlining/inline_accessing_constant.exp +++ b/third_party/move/move-compiler-v2/tests/checking/inlining/inline_accessing_constant.exp @@ -10,5 +10,17 @@ module 0xc0ffee::dummy2 { } } // end 0xc0ffee::dummy2 +// -- Sourcified model before bytecode pipeline +module 0xc0ffee::dummy1 { + public inline fun expose(): u64 { + 1 + } +} +module 0xc0ffee::dummy2 { + public fun main(): u64 { + 1 + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/checking/inlining/lambda.exp b/third_party/move/move-compiler-v2/tests/checking/inlining/lambda.exp index 11a8de528f5cb..b3ac0b9bccd11 100644 --- a/third_party/move/move-compiler-v2/tests/checking/inlining/lambda.exp +++ b/third_party/move/move-compiler-v2/tests/checking/inlining/lambda.exp @@ -94,5 +94,74 @@ module 0x42::LambdaTest { } } // end 0x42::LambdaTest +// -- Sourcified model before bytecode 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 { + let (a,b) = (f(b) + 1, 12); + a * 12 + } + public inline fun inline_mul(a: u64, b: u64): u64 { + a * b + } +} +module 0x42::LambdaTest2 { + use 0x42::LambdaTest1; + public inline fun foreach(v: &vector, action: |&T|) { + let i = 0; + while (i < 0x1::vector::length(v)) { + action(0x1::vector::borrow(v, i)); + i = i + 1; + } + } + public inline fun inline_apply2(g: |u64|u64, c: u64): u64 { + { + let (b) = (g({ + let (a,b) = (c, 3); + a * 3 + })); + let (a,b) = ({ + let (z) = (b); + z + } + 1, 12); + a * 12 + } + 2 + } + public inline fun inline_apply3(g: |u64|u64, c: u64): u64 { + LambdaTest1::inline_apply1(g, LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x| LambdaTest1::inline_apply(|y| y, x), 3))) + 4 + } + public fun test_inline_lambda() { + let product = 1; + { + let (v) = (&vector[1, 2, 3]); + let i = 0; + while (i < 0x1::vector::length(v)) { + { + let (e) = (0x1::vector::borrow(v, i)); + product = { + let (a,b) = (product, *e); + a * b + } + }; + i = i + 1; + } + }; + } +} +module 0x42::LambdaTest { + use 0x42::LambdaTest2; + public inline fun inline_apply(f: |u64|u64, b: u64): u64 { + f(b) + } + public inline fun inline_apply_test(): u64 { + 1120 + } + fun test_lambda() { + if (false) () else abort 0; + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/checking/inlining/lambda_cast.exp b/third_party/move/move-compiler-v2/tests/checking/inlining/lambda_cast.exp index 57cee1446037e..68c24b3325227 100644 --- a/third_party/move/move-compiler-v2/tests/checking/inlining/lambda_cast.exp +++ b/third_party/move/move-compiler-v2/tests/checking/inlining/lambda_cast.exp @@ -59,5 +59,45 @@ module 0x12391283::M { } } // end 0x12391283::M +// -- Sourcified model before bytecode pipeline +module 0x12391283::M { + fun test_1(): u64 { + let accu = 0; + { + let (v) = (vector[115u8, 115u8, 95u8, 112u8, 97u8, 99u8, 107u8, 101u8, 100u8, 32u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8]); + 0x1::vector::reverse(&mut v); + while (!0x1::vector::is_empty(&v)) { + let e = 0x1::vector::pop_back(&mut v); + { + let (elem) = (e); + accu = { + let (sum,addend) = (accu, elem); + sum + (addend as u64) + } + }; + }; + }; + accu + } + fun test_2(): u64 { + let accu = 0; + { + let (v) = (vector[115u8, 115u8, 95u8, 112u8, 97u8, 99u8, 107u8, 101u8, 100u8, 32u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8]); + 0x1::vector::reverse(&mut v); + while (!0x1::vector::is_empty(&v)) { + let e = 0x1::vector::pop_back(&mut v); + { + let (elem) = (e); + accu = { + let (sum,addend) = (accu, elem); + sum + (addend as u64) + } + }; + }; + }; + accu + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/checking/inlining/lambda_typed.exp b/third_party/move/move-compiler-v2/tests/checking/inlining/lambda_typed.exp index 11a8de528f5cb..b3ac0b9bccd11 100644 --- a/third_party/move/move-compiler-v2/tests/checking/inlining/lambda_typed.exp +++ b/third_party/move/move-compiler-v2/tests/checking/inlining/lambda_typed.exp @@ -94,5 +94,74 @@ module 0x42::LambdaTest { } } // end 0x42::LambdaTest +// -- Sourcified model before bytecode 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 { + let (a,b) = (f(b) + 1, 12); + a * 12 + } + public inline fun inline_mul(a: u64, b: u64): u64 { + a * b + } +} +module 0x42::LambdaTest2 { + use 0x42::LambdaTest1; + public inline fun foreach(v: &vector, action: |&T|) { + let i = 0; + while (i < 0x1::vector::length(v)) { + action(0x1::vector::borrow(v, i)); + i = i + 1; + } + } + public inline fun inline_apply2(g: |u64|u64, c: u64): u64 { + { + let (b) = (g({ + let (a,b) = (c, 3); + a * 3 + })); + let (a,b) = ({ + let (z) = (b); + z + } + 1, 12); + a * 12 + } + 2 + } + public inline fun inline_apply3(g: |u64|u64, c: u64): u64 { + LambdaTest1::inline_apply1(g, LambdaTest1::inline_mul(c, LambdaTest1::inline_apply(|x| LambdaTest1::inline_apply(|y| y, x), 3))) + 4 + } + public fun test_inline_lambda() { + let product = 1; + { + let (v) = (&vector[1, 2, 3]); + let i = 0; + while (i < 0x1::vector::length(v)) { + { + let (e) = (0x1::vector::borrow(v, i)); + product = { + let (a,b) = (product, *e); + a * b + } + }; + i = i + 1; + } + }; + } +} +module 0x42::LambdaTest { + use 0x42::LambdaTest2; + public inline fun inline_apply(f: |u64|u64, b: u64): u64 { + f(b) + } + public inline fun inline_apply_test(): u64 { + 1120 + } + fun test_lambda() { + if (false) () else abort 0; + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/checking/inlining/nested_mul.exp b/third_party/move/move-compiler-v2/tests/checking/inlining/nested_mul.exp index d2a9c2da6684a..fd17730d179b6 100644 --- a/third_party/move/move-compiler-v2/tests/checking/inlining/nested_mul.exp +++ b/third_party/move/move-compiler-v2/tests/checking/inlining/nested_mul.exp @@ -16,5 +16,18 @@ module 0x42::test { } } // end 0x42::test +// -- Sourcified model before bytecode pipeline +module 0x42::mathtest { + public inline fun mul_div(a: u64, b: u64, c: u64): u64 { + (a as u128) * (b as u128) / (c as u128) as u64 + } +} +module 0x42::test { + use 0x42::mathtest; + fun test_nested_mul_div() { + if (true) () else abort 0; + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/checking/inlining/order_sensitive.exp b/third_party/move/move-compiler-v2/tests/checking/inlining/order_sensitive.exp index 5db0ee1deb70d..e6febebcd74cb 100644 --- a/third_party/move/move-compiler-v2/tests/checking/inlining/order_sensitive.exp +++ b/third_party/move/move-compiler-v2/tests/checking/inlining/order_sensitive.exp @@ -92,5 +92,99 @@ module 0x42::OrderSensitiveTest3 { } } // end 0x42::OrderSensitiveTest3 +// -- Sourcified model before bytecode pipeline +module 0x42::OrderSensitiveTest1 { + public inline fun inline_fun1(a: u64, b: u64): u64 { + a * b + } + public inline fun inline_fun2(a: u64, b: u64): u64 { + { + let (a,b) = (a, b); + a * b + } + 2 * { + let (a,b) = (a, b); + a * b + 2 + } + } + public inline fun inline_fun3(a: u64, b: u64): u64 { + a * b + 2 + } +} +module 0x42::OrderSensitiveTest2 { + use 0x42::OrderSensitiveTest1; + public inline fun inline_fun1(a: u64, b: u64): u64 { + a * b + 3 + } + public inline fun inline_fun2(a: u64, b: u64): u64 { + { + let (a,b) = ({ + let (a,b) = (a, b); + a * b + 3 + }, { + let (a,b) = (a, b); + a * b + 4 + }); + { + let (a,b) = (a, b); + a * b + } + 2 * { + let (a,b) = (a, b); + a * b + 2 + } + } + 3 * { + let (a,b) = (a, b); + a * b + 3 + } + 5 * { + let (a,b) = (a, b); + a * b + 4 + } + } + public inline fun inline_fun3(a: u64, b: u64): u64 { + a * b + 4 + } +} +module 0x42::OrderSensitiveTest3 { + use 0x42::OrderSensitiveTest2; + public inline fun fun1(a: u64, b: u64): u64 { + a * b + 5 + } + public fun fun2(a: u64, b: u64): u64 { + { + let (a,b) = (7 * { + let (a,b) = (a, b); + a * b + 5 + }, b); + { + let (a,b) = ({ + let (a,b) = (a, b); + a * b + 3 + }, { + let (a,b) = (a, b); + a * b + 4 + }); + { + let (a,b) = (a, b); + a * b + } + 2 * { + let (a,b) = (a, b); + a * b + 2 + } + } + 3 * { + let (a,b) = (a, b); + a * b + 3 + } + 5 * { + let (a,b) = (a, b); + a * b + 4 + } + } + 9 * { + let (a,b) = (a, b); + a * b + 6 + } + } + public inline fun fun3(a: u64, b: u64): u64 { + a * b + 6 + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/checking/inlining/recursive_nesting.exp b/third_party/move/move-compiler-v2/tests/checking/inlining/recursive_nesting.exp index a7c00dc82c2a1..be3551312c2b4 100644 --- a/third_party/move/move-compiler-v2/tests/checking/inlining/recursive_nesting.exp +++ b/third_party/move/move-compiler-v2/tests/checking/inlining/recursive_nesting.exp @@ -39,5 +39,35 @@ module 0x42::test { } } // end 0x42::test +// -- Sourcified model before bytecode pipeline +module 0x42::mathtest { + public inline fun mul_div(a: u64, b: u64, c: u64): u64 { + (a as u128) * (b as u128) / (c as u128) as u64 + } +} +module 0x42::mathtest2 { + use 0x42::mathtest; + public inline fun mul_div2(a: u64, b: u64, c: u64): u64 { + let (a,b,c) = (b, a, c); + (a as u128) * (b as u128) / (c as u128) as u64 + } +} +module 0x42::mathtest3 { + use 0x42::mathtest2; + public inline fun mul_div3(a: u64, b: u64, c: u64): u64 { + let (a,b,c) = (b, a, c); + let (a,b,c) = (b, a, c); + (a as u128) * (b as u128) / (c as u128) as u64 + } +} +module 0x42::test { + use 0x42::mathtest; + use 0x42::mathtest2; + use 0x42::mathtest3; + fun test_nested_mul_div() { + if (true) () else abort 0; + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/checking/inlining/resources_valid.exp b/third_party/move/move-compiler-v2/tests/checking/inlining/resources_valid.exp index cf71f9d1297c0..21b9eabd6a4a8 100644 --- a/third_party/move/move-compiler-v2/tests/checking/inlining/resources_valid.exp +++ b/third_party/move/move-compiler-v2/tests/checking/inlining/resources_valid.exp @@ -3,10 +3,10 @@ module 0x42::objects { struct ReaderRef { addr: address, } - public fun get_addr(ref: &objects::ReaderRef<#0>): address { - select objects::ReaderRef.addr<&objects::ReaderRef>(ref) + public fun get_addr(ref: &0x42::objects::ReaderRef<#0>): address { + select objects::ReaderRef.addr<&ReaderRef>(ref) } - public inline fun reader(ref: &objects::ReaderRef<#0>): � { + public inline fun reader(ref: &0x42::objects::ReaderRef<#0>): � { BorrowGlobal(Immutable)(objects::get_addr(ref)) } } // end 0x42::objects @@ -15,15 +15,42 @@ module 0x42::token { struct Token { val: u64, } - public fun get_value(ref: &objects::ReaderRef): u64 - acquires token::Token(*) + public fun get_value(ref: &0x42::objects::ReaderRef<0x42::token::Token>): u64 + acquires 0x42::token::Token(*) { - select token::Token.val<&token::Token>({ - let (ref: &objects::ReaderRef): (&objects::ReaderRef) = Tuple(ref); - BorrowGlobal(Immutable)(objects::get_addr(ref)) + select token::Token.val<&Token>({ + let (ref: &objects::ReaderRef): (&objects::ReaderRef) = Tuple(ref); + BorrowGlobal(Immutable)(objects::get_addr(ref)) }) } } // end 0x42::token +// -- Sourcified model before bytecode pipeline +module 0x42::objects { + struct ReaderRef has store { + addr: address, + } + public fun get_addr(ref: &ReaderRef): address { + ref.addr + } + public inline fun reader(ref: &ReaderRef): &T { + borrow_global(get_addr(ref)) + } +} +module 0x42::token { + use 0x42::objects; + struct Token has key { + val: u64, + } + public fun get_value(ref: &objects::ReaderRef): u64 + acquires Token + { + { + let (ref) = (ref); + borrow_global(objects::get_addr(ref)) + }.val + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/checking/inlining/shadowing_unused.exp b/third_party/move/move-compiler-v2/tests/checking/inlining/shadowing_unused.exp index 2c3a1c4b158bd..5eb27791a5827 100644 --- a/third_party/move/move-compiler-v2/tests/checking/inlining/shadowing_unused.exp +++ b/third_party/move/move-compiler-v2/tests/checking/inlining/shadowing_unused.exp @@ -39,5 +39,34 @@ module 0x42::Test { } } // end 0x42::Test +// -- Sourcified model before bytecode pipeline +module 0x42::Test { + public inline fun foo(f: |(u64, u64)|, z: u64) { + { + let (_z) = (z); + f(3, 5); + }; + } + public inline fun quux(f: |(u64, u64)|, _z: u64) { + f(3, 5); + } + public fun test_shadowing() { + let _x = 1; + { + { + _x = 3; + }; + }; + if (_x == 3) () else abort 0 + } + public fun test_shadowing2() { + let _x = 1; + { + _x = 3; + }; + if (_x == 3) () else abort 0 + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/checking/inlining/shadowing_unused_nodecl.exp b/third_party/move/move-compiler-v2/tests/checking/inlining/shadowing_unused_nodecl.exp index 6a990cf6bcf0c..96b8d2c461add 100644 --- a/third_party/move/move-compiler-v2/tests/checking/inlining/shadowing_unused_nodecl.exp +++ b/third_party/move/move-compiler-v2/tests/checking/inlining/shadowing_unused_nodecl.exp @@ -47,5 +47,34 @@ module 0x42::Test { } } // end 0x42::Test +// -- Sourcified model before bytecode pipeline +module 0x42::Test { + public inline fun foo(f: |(u64, u64)|, z: u64) { + { + let (z) = (z); + f(3, 5); + }; + } + public inline fun quux(f: |(u64, u64)|, z: u64) { + f(3, 5); + } + public fun test_shadowing() { + let _x = 1; + { + { + _x = 3; + }; + }; + if (_x == 3) () else abort 0 + } + public fun test_shadowing2() { + let _x = 1; + { + _x = 3; + }; + if (_x == 3) () else abort 0 + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/checking/inlining/shadowing_unused_nodecl_typed.exp b/third_party/move/move-compiler-v2/tests/checking/inlining/shadowing_unused_nodecl_typed.exp index 4f7f74661aa59..9dc677d49a25e 100644 --- a/third_party/move/move-compiler-v2/tests/checking/inlining/shadowing_unused_nodecl_typed.exp +++ b/third_party/move/move-compiler-v2/tests/checking/inlining/shadowing_unused_nodecl_typed.exp @@ -47,5 +47,34 @@ module 0x42::Test { } } // end 0x42::Test +// -- Sourcified model before bytecode pipeline +module 0x42::Test { + public inline fun foo(f: |(u64, u64)|, z: u64) { + { + let (z) = (z); + f(3, 5); + }; + } + public inline fun quux(f: |(u64, u64)|, z: u64) { + f(3, 5); + } + public fun test_shadowing() { + let _x = 1; + { + { + _x = 3; + }; + }; + if (_x == 3) () else abort 0 + } + public fun test_shadowing2() { + let _x = 1; + { + _x = 3; + }; + if (_x == 3) () else abort 0 + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/checking/inlining/shadowing_unused_typed.exp b/third_party/move/move-compiler-v2/tests/checking/inlining/shadowing_unused_typed.exp index 2c3a1c4b158bd..5eb27791a5827 100644 --- a/third_party/move/move-compiler-v2/tests/checking/inlining/shadowing_unused_typed.exp +++ b/third_party/move/move-compiler-v2/tests/checking/inlining/shadowing_unused_typed.exp @@ -39,5 +39,34 @@ module 0x42::Test { } } // end 0x42::Test +// -- Sourcified model before bytecode pipeline +module 0x42::Test { + public inline fun foo(f: |(u64, u64)|, z: u64) { + { + let (_z) = (z); + f(3, 5); + }; + } + public inline fun quux(f: |(u64, u64)|, _z: u64) { + f(3, 5); + } + public fun test_shadowing() { + let _x = 1; + { + { + _x = 3; + }; + }; + if (_x == 3) () else abort 0 + } + public fun test_shadowing2() { + let _x = 1; + { + _x = 3; + }; + if (_x == 3) () else abort 0 + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/checking/inlining/spec_inlining.exp b/third_party/move/move-compiler-v2/tests/checking/inlining/spec_inlining.exp index f5a5f2de0f028..c63cdd3aaa435 100644 --- a/third_party/move/move-compiler-v2/tests/checking/inlining/spec_inlining.exp +++ b/third_party/move/move-compiler-v2/tests/checking/inlining/spec_inlining.exp @@ -56,5 +56,56 @@ module 0x42::Test { } } // end 0x42::Test +// -- Sourcified model before bytecode pipeline +module 0x42::Test { + inline fun apply(v: u64, predicate: |u64|bool): bool { + + /* spec { + assert Ge($t0, 0); + } + */ + ; + predicate(v) + } + public fun test_apply(x: u64) { + let r1 = { + let (v) = (x); + + /* spec { + assert Ge(v, 0); + } + */ + ; + let (v) = (v); + v >= 0 + }; + + /* spec { + assert r1; + } + */ + ; + if (r1) () else abort 1; + let r2 = { + let (v) = (x); + + /* spec { + assert Ge(v, 0); + } + */ + ; + let (v) = (v); + v != 0 + }; + + /* spec { + assert r2; + } + */ + ; + if (r2) () else abort 2; + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/checking/inlining/spec_inlining_typed.exp b/third_party/move/move-compiler-v2/tests/checking/inlining/spec_inlining_typed.exp index f5a5f2de0f028..c63cdd3aaa435 100644 --- a/third_party/move/move-compiler-v2/tests/checking/inlining/spec_inlining_typed.exp +++ b/third_party/move/move-compiler-v2/tests/checking/inlining/spec_inlining_typed.exp @@ -56,5 +56,56 @@ module 0x42::Test { } } // end 0x42::Test +// -- Sourcified model before bytecode pipeline +module 0x42::Test { + inline fun apply(v: u64, predicate: |u64|bool): bool { + + /* spec { + assert Ge($t0, 0); + } + */ + ; + predicate(v) + } + public fun test_apply(x: u64) { + let r1 = { + let (v) = (x); + + /* spec { + assert Ge(v, 0); + } + */ + ; + let (v) = (v); + v >= 0 + }; + + /* spec { + assert r1; + } + */ + ; + if (r1) () else abort 1; + let r2 = { + let (v) = (x); + + /* spec { + assert Ge(v, 0); + } + */ + ; + let (v) = (v); + v != 0 + }; + + /* spec { + assert r2; + } + */ + ; + if (r2) () else abort 2; + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/checking/inlining/temp_shadowing.exp b/third_party/move/move-compiler-v2/tests/checking/inlining/temp_shadowing.exp index 74d14cbaa3f32..21b28b8d8ae5c 100644 --- a/third_party/move/move-compiler-v2/tests/checking/inlining/temp_shadowing.exp +++ b/third_party/move/move-compiler-v2/tests/checking/inlining/temp_shadowing.exp @@ -57,5 +57,37 @@ module 0x42::Test { } } // end 0x42::Test +// -- Sourcified model before bytecode pipeline +module 0x42::Test { + public fun other(a: u64, b: u64): u64 { + let sum = 0; + while (a < b) { + a = a + 1; + sum = { + let (a,b) = (a, b); + let sum = 0; + while (a < b) { + a = a + 1; + sum = sum + a; + }; + sum + } + sum; + }; + sum + } + public inline fun nested(a: u64, b: u64): u64 { + let sum = 0; + while (a < b) { + a = a + 1; + sum = sum + a; + }; + sum + } + public fun test_shadowing() { + let z = other(1, 4); + if (z == 10) () else abort z + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/checking/inlining/test_12670.exp b/third_party/move/move-compiler-v2/tests/checking/inlining/test_12670.exp index e110f2e38ae4f..14ded7e3c10d8 100644 --- a/third_party/move/move-compiler-v2/tests/checking/inlining/test_12670.exp +++ b/third_party/move/move-compiler-v2/tests/checking/inlining/test_12670.exp @@ -4,18 +4,18 @@ module 0x1::Test { struct S { x: u8, } - private fun foo(xs: vector) { + private fun foo(xs: vector<0x1::Test::S>) { { let sum: u8 = 0; { - let (v: &vector): (&vector) = Tuple(Borrow(Immutable)(xs)); + let (v: &vector): (&vector) = Tuple(Borrow(Immutable)(xs)); { let i: u64 = 0; loop { - if Lt(i, vector::length(v)) { + if Lt(i, vector::length(v)) { { - let (e: &Test::S): (&Test::S) = Tuple(vector::borrow(v, i)); - sum: u8 = Add(sum, select Test::S.x<&Test::S>(e)); + let (e: &S): (&S) = Tuple(vector::borrow(v, i)); + sum: u8 = Add(sum, select Test::S.x<&S>(e)); Tuple() }; i: u64 = Add(i, 1) @@ -30,5 +30,26 @@ module 0x1::Test { } } // end 0x1::Test +// -- Sourcified model before bytecode pipeline +module 0x1::Test { + struct S has drop { + x: u8, + } + fun foo(xs: vector) { + let sum = 0u8; + { + let (v) = (&xs); + let i = 0; + while (i < 0x1::vector::length(v)) { + { + let (e) = (0x1::vector::borrow(v, i)); + sum = sum + e.x; + }; + i = i + 1 + } + }; + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/checking/inlining/unused_inline.exp b/third_party/move/move-compiler-v2/tests/checking/inlining/unused_inline.exp index 2418f6a234d5d..ba49606523aa6 100644 --- a/third_party/move/move-compiler-v2/tests/checking/inlining/unused_inline.exp +++ b/third_party/move/move-compiler-v2/tests/checking/inlining/unused_inline.exp @@ -40,5 +40,29 @@ module 0xc0ffee::m { } } // end 0xc0ffee::m +// -- Sourcified model before bytecode pipeline +module 0xc0ffee::m { + public fun bar(): u64 { + let i = 0; + while (i < 10) { + i = i + 1; + if (i == 5) { + break; + } + }; + i + } + inline fun foo(): u64 { + let i = 0; + while (i < 10) { + i = i + 1; + if (i == 5) { + break; + } + }; + i + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/checking/naming/duplicate_acquires_list_item.exp b/third_party/move/move-compiler-v2/tests/checking/naming/duplicate_acquires_list_item.exp index c1969b53e490a..e09b6408ae260 100644 --- a/third_party/move/move-compiler-v2/tests/checking/naming/duplicate_acquires_list_item.exp +++ b/third_party/move/move-compiler-v2/tests/checking/naming/duplicate_acquires_list_item.exp @@ -7,23 +7,43 @@ module 0x8675309::M { dummy_field: bool, } private fun t0() - acquires M::R(*) - acquires M::X(*) - acquires M::R(*) + acquires 0x8675309::M::R(*) + acquires 0x8675309::M::X(*) + acquires 0x8675309::M::R(*) { - BorrowGlobal(Mutable)(0x1); - BorrowGlobal(Mutable)(0x1); + BorrowGlobal(Mutable)(0x1); + BorrowGlobal(Mutable)(0x1); Tuple() } private fun t1() - acquires M::R(*) - acquires M::X(*) - acquires M::R(*) - acquires M::R(*) - acquires M::R(*) + acquires 0x8675309::M::R(*) + acquires 0x8675309::M::X(*) + acquires 0x8675309::M::R(*) + acquires 0x8675309::M::R(*) + acquires 0x8675309::M::R(*) { - BorrowGlobal(Mutable)(0x1); - BorrowGlobal(Mutable)(0x1); + BorrowGlobal(Mutable)(0x1); + BorrowGlobal(Mutable)(0x1); Tuple() } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R has key { + } + struct X has key { + } + fun t0() + acquires Racquires Xacquires R + { + borrow_global_mut(0x1); + borrow_global_mut(0x1); + } + fun t1() + acquires Racquires Xacquires Racquires Racquires R + { + borrow_global_mut(0x1); + borrow_global_mut(0x1); + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/naming/generics_shadowing.exp b/third_party/move/move-compiler-v2/tests/checking/naming/generics_shadowing.exp index 7d025d34595a6..121cfb4d68b33 100644 --- a/third_party/move/move-compiler-v2/tests/checking/naming/generics_shadowing.exp +++ b/third_party/move/move-compiler-v2/tests/checking/naming/generics_shadowing.exp @@ -13,3 +13,14 @@ module 0x2::M { } } } // end 0x2::M + +// -- Sourcified model before bytecode pipeline +module 0x2::M { + struct S { + } + fun foo(s: S): S { + let s = s; + let s = s; + s + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/naming/global_builtin_one_type_argument.exp b/third_party/move/move-compiler-v2/tests/checking/naming/global_builtin_one_type_argument.exp index 441e25f4f2b3b..85a59aab9e4b2 100644 --- a/third_party/move/move-compiler-v2/tests/checking/naming/global_builtin_one_type_argument.exp +++ b/third_party/move/move-compiler-v2/tests/checking/naming/global_builtin_one_type_argument.exp @@ -4,18 +4,18 @@ module 0x8675309::M { dummy_field: bool, } private fun t(account: &signer) - acquires M::R(*) + acquires 0x8675309::M::R(*) { { - let _: bool = exists(0x0); + let _: bool = exists(0x0); { - let (): () = MoveTo(account, pack M::R(false)); + let (): () = MoveTo(account, pack M::R(false)); { - let _: &M::R = BorrowGlobal(Immutable)(0x0); + let _: &R = BorrowGlobal(Immutable)(0x0); { - let _: &mut M::R = BorrowGlobal(Mutable)(0x0); + let _: &mut R = BorrowGlobal(Mutable)(0x0); { - let M::R{ dummy_field: _ } = MoveFrom(0x0); + let M::R{ dummy_field: _ } = MoveFrom(0x0); Tuple() } } @@ -24,3 +24,18 @@ module 0x8675309::M { } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R has key { + } + fun t(account: &signer) + acquires R + { + let _ = exists(0x0); + let () = move_to(account, R{}); + let _ = borrow_global(0x0); + let _ = borrow_global_mut(0x0); + let R{} = move_from(0x0); + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/naming/struct_in_current_module.exp b/third_party/move/move-compiler-v2/tests/checking/naming/struct_in_current_module.exp index 8e0fcca2100b4..981ba43a7d97e 100644 --- a/third_party/move/move-compiler-v2/tests/checking/naming/struct_in_current_module.exp +++ b/third_party/move/move-compiler-v2/tests/checking/naming/struct_in_current_module.exp @@ -8,7 +8,7 @@ module 0x8675309::M { } private fun foo() { { - let _: M::S = pack M::S(0); + let _: S = pack M::S(0); { let M::R{ f: _ } = pack M::R(0); Tuple() @@ -16,3 +16,17 @@ module 0x8675309::M { } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R { + f: u64, + } + struct S has drop { + f: u64, + } + fun foo() { + let _ = S{f: 0}; + let R{f: _} = R{f: 0}; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/naming/unused_type_parameter_struct.exp b/third_party/move/move-compiler-v2/tests/checking/naming/unused_type_parameter_struct.exp index bc74029181400..3ae2e7bdc83b2 100644 --- a/third_party/move/move-compiler-v2/tests/checking/naming/unused_type_parameter_struct.exp +++ b/third_party/move/move-compiler-v2/tests/checking/naming/unused_type_parameter_struct.exp @@ -49,7 +49,7 @@ module 0x42::test { dummy_field: bool, } struct S2 { - f: test::S3<#1>, + f: 0x42::test::S3<#1>, } struct S3 { dummy_field: bool, @@ -62,3 +62,23 @@ module 0x42::test { g: vector<#1>, } } // end 0x42::test + +// -- Sourcified model before bytecode pipeline +module 0x42::test { + struct S0 { + } + struct S1 { + } + struct S2 { + f: S3, + } + struct S3 { + } + struct S4 { + f: vector, + } + struct S5 { + f: vector, + g: vector, + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/naming/warning_dependency.exp b/third_party/move/move-compiler-v2/tests/checking/naming/warning_dependency.exp index d18cbc88a3820..af81d60312b4a 100644 --- a/third_party/move/move-compiler-v2/tests/checking/naming/warning_dependency.exp +++ b/third_party/move/move-compiler-v2/tests/checking/naming/warning_dependency.exp @@ -18,7 +18,7 @@ module 0x42::test { dummy_field: bool, } struct S2 { - f: test::S3<#1>, + f: 0x42::test::S3<#1>, } struct S3 { dummy_field: bool, @@ -31,3 +31,7 @@ module 0x42::test { g: vector<#1>, } } // end 0x42::test + +// -- Sourcified model before bytecode pipeline +module 0x42::dependency { +} diff --git a/third_party/move/move-compiler-v2/tests/checking/positional_fields/assign_field.exp b/third_party/move/move-compiler-v2/tests/checking/positional_fields/assign_field.exp index f84ae045ce12c..6f447fc7cb719 100644 --- a/third_party/move/move-compiler-v2/tests/checking/positional_fields/assign_field.exp +++ b/third_party/move/move-compiler-v2/tests/checking/positional_fields/assign_field.exp @@ -6,7 +6,7 @@ module 0x42::test { 1: bool, } V2 { - 0: test::S3, + 0: 0x42::test::S3, } } struct S0 { @@ -17,20 +17,20 @@ module 0x42::test { 1: bool, } struct S2 { - 0: test::S0, + 0: 0x42::test::S0, 1: u8, } struct S3 { - 0: test::S2, - 1: test::S0, - 2: test::S2, + 0: 0x42::test::S2, + 1: 0x42::test::S0, + 2: 0x42::test::S2, } private fun assign0(a: u64,b: bool) { { - let x: test::S1 = pack test::S1(a, b); + let x: S1 = pack test::S1(a, b); loop { - if select test::S1.1(x) { - x: test::S1 = pack test::S1(Sub(select test::S1.0(x), 1), Ge(select test::S1.0(x), 1)); + if select test::S1.1(x) { + x: S1 = pack test::S1(Sub(select test::S1.0(x), 1), Ge(select test::S1.0(x), 1)); Tuple() } else { break @@ -38,18 +38,18 @@ module 0x42::test { } } } - private fun assign1(x: test::S1): u64 { + private fun assign1(x: 0x42::test::S1): u64 { { let count: u64 = 0; loop { - if select test::S1.1(x) { + if select test::S1.1(x) { { - let y: u64 = if Gt(select test::S1.0(x), 0) { - Sub(select test::S1.0(x), 1) + let y: u64 = if Gt(select test::S1.0(x), 0) { + Sub(select test::S1.0(x), 1) } else { 0 }; - x: test::S1 = pack test::S1(y, Ge(y, 1)); + x: S1 = pack test::S1(y, Ge(y, 1)); count: u64 = Add(count, 1); Tuple() } @@ -60,14 +60,14 @@ module 0x42::test { count } } - private fun assign_chained(x: test::S3) { - Add(Add(select test::S0.x(select test::S2.0(select test::S3.0(x))), select test::S0.x(select test::S3.1(x))), select test::S0.x(select test::S2.0(select test::S3.2(x)))); - select test::S0.x(select test::S2.0(select test::S3.0(x))) = 0; - select test::S0.x(select test::S3.1(x)) = 1; - select test::S0.x(select test::S2.0(select test::S3.2(x))) = 2; + private fun assign_chained(x: 0x42::test::S3) { + Add(Add(select test::S0.x(select test::S2.0(select test::S3.0(x))), select test::S0.x(select test::S3.1(x))), select test::S0.x(select test::S2.0(select test::S3.2(x)))); + select test::S0.x(select test::S2.0(select test::S3.0(x))) = 0; + select test::S0.x(select test::S3.1(x)) = 1; + select test::S0.x(select test::S2.0(select test::S3.2(x))) = 2; Tuple() } - private fun assign_enum(x: &mut test::E) { + private fun assign_enum(x: &mut 0x42::test::E) { match (x) { test::E::V1{ 0: x, 1: y } => { x = 42; @@ -75,22 +75,93 @@ module 0x42::test { Tuple() } test::E::V2{ 0: x } => { - select test::S0.x(select test::S2.0(select test::S3.0<&mut test::S3>(x))) = 0; - select test::S0.x(select test::S3.1<&mut test::S3>(x)) = 1; - select test::S0.x(select test::S2.0(select test::S3.2<&mut test::S3>(x))) = 2; + select test::S0.x(select test::S2.0(select test::S3.0<&mut S3>(x))) = 0; + select test::S0.x(select test::S3.1<&mut S3>(x)) = 1; + select test::S0.x(select test::S2.0(select test::S3.2<&mut S3>(x))) = 2; Tuple() } } } - private fun simple(x: test::S1) { - select test::S1.0(x) = 42; - select test::S1.1(x) = true; + private fun simple(x: 0x42::test::S1) { + select test::S1.0(x) = 42; + select test::S1.1(x) = true; Tuple() } - private fun simple_ref(x: &mut test::S1) { - select test::S1.0<&mut test::S1>(x) = 42; - select test::S1.1<&mut test::S1>(x) = true; + private fun simple_ref(x: &mut 0x42::test::S1) { + select test::S1.0<&mut S1>(x) = 42; + select test::S1.1<&mut S1>(x) = true; Tuple() } } // end 0x42::test + +// -- Sourcified model before bytecode pipeline +module 0x42::test { + enum E { + V1 { + 0: u8, + 1: bool, + } + V2 { + 0: S3, + } + } + struct S0 { + x: u8, + } + struct S1 { + 0: u64, + 1: bool, + } + struct S2 { + 0: S0, + 1: u8, + } + struct S3 { + 0: S2, + 1: S0, + 2: S2, + } + fun assign0(a: u64, b: bool) { + let x = S1{0: a,1: b}; + while (x.1) { + x = S1{0: x.0 - 1,1: x.0 >= 1}; + } + } + fun assign1(x: S1): u64 { + let count = 0; + while (x.1) { + let y = if (x.0 > 0) x.0 - 1 else 0; + x = S1{0: y,1: y >= 1}; + count = count + 1; + }; + count + } + fun assign_chained(x: S3) { + x.0.0.x + x.1.x + x.2.0.x; + x.0.0.x = 0u8; + x.1.x = 1u8; + x.2.0.x = 2u8; + } + fun assign_enum(x: &mut E) { + match (x) { + E::V1{0: x,1: y} => { + *x = 42u8; + *y = true; + }, + E::V2{0: x} => { + x.0.0.x = 0u8; + x.1.x = 1u8; + x.2.0.x = 2u8; + }, + } + } + fun simple(x: S1) { + x.0 = 42; + x.1 = true; + } + fun simple_ref(x: &mut S1) { + x.0 = 42; + x.1 = true; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/positional_fields/bind_anonymous_field.exp b/third_party/move/move-compiler-v2/tests/checking/positional_fields/bind_anonymous_field.exp index 09aaa32647c33..2d803a8468b74 100644 --- a/third_party/move/move-compiler-v2/tests/checking/positional_fields/bind_anonymous_field.exp +++ b/third_party/move/move-compiler-v2/tests/checking/positional_fields/bind_anonymous_field.exp @@ -2,10 +2,10 @@ module 0x42::test { enum E1 { V1 { - 0: test::S0, + 0: 0x42::test::S0, } V2 { - 0: test::S1, + 0: 0x42::test::S1, } } struct S0 { @@ -13,9 +13,9 @@ module 0x42::test { } struct S1 { 0: bool, - 1: test::S0, + 1: 0x42::test::S0, } - private fun match(x: test::E1) { + private fun match(x: 0x42::test::E1) { match (x) { test::E1::V1{ 0: test::S0{ 0: _x } } => { Tuple() @@ -26,16 +26,47 @@ module 0x42::test { } } - private fun nested(x: test::S1) { + private fun nested(x: 0x42::test::S1) { { let test::S1{ 0: _x, 1: test::S0{ 0: _y } } = x; Tuple() } } - private fun simple(x: test::S0) { + private fun simple(x: 0x42::test::S0) { { let test::S0{ 0: _x } = x; Tuple() } } } // end 0x42::test + +// -- Sourcified model before bytecode pipeline +module 0x42::test { + enum E1 { + V1 { + 0: S0, + } + V2 { + 0: S1, + } + } + struct S0 { + 0: u8, + } + struct S1 { + 0: bool, + 1: S0, + } + fun match(x: E1) { + match (x) { + E1::V1{0: S0{0: _x}} => (), + E1::V2{0: S1{0: _x,1: S0{0: _y}}} => (), + } + } + fun nested(x: S1) { + let S1{0: _x,1: S0{0: _y}} = x; + } + fun simple(x: S0) { + let S0{0: _x} = x; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/positional_fields/common_access.exp b/third_party/move/move-compiler-v2/tests/checking/positional_fields/common_access.exp index b0f4b0957c213..64c0f5d84aacf 100644 --- a/third_party/move/move-compiler-v2/tests/checking/positional_fields/common_access.exp +++ b/third_party/move/move-compiler-v2/tests/checking/positional_fields/common_access.exp @@ -8,7 +8,22 @@ module 0x42::test { 0: u8, } } - private fun common_access(x: test::Foo): u8 { - select_variants test::Foo.A.0|test::Foo.B.0(x) + private fun common_access(x: 0x42::test::Foo): u8 { + select_variants test::Foo.A.0|test::Foo.B.0(x) } } // end 0x42::test + +// -- Sourcified model before bytecode pipeline +module 0x42::test { + enum Foo has drop { + A { + 0: u8, + } + B { + 0: u8, + } + } + fun common_access(x: Foo): u8 { + x.A.0 + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/positional_fields/decl_ok.exp b/third_party/move/move-compiler-v2/tests/checking/positional_fields/decl_ok.exp index 5280e3ddd0a51..292ece45c67f2 100644 --- a/third_party/move/move-compiler-v2/tests/checking/positional_fields/decl_ok.exp +++ b/third_party/move/move-compiler-v2/tests/checking/positional_fields/decl_ok.exp @@ -20,8 +20,8 @@ module 0x42::test { 1: u8, 2: #0, } - private fun bar(x: test::S2) { - select test::S2.0(x); + private fun bar(x: 0x42::test::S2) { + select test::S2.0(x); Tuple() } private fun baz() { @@ -30,9 +30,44 @@ module 0x42::test { pack test::E1::V3(42, true); Tuple() } - private fun foo(x: test::S2) { - select test::S2.0(x); - select test::S2.1(x); + private fun foo(x: 0x42::test::S2) { + select test::S2.0(x); + select test::S2.1(x); Tuple() } } // end 0x42::test + +// -- Sourcified model before bytecode pipeline +module 0x42::test { + enum E1 { + V1, + V2, + V3 { + 0: u8, + 1: bool, + } + } + struct S1 { + } + struct S2 { + 0: u8, + 1: bool, + } + struct S3 { + 0: T2, + 1: u8, + 2: T1, + } + fun bar(x: S2) { + x.0; + } + fun baz() { + E1::V1{}; + E1::V2{}; + E1::V3{0: 42u8,1: true}; + } + fun foo(x: S2) { + x.0; + x.1; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/positional_fields/named_tuple_ability_decl_ok.exp b/third_party/move/move-compiler-v2/tests/checking/positional_fields/named_tuple_ability_decl_ok.exp index 3271dea2b7566..298a8f310f809 100644 --- a/third_party/move/move-compiler-v2/tests/checking/positional_fields/named_tuple_ability_decl_ok.exp +++ b/third_party/move/move-compiler-v2/tests/checking/positional_fields/named_tuple_ability_decl_ok.exp @@ -20,9 +20,36 @@ module 0x42::test { } struct S5 { 0: #0, - 1: test::S3<#0>, + 1: 0x42::test::S3<#0>, } struct S6 { dummy_field: bool, } } // end 0x42::test + +// -- Sourcified model before bytecode pipeline +module 0x42::test { + struct S has copy, key { + } + struct S1 has drop { + 0: u8, + } + struct S2 has key { + 0: T, + 1: u8, + } + struct S3 has key { + 0: T, + 1: u8, + } + struct S4 has drop { + x: u8, + y: T, + } + struct S5 has key { + 0: T, + 1: S3, + } + struct S6 { + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/positional_fields/named_tuple_construct_ok.exp b/third_party/move/move-compiler-v2/tests/checking/positional_fields/named_tuple_construct_ok.exp index c56d7f9c7a5c1..fdfa85f4155ca 100644 --- a/third_party/move/move-compiler-v2/tests/checking/positional_fields/named_tuple_construct_ok.exp +++ b/third_party/move/move-compiler-v2/tests/checking/positional_fields/named_tuple_construct_ok.exp @@ -29,23 +29,23 @@ module 0x42::test { x: #0, y: u8, } - private fun S0_inhabited(): test::S0 { + private fun S0_inhabited(): 0x42::test::S0 { pack test::S0(false) } - private fun S1_inhabited(): test::S1 { + private fun S1_inhabited(): 0x42::test::S1 { pack test::S1(0) } - private fun S2_inhabited(): test::S2 { + private fun S2_inhabited(): 0x42::test::S2 { pack test::S2(0, false) } - private fun S3_test(x: #0): test::S3<#0> { + private fun S3_test(x: #0): 0x42::test::S3<#0> { pack test::S3(x, 0) } - private fun nested_0(): test::S3 { - pack test::S3(pack test::S4(false), 0) + private fun nested_0(): 0x42::test::S3<0x42::test::S4> { + pack test::S3(pack test::S4(false), 0) } - private fun nested_1(): test::S5 { - pack test::S5(pack test::S0(false), 0) + private fun nested_1(): 0x42::test::S5<0x42::test::S0> { + pack test::S5(pack test::S0(false), 0) } private fun test_variant() { pack test::E1::V1(); @@ -54,3 +54,57 @@ module 0x42::test { Tuple() } } // end 0x42::test + +// -- Sourcified model before bytecode pipeline +module 0x42::test { + enum E1 { + V1, + V2, + V3 { + 0: u8, + 1: bool, + } + } + struct S0 { + } + struct S1 { + 0: u8, + } + struct S2 { + 0: u8, + 1: bool, + } + struct S3 { + 0: T, + 1: u8, + } + struct S4 { + } + struct S5 { + x: T, + y: u8, + } + fun S0_inhabited(): S0 { + S0{} + } + fun S1_inhabited(): S1 { + S1{0: 0u8} + } + fun S2_inhabited(): S2 { + S2{0: 0u8,1: false} + } + fun S3_test(x: T): S3 { + S3{0: x,1: 0u8} + } + fun nested_0(): S3 { + S3{0: S4{},1: 0u8} + } + fun nested_1(): S5 { + S5{x: S0{},y: 0u8} + } + fun test_variant() { + E1::V1{}; + E1::V2{}; + E1::V3{0: 42u8,1: true}; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/positional_fields/variant_ability_decl_ok.exp b/third_party/move/move-compiler-v2/tests/checking/positional_fields/variant_ability_decl_ok.exp index 2b5cb1622dfa7..07b4274a25e4b 100644 --- a/third_party/move/move-compiler-v2/tests/checking/positional_fields/variant_ability_decl_ok.exp +++ b/third_party/move/move-compiler-v2/tests/checking/positional_fields/variant_ability_decl_ok.exp @@ -19,3 +19,25 @@ module 0x42::test { } } } // end 0x42::test + +// -- Sourcified model before bytecode pipeline +module 0x42::test { + enum Bar has copy, drop { + A { + 0: T, + } + B { + 0: u8, + 1: bool, + } + } + enum Foo has copy, drop { + A { + 0: T, + } + B { + 0: u8, + 1: bool, + } + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/receiver/calls.exp b/third_party/move/move-compiler-v2/tests/checking/receiver/calls.exp index 7710862209187..7ccdbc18f5b68 100644 --- a/third_party/move/move-compiler-v2/tests/checking/receiver/calls.exp +++ b/third_party/move/move-compiler-v2/tests/checking/receiver/calls.exp @@ -3,25 +3,51 @@ module 0x42::m { struct S { x: u64, } - private inline fun inline_receiver_ref_mut(self: &mut m::S,y: u64): u64 { - Add(select m::S.x<&mut m::S>(self), y) + private inline fun inline_receiver_ref_mut(self: &mut 0x42::m::S,y: u64): u64 { + Add(select m::S.x<&mut S>(self), y) } - private fun receiver(self: m::S,y: u64): u64 { - Add(select m::S.x(self), y) + private fun receiver(self: 0x42::m::S,y: u64): u64 { + Add(select m::S.x(self), y) } - private fun receiver_ref(self: &m::S,y: u64): u64 { - Add(select m::S.x<&m::S>(self), y) + private fun receiver_ref(self: &0x42::m::S,y: u64): u64 { + Add(select m::S.x<&S>(self), y) } - private fun receiver_ref_mut(self: &mut m::S,y: u64): u64 { - Add(select m::S.x<&mut m::S>(self), y) + private fun receiver_ref_mut(self: &mut 0x42::m::S,y: u64): u64 { + Add(select m::S.x<&mut S>(self), y) } - private fun test_call_styles(s: m::S): u64 { + private fun test_call_styles(s: 0x42::m::S): u64 { m::receiver(s, 1); m::receiver_ref(Borrow(Immutable)(s), 1); m::receiver_ref_mut(Borrow(Mutable)(s), 1); { - let (self: &mut m::S, y: u64): (&mut m::S, u64) = Tuple(Borrow(Mutable)(s), 1); - Add(select m::S.x<&mut m::S>(self), 1) + let (self: &mut S, y: u64): (&mut S, u64) = Tuple(Borrow(Mutable)(s), 1); + Add(select m::S.x<&mut S>(self), 1) } } } // end 0x42::m + +// -- Sourcified model before bytecode pipeline +module 0x42::m { + struct S { + x: u64, + } + inline fun inline_receiver_ref_mut(self: &mut S, y: u64): u64 { + self.x + y + } + fun receiver(self: S, y: u64): u64 { + self.x + y + } + fun receiver_ref(self: &S, y: u64): u64 { + self.x + y + } + fun receiver_ref_mut(self: &mut S, y: u64): u64 { + self.x + y + } + fun test_call_styles(s: S): u64 { + receiver(s, 1); + receiver_ref(&s, 1); + receiver_ref_mut(&mut s, 1); + let (self,y) = (&mut s, 1); + self.x + 1 + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/receiver/calls_with_freeze.exp b/third_party/move/move-compiler-v2/tests/checking/receiver/calls_with_freeze.exp index b21f306bed416..0061771a73d3c 100644 --- a/third_party/move/move-compiler-v2/tests/checking/receiver/calls_with_freeze.exp +++ b/third_party/move/move-compiler-v2/tests/checking/receiver/calls_with_freeze.exp @@ -3,20 +3,20 @@ module 0x42::m { struct S { x: u64, } - private fun sum(self: &m::S,_other: &m::S): u64 { + private fun sum(self: &0x42::m::S,_other: &0x42::m::S): u64 { Abort(1) } - private fun test_arg_freeze(s: m::S): u64 { + private fun test_arg_freeze(s: 0x42::m::S): u64 { { - let p1: &m::S = Borrow(Immutable)(s); + let p1: &S = Borrow(Immutable)(s); { - let p1m: &mut m::S = Borrow(Mutable)(s); + let p1m: &mut S = Borrow(Mutable)(s); { - let s2: m::S = pack m::S(4); + let s2: S = pack m::S(4); { - let p2: &m::S = Borrow(Immutable)(s2); + let p2: &S = Borrow(Immutable)(s2); { - let p2m: &mut m::S = Borrow(Mutable)(s); + let p2m: &mut S = Borrow(Mutable)(s); { let x1: u64 = m::sum(Freeze(false)(p1m), p1); { @@ -37,3 +37,25 @@ module 0x42::m { } } } // end 0x42::m + +// -- Sourcified model before bytecode pipeline +module 0x42::m { + struct S { + x: u64, + } + fun sum(self: &S, _other: &S): u64 { + abort 1 + } + fun test_arg_freeze(s: S): u64 { + let p1 = &s; + let p1m = &mut s; + let s2 = S{x: 4}; + let p2 = &s2; + let p2m = &mut s; + let x1 = sum(/*freeze*/p1m, p1); + let x2 = sum(/*freeze*/p1m, /*freeze*/p1m); + let x3 = sum(/*freeze*/p1m, p2); + let x4 = sum(/*freeze*/p2m, /*freeze*/p2m); + x1 + x2 + x3 + x4 + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/receiver/decl_errors.exp b/third_party/move/move-compiler-v2/tests/checking/receiver/decl_errors.exp index 8df2af098de89..e20c148f536a6 100644 --- a/third_party/move/move-compiler-v2/tests/checking/receiver/decl_errors.exp +++ b/third_party/move/move-compiler-v2/tests/checking/receiver/decl_errors.exp @@ -45,10 +45,10 @@ module 0x42::m { struct S { x: u64, } - private fun receiver(self: m::S) { + private fun receiver(self: 0x42::m::S) { Tuple() } - private fun receiver_for_external_type(self: n::T) { + private fun receiver_for_external_type(self: 0x42::n::T) { Tuple() } private fun receiver_for_external_vector(self: vector) { @@ -57,10 +57,39 @@ module 0x42::m { private fun receiver_for_primitive(self: &u64) { Tuple() } - private fun receiver_non_linear_instantiated(self: m::G<#0, #0>) { + private fun receiver_non_linear_instantiated(self: 0x42::m::G<#0, #0>) { Tuple() } - private fun receiver_partial_instantiated(self: m::G) { + private fun receiver_partial_instantiated(self: 0x42::m::G) { Tuple() } } // end 0x42::m + +// -- Sourcified model before bytecode pipeline +module 0x42::n { + struct T { + x: u64, + } +} +module 0x42::m { + use 0x42::n; + struct G { + x: T, + y: R, + } + struct S { + x: u64, + } + fun receiver(self: S) { + } + fun receiver_for_external_type(self: n::T) { + } + fun receiver_for_external_vector(self: vector) { + } + fun receiver_for_primitive(self: &u64) { + } + fun receiver_non_linear_instantiated(self: G) { + } + fun receiver_partial_instantiated(self: G) { + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/receiver/dont_warn_unused_self.exp b/third_party/move/move-compiler-v2/tests/checking/receiver/dont_warn_unused_self.exp index 135e3d8795172..b1f25c778b2a5 100644 --- a/third_party/move/move-compiler-v2/tests/checking/receiver/dont_warn_unused_self.exp +++ b/third_party/move/move-compiler-v2/tests/checking/receiver/dont_warn_unused_self.exp @@ -11,7 +11,7 @@ module 0x42::m { struct S { x: u64, } - private fun receiver(self: m::S,y: u64) { + private fun receiver(self: 0x42::m::S,y: u64) { Tuple() } spec { @@ -19,3 +19,12 @@ module 0x42::m { } } // end 0x42::m + +// -- Sourcified model before bytecode pipeline +module 0x42::m { + struct S has drop { + x: u64, + } + fun receiver(self: S, y: u64) { + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/receiver/generic_calls.exp b/third_party/move/move-compiler-v2/tests/checking/receiver/generic_calls.exp index b396815647805..b0ef28a181601 100644 --- a/third_party/move/move-compiler-v2/tests/checking/receiver/generic_calls.exp +++ b/third_party/move/move-compiler-v2/tests/checking/receiver/generic_calls.exp @@ -3,30 +3,30 @@ module 0x42::m { struct S { x: #0, } - private fun id(self: m::S<#0>): m::S<#0> { + private fun id(self: 0x42::m::S<#0>): 0x42::m::S<#0> { self } - private inline fun inlined(f: |m::S<#0>|m::S<#0>,s: m::S<#0>) { + private inline fun inlined(f: |0x42::m::S<#0>|0x42::m::S<#0>,s: 0x42::m::S<#0>) { (f)(s); Tuple() } - private fun receiver(self: m::S<#0>,y: #0) { - select m::S.x>(self) = y; + private fun receiver(self: 0x42::m::S<#0>,y: #0) { + select m::S.x>(self) = y; Tuple() } - private fun receiver_more_generics(self: m::S<#0>,_y: #1) { + private fun receiver_more_generics(self: 0x42::m::S<#0>,_y: #1) { Tuple() } - private fun receiver_needs_type_args(self: m::S<#0>,_y: #0) { + private fun receiver_needs_type_args(self: 0x42::m::S<#0>,_y: #0) { Abort(1) } - private fun receiver_ref(self: &m::S<#0>,_y: #0) { + private fun receiver_ref(self: &0x42::m::S<#0>,_y: #0) { Tuple() } - private fun receiver_ref_mut(self: &mut m::S<#0>,y: #0) { - select m::S.x<&mut m::S>(self) = y + private fun receiver_ref_mut(self: &mut 0x42::m::S<#0>,y: #0) { + select m::S.x<&mut S>(self) = y } - private fun test_call_styles(s: m::S,x: u64) { + private fun test_call_styles(s: 0x42::m::S,x: u64) { m::receiver(s, x); m::receiver_ref(Borrow(Immutable)(s), x); m::receiver_ref_mut(Borrow(Mutable)(s), x); @@ -34,14 +34,54 @@ module 0x42::m { m::receiver_needs_type_args(s, x); Tuple() } - private fun test_receiver_inference(s: m::S) { + private fun test_receiver_inference(s: 0x42::m::S) { { - let (s: m::S): (m::S) = Tuple(s); + let (s: S): (S) = Tuple(s); { - let (s: m::S): (m::S) = Tuple(s); + let (s: S): (S) = Tuple(s); m::id(s) }; Tuple() } } } // end 0x42::m + +// -- Sourcified model before bytecode pipeline +module 0x42::m { + struct S { + x: T, + } + fun id(self: S): S { + self + } + inline fun inlined(f: |S|S, s: S) { + f(s); + } + fun receiver(self: S, y: T) { + self.x = y; + } + fun receiver_more_generics(self: S, _y: R) { + } + fun receiver_needs_type_args(self: S, _y: T) { + abort 1 + } + fun receiver_ref(self: &S, _y: T) { + } + fun receiver_ref_mut(self: &mut S, y: T) { + self.x = y + } + fun test_call_styles(s: S, x: u64) { + receiver(s, x); + receiver_ref(&s, x); + receiver_ref_mut(&mut s, x); + receiver_more_generics(s, 22); + receiver_needs_type_args(s, x); + } + fun test_receiver_inference(s: S) { + let (s) = (s); + { + let (s) = (s); + id(s) + }; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/receiver/generic_calls_typed.exp b/third_party/move/move-compiler-v2/tests/checking/receiver/generic_calls_typed.exp index b396815647805..b0ef28a181601 100644 --- a/third_party/move/move-compiler-v2/tests/checking/receiver/generic_calls_typed.exp +++ b/third_party/move/move-compiler-v2/tests/checking/receiver/generic_calls_typed.exp @@ -3,30 +3,30 @@ module 0x42::m { struct S { x: #0, } - private fun id(self: m::S<#0>): m::S<#0> { + private fun id(self: 0x42::m::S<#0>): 0x42::m::S<#0> { self } - private inline fun inlined(f: |m::S<#0>|m::S<#0>,s: m::S<#0>) { + private inline fun inlined(f: |0x42::m::S<#0>|0x42::m::S<#0>,s: 0x42::m::S<#0>) { (f)(s); Tuple() } - private fun receiver(self: m::S<#0>,y: #0) { - select m::S.x>(self) = y; + private fun receiver(self: 0x42::m::S<#0>,y: #0) { + select m::S.x>(self) = y; Tuple() } - private fun receiver_more_generics(self: m::S<#0>,_y: #1) { + private fun receiver_more_generics(self: 0x42::m::S<#0>,_y: #1) { Tuple() } - private fun receiver_needs_type_args(self: m::S<#0>,_y: #0) { + private fun receiver_needs_type_args(self: 0x42::m::S<#0>,_y: #0) { Abort(1) } - private fun receiver_ref(self: &m::S<#0>,_y: #0) { + private fun receiver_ref(self: &0x42::m::S<#0>,_y: #0) { Tuple() } - private fun receiver_ref_mut(self: &mut m::S<#0>,y: #0) { - select m::S.x<&mut m::S>(self) = y + private fun receiver_ref_mut(self: &mut 0x42::m::S<#0>,y: #0) { + select m::S.x<&mut S>(self) = y } - private fun test_call_styles(s: m::S,x: u64) { + private fun test_call_styles(s: 0x42::m::S,x: u64) { m::receiver(s, x); m::receiver_ref(Borrow(Immutable)(s), x); m::receiver_ref_mut(Borrow(Mutable)(s), x); @@ -34,14 +34,54 @@ module 0x42::m { m::receiver_needs_type_args(s, x); Tuple() } - private fun test_receiver_inference(s: m::S) { + private fun test_receiver_inference(s: 0x42::m::S) { { - let (s: m::S): (m::S) = Tuple(s); + let (s: S): (S) = Tuple(s); { - let (s: m::S): (m::S) = Tuple(s); + let (s: S): (S) = Tuple(s); m::id(s) }; Tuple() } } } // end 0x42::m + +// -- Sourcified model before bytecode pipeline +module 0x42::m { + struct S { + x: T, + } + fun id(self: S): S { + self + } + inline fun inlined(f: |S|S, s: S) { + f(s); + } + fun receiver(self: S, y: T) { + self.x = y; + } + fun receiver_more_generics(self: S, _y: R) { + } + fun receiver_needs_type_args(self: S, _y: T) { + abort 1 + } + fun receiver_ref(self: &S, _y: T) { + } + fun receiver_ref_mut(self: &mut S, y: T) { + self.x = y + } + fun test_call_styles(s: S, x: u64) { + receiver(s, x); + receiver_ref(&s, x); + receiver_ref_mut(&mut s, x); + receiver_more_generics(s, 22); + receiver_needs_type_args(s, x); + } + fun test_receiver_inference(s: S) { + let (s) = (s); + { + let (s) = (s); + id(s) + }; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/receiver/same_names.exp b/third_party/move/move-compiler-v2/tests/checking/receiver/same_names.exp index b45494f8c2cf6..2dacf49d882be 100644 --- a/third_party/move/move-compiler-v2/tests/checking/receiver/same_names.exp +++ b/third_party/move/move-compiler-v2/tests/checking/receiver/same_names.exp @@ -3,25 +3,25 @@ module 0x42::b { struct MyOtherList { len: u64, } - public fun len(self: &b::MyOtherList): u64 { - select b::MyOtherList.len<&b::MyOtherList>(self) + public fun len(self: &0x42::b::MyOtherList): u64 { + select b::MyOtherList.len<&MyOtherList>(self) } } // end 0x42::b module 0x42::a { struct MyList { len: u64, } - public fun len(self: &a::MyList): u64 { - select a::MyList.len<&a::MyList>(self) + public fun len(self: &0x42::a::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 inline fun foo(f: |(a::MyList, b::MyOtherList)|,x: a::MyList,y: b::MyOtherList) { + private inline fun foo(f: |(0x42::a::MyList, 0x42::b::MyOtherList)|,x: 0x42::a::MyList,y: 0x42::b::MyOtherList) { (f)(x, y) } - private fun test(x: a::MyList,y: b::MyOtherList) { + private fun test(x: 0x42::a::MyList,y: 0x42::b::MyOtherList) { { let (x: a::MyList, y: b::MyOtherList): (a::MyList, b::MyOtherList) = Tuple(x, y); { @@ -35,3 +35,33 @@ module 0x42::c { } } } // end 0x42::c + +// -- Sourcified model before bytecode pipeline +module 0x42::b { + struct MyOtherList { + len: u64, + } + public fun len(self: &MyOtherList): u64 { + self.len + } +} +module 0x42::a { + struct MyList { + len: u64, + } + public fun len(self: &MyList): u64 { + self.len + } +} +module 0x42::c { + use 0x42::b; + use 0x42::a; + inline fun foo(f: |(a::MyList, b::MyOtherList)|, x: a::MyList, y: b::MyOtherList) { + f(x, y) + } + fun test(x: a::MyList, y: b::MyOtherList) { + let (x,y) = (x, y); + let (x,y) = (x, y); + if (a::len(&x) + b::len(&y) == 1) () else abort 1 + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/receiver/same_names_typed.exp b/third_party/move/move-compiler-v2/tests/checking/receiver/same_names_typed.exp index b45494f8c2cf6..2dacf49d882be 100644 --- a/third_party/move/move-compiler-v2/tests/checking/receiver/same_names_typed.exp +++ b/third_party/move/move-compiler-v2/tests/checking/receiver/same_names_typed.exp @@ -3,25 +3,25 @@ module 0x42::b { struct MyOtherList { len: u64, } - public fun len(self: &b::MyOtherList): u64 { - select b::MyOtherList.len<&b::MyOtherList>(self) + public fun len(self: &0x42::b::MyOtherList): u64 { + select b::MyOtherList.len<&MyOtherList>(self) } } // end 0x42::b module 0x42::a { struct MyList { len: u64, } - public fun len(self: &a::MyList): u64 { - select a::MyList.len<&a::MyList>(self) + public fun len(self: &0x42::a::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 inline fun foo(f: |(a::MyList, b::MyOtherList)|,x: a::MyList,y: b::MyOtherList) { + private inline fun foo(f: |(0x42::a::MyList, 0x42::b::MyOtherList)|,x: 0x42::a::MyList,y: 0x42::b::MyOtherList) { (f)(x, y) } - private fun test(x: a::MyList,y: b::MyOtherList) { + private fun test(x: 0x42::a::MyList,y: 0x42::b::MyOtherList) { { let (x: a::MyList, y: b::MyOtherList): (a::MyList, b::MyOtherList) = Tuple(x, y); { @@ -35,3 +35,33 @@ module 0x42::c { } } } // end 0x42::c + +// -- Sourcified model before bytecode pipeline +module 0x42::b { + struct MyOtherList { + len: u64, + } + public fun len(self: &MyOtherList): u64 { + self.len + } +} +module 0x42::a { + struct MyList { + len: u64, + } + public fun len(self: &MyList): u64 { + self.len + } +} +module 0x42::c { + use 0x42::b; + use 0x42::a; + inline fun foo(f: |(a::MyList, b::MyOtherList)|, x: a::MyList, y: b::MyOtherList) { + f(x, y) + } + fun test(x: a::MyList, y: b::MyOtherList) { + let (x,y) = (x, y); + let (x,y) = (x, y); + if (a::len(&x) + b::len(&y) == 1) () else abort 1 + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/receiver/vectors.exp b/third_party/move/move-compiler-v2/tests/checking/receiver/vectors.exp index 35e73d04076f8..036ee78391b29 100644 --- a/third_party/move/move-compiler-v2/tests/checking/receiver/vectors.exp +++ b/third_party/move/move-compiler-v2/tests/checking/receiver/vectors.exp @@ -16,3 +16,18 @@ module 0x1::vector { Tuple() } } // end 0x1::vector + +// -- Sourcified model before bytecode pipeline +module 0x1::vector { + fun receiver(self: vector, _y: T) { + } + fun receiver_ref(self: &vector, _y: T) { + } + fun receiver_ref_mut(self: &mut vector, _y: T) { + } + fun test_call_styles(s: vector, x: u64) { + receiver(s, x); + receiver_ref(&s, x); + receiver_ref_mut(&mut s, x); + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/specs/assert_skipped_for_spec.exp b/third_party/move/move-compiler-v2/tests/checking/specs/assert_skipped_for_spec.exp index 35729286d8c52..6c0bb9bfdcd4d 100644 --- a/third_party/move/move-compiler-v2/tests/checking/specs/assert_skipped_for_spec.exp +++ b/third_party/move/move-compiler-v2/tests/checking/specs/assert_skipped_for_spec.exp @@ -15,3 +15,11 @@ module 0x42::M { Sub(x, 1) } } // end 0x42::M + +// -- Sourcified model before bytecode pipeline +module 0x42::M { + fun bar(x: u64): u64 { + if (x > 0) () else abort 1; + x - 1 + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/specs/conditions_ok.exp b/third_party/move/move-compiler-v2/tests/checking/specs/conditions_ok.exp index 54fe8ac5132a6..662b02e08d47d 100644 --- a/third_party/move/move-compiler-v2/tests/checking/specs/conditions_ok.exp +++ b/third_party/move/move-compiler-v2/tests/checking/specs/conditions_ok.exp @@ -8,7 +8,7 @@ module 0x42::M { Deref(x) } spec { - aborts_if Or(Eq(Freeze(false)($t0), 0), Eq(select M::Ghost$some_global.v(global(0x0)), 0)); + aborts_if Or(Eq(Freeze(false)($t0), 0), Eq(select M::Ghost$some_global.v(global<0x42::M::Ghost$some_global>(0x0)), 0)); ensures Gt(Old($t0), $t0); ensures Eq(result0(), Freeze(false)($t0)); } @@ -30,3 +30,20 @@ module 0x42::M { } } // end 0x42::M + +// -- Sourcified model before bytecode pipeline +module 0x42::M { + struct Ghost$some_global has copy, drop, store, key { + v: u64, + } + fun add_some(x: &mut u64): u64 { + *x = *x + 1; + *x + } + fun multiple_results(x: u64): (u64, bool) { + (x, true) + } + fun with_emits(_guid: vector, _msg: T, x: u64): u64 { + x + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/specs/expressions_ok.exp b/third_party/move/move-compiler-v2/tests/checking/specs/expressions_ok.exp index c1a6dc4437405..cb024a2ab2a64 100644 --- a/third_party/move/move-compiler-v2/tests/checking/specs/expressions_ok.exp +++ b/third_party/move/move-compiler-v2/tests/checking/specs/expressions_ok.exp @@ -62,3 +62,7 @@ module 0x42::M { M::generic_function(3, 3) } } // end 0x42::M + +// -- Sourcified model before bytecode pipeline +module 0x42::M { +} diff --git a/third_party/move/move-compiler-v2/tests/checking/specs/inline_fun_in_spec.exp b/third_party/move/move-compiler-v2/tests/checking/specs/inline_fun_in_spec.exp index 07a0195d39472..2a255ec036435 100644 --- a/third_party/move/move-compiler-v2/tests/checking/specs/inline_fun_in_spec.exp +++ b/third_party/move/move-compiler-v2/tests/checking/specs/inline_fun_in_spec.exp @@ -1,14 +1,14 @@ // -- Model dump before bytecode pipeline module 0x42::m { spec { - invariant forall a: address: TypeDomain
(): Implies(exists(a), { + invariant forall a: address: TypeDomain
(): Implies(exists<0x42::m::S>(a), { let (x: address): (address) = Tuple(a); { let r: bool = { let (a: address): (address) = Tuple(x); - Lt(select m::S.f({ + Lt(select m::S.f<0x42::m::S>({ let (a: address): (address) = Tuple(a); - global(a) + global<0x42::m::S>(a) }), 10) }; r @@ -78,3 +78,59 @@ module 0x42::m { BorrowGlobal(Immutable)(a) } } // end 0x42::m + +// -- Sourcified model before bytecode pipeline +module 0x42::m { + struct S has key { + f: u64, + } + /* + spec { + invariant { + let (x: num): (num) = Tuple(select m::S.f()); + { + let r: bool = { + let (x: num): (num) = Tuple(x); + Gt(x, 0) + }; + r + } + }; + } + + */ + inline fun exec(f: |T|R, x: T): R { + let r = f(x); + + /* spec { + assert Eq<#1>(r, (f)($t1)); + } + */ + ; + r + } + fun function_code_spec_block(x: u64): u64 { + + /* spec { + assert { + let (x: num): (num) = Tuple($t0); + { + let r: bool = { + let (y: num): (num) = Tuple(x); + Gt(y, 0) + }; + r + } + }; + } + */ + ; + x + 1 + } + fun function_spec_block(x: u64): u64 { + x + 1 + } + inline fun get(a: address): &R { + borrow_global(a) + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/specs/inline_fun_in_spec_typed.exp b/third_party/move/move-compiler-v2/tests/checking/specs/inline_fun_in_spec_typed.exp index e3c750934cc8c..0b0133cc30042 100644 --- a/third_party/move/move-compiler-v2/tests/checking/specs/inline_fun_in_spec_typed.exp +++ b/third_party/move/move-compiler-v2/tests/checking/specs/inline_fun_in_spec_typed.exp @@ -1,14 +1,14 @@ // -- Model dump before bytecode pipeline module 0x42::m { spec { - invariant forall a: address: TypeDomain
(): Implies(exists(a), { + invariant forall a: address: TypeDomain
(): Implies(exists<0x42::m::S>(a), { let (x: address): (address) = Tuple(a); { let r: bool = { let (a: address): (address) = Tuple(x); - Lt(select m::S.f({ + Lt(select m::S.f<0x42::m::S>({ let (a: address): (address) = Tuple(a); - global(a) + global<0x42::m::S>(a) }), 10) }; r @@ -78,3 +78,59 @@ module 0x42::m { BorrowGlobal(Immutable)(a) } } // end 0x42::m + +// -- Sourcified model before bytecode pipeline +module 0x42::m { + struct S has key { + f: u64, + } + /* + spec { + invariant { + let (x: u64): (u64) = Tuple(select m::S.f()); + { + let r: bool = { + let (x: u64): (u64) = Tuple(x); + Gt(x, 0) + }; + r + } + }; + } + + */ + inline fun exec(f: |T|R, x: T): R { + let r = f(x); + + /* spec { + assert Eq<#1>(r, (f)($t1)); + } + */ + ; + r + } + fun function_code_spec_block(x: u64): u64 { + + /* spec { + assert { + let (x: u64): (u64) = Tuple($t0); + { + let r: bool = { + let (y: u64): (u64) = Tuple(x); + Gt(y, 0) + }; + r + } + }; + } + */ + ; + x + 1 + } + fun function_spec_block(x: u64): u64 { + x + 1 + } + inline fun get(a: address): &R { + borrow_global(a) + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/specs/inline_fun_spec_ok.exp b/third_party/move/move-compiler-v2/tests/checking/specs/inline_fun_spec_ok.exp index fc26e019be673..42ce1545caefb 100644 --- a/third_party/move/move-compiler-v2/tests/checking/specs/inline_fun_spec_ok.exp +++ b/third_party/move/move-compiler-v2/tests/checking/specs/inline_fun_spec_ok.exp @@ -8,3 +8,16 @@ module 0x42::M { 42 } } // end 0x42::M + +// -- Sourcified model before bytecode pipeline +module 0x42::M { + public inline fun f(): u64 { + + /* spec { + assert true; + } + */ + ; + 42 + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/specs/inline_spec_inference.exp b/third_party/move/move-compiler-v2/tests/checking/specs/inline_spec_inference.exp index 6073b62bbaa43..382979923cce9 100644 --- a/third_party/move/move-compiler-v2/tests/checking/specs/inline_spec_inference.exp +++ b/third_party/move/move-compiler-v2/tests/checking/specs/inline_spec_inference.exp @@ -11,3 +11,17 @@ module 0x42::m { } } } // end 0x42::m + +// -- Sourcified model before bytecode pipeline +module 0x42::m { + fun foo() { + let i = 10; + + /* spec { + assert forall j: num: Range(0, i): Lt(j, i); + } + */ + ; + i = i + 1 + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/specs/inline_spec_inference_bitvector.exp b/third_party/move/move-compiler-v2/tests/checking/specs/inline_spec_inference_bitvector.exp index f60c5fa68e8f8..6f8111e4122ff 100644 --- a/third_party/move/move-compiler-v2/tests/checking/specs/inline_spec_inference_bitvector.exp +++ b/third_party/move/move-compiler-v2/tests/checking/specs/inline_spec_inference_bitvector.exp @@ -22,3 +22,21 @@ module 0x42::bit_vector_infer { } } } // end 0x42::bit_vector_infer + +// -- Sourcified model before bytecode pipeline +module 0x42::bit_vector_infer { + public fun new(_length: u64) { + let counter = 1; + if (counter > 0) { + counter = counter - 1; + }; + let bit_field = 0x1::vector::empty(); + 0x1::vector::push_back(&mut bit_field, false); + + /* spec { + assert Eq(Len(bit_field), 0); + } + */ + ; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/specs/inline_spec_inference_vector.exp b/third_party/move/move-compiler-v2/tests/checking/specs/inline_spec_inference_vector.exp index d0b499f33c6f9..3034b88d36648 100644 --- a/third_party/move/move-compiler-v2/tests/checking/specs/inline_spec_inference_vector.exp +++ b/third_party/move/move-compiler-v2/tests/checking/specs/inline_spec_inference_vector.exp @@ -13,3 +13,17 @@ module 0x42::bit_vector { } } } // end 0x42::bit_vector + +// -- Sourcified model before bytecode pipeline +module 0x42::bit_vector { + public fun new(_length: u64) { + let bit_field = 0x1::vector::empty(); + + /* spec { + assert Eq(Len(bit_field), 0); + } + */ + ; + 0x1::vector::push_back(&mut bit_field, false); + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/specs/inline_spec_old.exp b/third_party/move/move-compiler-v2/tests/checking/specs/inline_spec_old.exp index f0d2ba60255f7..fc1cae43ff96c 100644 --- a/third_party/move/move-compiler-v2/tests/checking/specs/inline_spec_old.exp +++ b/third_party/move/move-compiler-v2/tests/checking/specs/inline_spec_old.exp @@ -8,3 +8,15 @@ module 0x42::m { Tuple() } } // end 0x42::m + +// -- Sourcified model before bytecode pipeline +module 0x42::m { + public fun foo(vec: &mut vector) { + + /* spec { + assert forall k: num: Range(0, Len($t0)): Eq(Index($t0, k), Index(Old>($t0), k)); + } + */ + ; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/specs/intrinsic_decl_ok.exp b/third_party/move/move-compiler-v2/tests/checking/specs/intrinsic_decl_ok.exp index 6b81d226f4150..a377c93e8b35c 100644 --- a/third_party/move/move-compiler-v2/tests/checking/specs/intrinsic_decl_ok.exp +++ b/third_party/move/move-compiler-v2/tests/checking/specs/intrinsic_decl_ok.exp @@ -12,18 +12,44 @@ module 0x42::M { spec { } - private native fun contains(t: &M::MyTable2<#0, #1>,k: #0): bool; - private native fun borrow(t: &M::MyTable2<#0, #1>,k: #0):  - private native fun borrow_mut(t: &mut M::MyTable1<#0, #1>,k: #0): &mut #1; - private native fun destroy_empty(t: M::MyTable1<#0, #1>); - private native fun length(t: &M::MyTable1<#0, #1>): u64; - private native fun remove(t: &mut M::MyTable2<#0, #1>,k: #0): #1; - private native fun new(): M::MyTable1<#0, #1>; - private native fun new2(): M::MyTable2<#0, #1>; - spec fun spec_len(t: M::MyTable1<#0, #1>): num; - spec fun spec_set(t: M::MyTable1<#0, #1>,k: #0,v: #1): M::MyTable1<#0, #1>; - spec fun spec_get(t: M::MyTable1<#0, #1>,k: #0): #1; - spec fun spec_len2(t: M::MyTable2<#0, #1>): num; - spec fun spec_del(t: M::MyTable2<#0, #1>): num; - spec fun spec_has_key(t: M::MyTable2<#0, #1>,k: #0): bool; + private native fun contains(t: &0x42::M::MyTable2<#0, #1>,k: #0): bool; + private native fun borrow(t: &0x42::M::MyTable2<#0, #1>,k: #0):  + private native fun borrow_mut(t: &mut 0x42::M::MyTable1<#0, #1>,k: #0): &mut #1; + private native fun destroy_empty(t: 0x42::M::MyTable1<#0, #1>); + private native fun length(t: &0x42::M::MyTable1<#0, #1>): u64; + private native fun remove(t: &mut 0x42::M::MyTable2<#0, #1>,k: #0): #1; + private native fun new(): 0x42::M::MyTable1<#0, #1>; + private native fun new2(): 0x42::M::MyTable2<#0, #1>; + spec fun spec_len(t: 0x42::M::MyTable1<#0, #1>): num; + spec fun spec_set(t: 0x42::M::MyTable1<#0, #1>,k: #0,v: #1): 0x42::M::MyTable1<#0, #1>; + spec fun spec_get(t: 0x42::M::MyTable1<#0, #1>,k: #0): #1; + spec fun spec_len2(t: 0x42::M::MyTable2<#0, #1>): num; + spec fun spec_del(t: 0x42::M::MyTable2<#0, #1>): num; + spec fun spec_has_key(t: 0x42::M::MyTable2<#0, #1>,k: #0): bool; } // end 0x42::M + +// -- Sourcified model before bytecode pipeline +module 0x42::M { + struct MyTable1 { + } + /* + spec { + } + + */ + struct MyTable2 { + } + /* + spec { + } + + */ + native fun contains(t: &MyTable2, k: K): bool ; + native fun borrow(t: &MyTable2, k: K): &V ; + native fun borrow_mut(t: &mut MyTable1, k: K): &mut V ; + native fun destroy_empty(t: MyTable1) ; + native fun length(t: &MyTable1): u64 ; + native fun remove(t: &mut MyTable2, k: K): V ; + native fun new(): MyTable1 ; + native fun new2(): MyTable2 ; +} diff --git a/third_party/move/move-compiler-v2/tests/checking/specs/invariants_ok.exp b/third_party/move/move-compiler-v2/tests/checking/specs/invariants_ok.exp index adfbe05e60cbc..a7059c9346e06 100644 --- a/third_party/move/move-compiler-v2/tests/checking/specs/invariants_ok.exp +++ b/third_party/move/move-compiler-v2/tests/checking/specs/invariants_ok.exp @@ -1,10 +1,10 @@ // -- Model dump before bytecode pipeline module 0x42::M { struct R { - s: M::S, + s: 0x42::M::S, } spec { - invariant M::less10(true, select M::S.x(select M::R.s())); + invariant M::less10(true, select M::S.x<0x42::M::S>(select M::R.s())); } struct S { @@ -26,3 +26,26 @@ module 0x42::M { M::less10(Not(c), x) } } // end 0x42::M + +// -- Sourcified model before bytecode pipeline +module 0x42::M { + struct R { + s: S, + } + /* + spec { + invariant M::less10(true, select M::S.x<0x42::M::S>(select M::R.s())); + } + + */ + struct S { + x: u64, + y: bool, + } + /* + spec { + invariant Eq(Gt(select M::S.x(), 0), select M::S.y()); + } + + */ +} diff --git a/third_party/move/move-compiler-v2/tests/checking/specs/lets_ok.exp b/third_party/move/move-compiler-v2/tests/checking/specs/lets_ok.exp index 4cba29d734223..a89a56075d873 100644 --- a/third_party/move/move-compiler-v2/tests/checking/specs/lets_ok.exp +++ b/third_party/move/move-compiler-v2/tests/checking/specs/lets_ok.exp @@ -11,3 +11,11 @@ module 0x42::M { } } // end 0x42::M + +// -- Sourcified model before bytecode pipeline +module 0x42::M { + fun foo(x: &mut u64): u64 { + *x = *x + 1; + *x + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/specs/move_function_in_spec_ok.exp b/third_party/move/move-compiler-v2/tests/checking/specs/move_function_in_spec_ok.exp index f6a3025c7b239..9266d040570f5 100644 --- a/third_party/move/move-compiler-v2/tests/checking/specs/move_function_in_spec_ok.exp +++ b/third_party/move/move-compiler-v2/tests/checking/specs/move_function_in_spec_ok.exp @@ -5,12 +5,12 @@ module 0x42::move_function_in_spec { } private fun foo() { { - let type_info: move_function_in_spec::TypeInfo = move_function_in_spec::type_of(); + let type_info: TypeInfo = move_function_in_spec::type_of(); { - let account_address: address = select move_function_in_spec::TypeInfo.account_address(type_info); + let account_address: address = select move_function_in_spec::TypeInfo.account_address(type_info); spec { assert move_function_in_spec::$no_change(account_address, account_address); - assert Eq
(account_address, select move_function_in_spec::TypeInfo.account_address(move_function_in_spec::$type_of<#0>())); + assert Eq
(account_address, select move_function_in_spec::TypeInfo.account_address<0x42::move_function_in_spec::TypeInfo>(move_function_in_spec::$type_of<#0>())); } ; Tuple() @@ -18,23 +18,50 @@ module 0x42::move_function_in_spec { } } public fun no_change(target: address,new_addr: address): bool - acquires move_function_in_spec::TypeInfo(*) + acquires 0x42::move_function_in_spec::TypeInfo(*) { { - let ty: &move_function_in_spec::TypeInfo = BorrowGlobal(Immutable)(target); - Eq
(select move_function_in_spec::TypeInfo.account_address<&move_function_in_spec::TypeInfo>(ty), new_addr) + let ty: &TypeInfo = BorrowGlobal(Immutable)(target); + Eq
(select move_function_in_spec::TypeInfo.account_address<&TypeInfo>(ty), new_addr) } } - public fun type_of(): move_function_in_spec::TypeInfo { + public fun type_of(): 0x42::move_function_in_spec::TypeInfo { Abort(1) } spec fun $no_change(target: address,new_addr: address): bool { { - let ty: &move_function_in_spec::TypeInfo = global(target); - Eq
(select move_function_in_spec::TypeInfo.account_address(ty), new_addr) + let ty: &0x42::move_function_in_spec::TypeInfo = global<0x42::move_function_in_spec::TypeInfo>(target); + Eq
(select move_function_in_spec::TypeInfo.account_address<0x42::move_function_in_spec::TypeInfo>(ty), new_addr) } } - spec fun $type_of(): move_function_in_spec::TypeInfo { + spec fun $type_of(): 0x42::move_function_in_spec::TypeInfo { Tuple() } } // end 0x42::move_function_in_spec + +// -- Sourcified model before bytecode pipeline +module 0x42::move_function_in_spec { + struct TypeInfo has copy, drop, store, key { + account_address: address, + } + fun foo() { + let type_info = type_of(); + let account_address = type_info.account_address; + + /* spec { + assert move_function_in_spec::$no_change(account_address, account_address); + assert Eq
(account_address, select move_function_in_spec::TypeInfo.account_address<0x42::move_function_in_spec::TypeInfo>(move_function_in_spec::$type_of<#0>())); + } + */ + ; + } + public fun no_change(target: address, new_addr: address): bool + acquires TypeInfo + { + let ty = borrow_global(target); + ty.account_address == new_addr + } + public fun type_of(): TypeInfo { + abort 1 + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/specs/quantifiers_ok.exp b/third_party/move/move-compiler-v2/tests/checking/specs/quantifiers_ok.exp index bef42715930d6..b4258f9204f1d 100644 --- a/third_party/move/move-compiler-v2/tests/checking/specs/quantifiers_ok.exp +++ b/third_party/move/move-compiler-v2/tests/checking/specs/quantifiers_ok.exp @@ -3,10 +3,17 @@ module 0x42::M { struct S { x: u64, } - spec fun exists_in_vector(v: vector): bool { - exists s: M::S: v: Gt(select M::S.x(s), 0) + spec fun exists_in_vector(v: vector<0x42::M::S>): bool { + exists s: 0x42::M::S: v: Gt(select M::S.x<0x42::M::S>(s), 0) } - spec fun some_in_vector(v: vector): M::S { - choose s: M::S: v: Eq(select M::S.x(s), 0) + spec fun some_in_vector(v: vector<0x42::M::S>): 0x42::M::S { + choose s: 0x42::M::S: v: Eq(select M::S.x<0x42::M::S>(s), 0) } } // end 0x42::M + +// -- Sourcified model before bytecode pipeline +module 0x42::M { + struct S { + x: u64, + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/specs/schemas_ok.exp b/third_party/move/move-compiler-v2/tests/checking/specs/schemas_ok.exp index 3ef30afac08f9..4c8215291a695 100644 --- a/third_party/move/move-compiler-v2/tests/checking/specs/schemas_ok.exp +++ b/third_party/move/move-compiler-v2/tests/checking/specs/schemas_ok.exp @@ -75,3 +75,18 @@ module 0x42::M { } } // end 0x42::M + +// -- Sourcified model before bytecode pipeline +module 0x42::M { + struct S { + x: X, + } + fun add(x: u64): u64 { + x + 1 + } + fun id(x: u64): u64 { + x + } + fun multiple(_x: u64, _y: u64) { + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/specs/structs_ok.exp b/third_party/move/move-compiler-v2/tests/checking/specs/structs_ok.exp index 591fc4fd388df..4f8d0f14f9d35 100644 --- a/third_party/move/move-compiler-v2/tests/checking/specs/structs_ok.exp +++ b/third_party/move/move-compiler-v2/tests/checking/specs/structs_ok.exp @@ -8,26 +8,26 @@ module 0x42::M { y: bool, } struct R { - s: M::S, + s: 0x42::M::S, } struct S { x: u64, y: bool, z: vector, } - public fun f(r: M::R): M::T { - pack M::T(select M::S.x(select M::R.s(r))) + public fun f(r: 0x42::M::R): 0x42::M::T { + pack M::T(select M::S.x(select M::R.s(r))) } - spec fun struct_access(s: M::S): u64 { - select M::S.x(s) + spec fun struct_access(s: 0x42::M::S): u64 { + select M::S.x<0x42::M::S>(s) } - spec fun nested_struct_access(r: M::R): bool { - select M::S.y(select M::R.s(r)) + spec fun nested_struct_access(r: 0x42::M::R): bool { + select M::S.y<0x42::M::S>(select M::R.s<0x42::M::R>(r)) } - spec fun struct_pack(x: u64,y: bool,z: vector): M::S { + spec fun struct_pack(x: u64,y: bool,z: vector): 0x42::M::S { pack M::S(x, y, z) } - spec fun struct_pack_other_order(x: u64,y: bool,z: vector): M::S { + spec fun struct_pack_other_order(x: u64,y: bool,z: vector): 0x42::M::S { { let $z: vector = z; { @@ -36,16 +36,38 @@ module 0x42::M { } } } - spec fun generic_struct_pack(x: u64,y: bool): M::G { + spec fun generic_struct_pack(x: u64,y: bool): 0x42::M::G { pack M::G(x, y) } - spec fun generic_struct_pack_instantiated(x: u64,y: bool): M::G { + spec fun generic_struct_pack_instantiated(x: u64,y: bool): 0x42::M::G { pack M::G(x, y) } - spec fun resource_global(addr: address): M::T { - global(addr) + spec fun resource_global(addr: address): 0x42::M::T { + global<0x42::M::T>(addr) } spec fun resource_global_exists(addr: address): bool { - exists(addr) + exists<0x42::M::T>(addr) } } // end 0x42::M + +// -- Sourcified model before bytecode pipeline +module 0x42::M { + struct T has key { + x: u64, + } + struct G { + x: T, + y: bool, + } + struct R has drop { + s: S, + } + struct S has drop { + x: u64, + y: bool, + z: vector, + } + public fun f(r: R): T { + T{x: r.s.x} + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/specs/type_variance_ok.exp b/third_party/move/move-compiler-v2/tests/checking/specs/type_variance_ok.exp index 2c0d1376d130b..a4d2c3eb0a363 100644 --- a/third_party/move/move-compiler-v2/tests/checking/specs/type_variance_ok.exp +++ b/third_party/move/move-compiler-v2/tests/checking/specs/type_variance_ok.exp @@ -8,3 +8,10 @@ module 0x42::M { } } // end 0x42::M + +// -- Sourcified model before bytecode pipeline +module 0x42::M { + fun foo(v: vector): vector { + v + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/specs/update_field_ok.exp b/third_party/move/move-compiler-v2/tests/checking/specs/update_field_ok.exp index a808e4517a749..1e22285d1e847 100644 --- a/third_party/move/move-compiler-v2/tests/checking/specs/update_field_ok.exp +++ b/third_party/move/move-compiler-v2/tests/checking/specs/update_field_ok.exp @@ -4,16 +4,27 @@ module 0x42::update_field_ok { x: u64, y: u64, } - private fun f(r: &mut update_field_ok::R) { - select update_field_ok::R.x<&mut update_field_ok::R>(r) = 1; + private fun f(r: &mut 0x42::update_field_ok::R) { + select update_field_ok::R.x<&mut R>(r) = 1; Tuple() } spec { aborts_if false; - ensures Eq(Freeze(false)($t0), update_field_ok::assign_x_1(Old($t0))); + ensures Eq<0x42::update_field_ok::R>(Freeze(false)($t0), update_field_ok::assign_x_1(Old<0x42::update_field_ok::R>($t0))); } - spec fun assign_x_1(r: update_field_ok::R): update_field_ok::R { - update update_field_ok::R.x(r, 1) + spec fun assign_x_1(r: 0x42::update_field_ok::R): 0x42::update_field_ok::R { + update update_field_ok::R.x<0x42::update_field_ok::R>(r, 1) } } // end 0x42::update_field_ok + +// -- Sourcified model before bytecode pipeline +module 0x42::update_field_ok { + struct R { + x: u64, + y: u64, + } + fun f(r: &mut R) { + r.x = 1; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/annotated_types.exp b/third_party/move/move-compiler-v2/tests/checking/typing/annotated_types.exp index 7547136a5af2a..f9428b593f237 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/annotated_types.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/annotated_types.exp @@ -11,7 +11,22 @@ module 0x8675309::M { 0; pack M::S(false); M::R{ dummy_field: _ } = pack M::R(false); - (_: u64, _: M::S, M::R{ dummy_field: _ }): (u64, M::S, M::R) = Tuple(0, pack M::S(false), pack M::R(false)); + (_: u64, _: S, M::R{ dummy_field: _ }): (u64, S, R) = Tuple(0, pack M::S(false), pack M::R(false)); Tuple() } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R { + } + struct S has drop { + } + fun t() { + (); + 0; + S{}; + R{} = R{}; + (_,_,R{}) = (0, S{}, R{}); + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/assign_nested2.exp b/third_party/move/move-compiler-v2/tests/checking/typing/assign_nested2.exp index 909472ecef030..b7fe0f0db7198 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/assign_nested2.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/assign_nested2.exp @@ -28,7 +28,7 @@ module 0x8675309::A { { let r_ref: &mut u64 = Borrow(Mutable)(r); { - let s: A::S = pack A::S(0); + let s: S = pack A::S(0); (_: u64, x: u64, _: u64, _: u64): (u64, u64, u64, u64) = A::four(); Tuple() } @@ -37,3 +37,20 @@ module 0x8675309::A { } } } // end 0x8675309::A + +// -- Sourcified model before bytecode pipeline +module 0x8675309::A { + struct S has drop { + f: u64, + } + fun four(): (u64, u64, u64, u64) { + (0, 1, 2, 3) + } + public fun mixed() { + let x; + let r = 0; + let r_ref = &mut r; + let s = S{f: 0}; + (_,x,_,_) = four(); + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/assign_tuple_wg.exp b/third_party/move/move-compiler-v2/tests/checking/typing/assign_tuple_wg.exp index a250c827c1d81..574e85d52c464 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/assign_tuple_wg.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/assign_tuple_wg.exp @@ -18,10 +18,27 @@ module 0xc0ffee::dummy2 { struct State { value: u64, } - private fun tuple_assignments(s: &signer,state: dummy2::State) { + private fun tuple_assignments(s: &signer,state: 0xc0ffee::dummy2::State) { { - let (): () = MoveTo(s, state); + let (): () = MoveTo(s, state); Tuple() } } } // end 0xc0ffee::dummy2 + +// -- Sourcified model before bytecode pipeline +module 0xc0ffee::dummy1 { + fun bar(b: bool) { + let () = if (b) baz(); + } + fun baz() { + } +} +module 0xc0ffee::dummy2 { + struct State has key { + value: u64, + } + fun tuple_assignments(s: &signer, state: State) { + let () = move_to(s, state); + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/binary_add.exp b/third_party/move/move-compiler-v2/tests/checking/typing/binary_add.exp index 499d07865f69a..dbf962cd18cc3 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/binary_add.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/binary_add.exp @@ -3,7 +3,7 @@ module 0x8675309::M { struct R { f: u64, } - private fun t0(x: u64,r: M::R) { + private fun t0(x: u64,r: 0x8675309::M::R) { 0; 1; 1; @@ -13,11 +13,32 @@ module 0x8675309::M { 1; 1; Add(Copy(x), Move(x)); - Add(select M::R.f(r), select M::R.f(r)); - Add(Add(Add(1, select M::R.f(r)), select M::R.f(r)), 0); + Add(select M::R.f(r), select M::R.f(r)); + Add(Add(Add(1, select M::R.f(r)), select M::R.f(r)), 0); { let M::R{ f: _ } = r; Tuple() } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R { + f: u64, + } + fun t0(x: u64, r: R) { + 0; + 1; + 1; + 1u8; + 1u8; + 1u128; + 1u128; + 1; + (copy x) + (move x); + r.f + r.f; + 1 + r.f + r.f + 0; + let R{f: _} = r; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/binary_and.exp b/third_party/move/move-compiler-v2/tests/checking/typing/binary_and.exp index dcc109892aa00..dc36e8c925bf4 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/binary_and.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/binary_and.exp @@ -3,13 +3,13 @@ module 0x8675309::M { struct R { f: bool, } - private fun t0(x: bool,r: M::R) { + private fun t0(x: bool,r: 0x8675309::M::R) { false; false; false; true; And(Copy(x), Move(x)); - And(select M::R.f(r), select M::R.f(r)); + And(select M::R.f(r), select M::R.f(r)); false; { let M::R{ f: _ } = r; @@ -17,3 +17,20 @@ module 0x8675309::M { } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R { + f: bool, + } + fun t0(x: bool, r: R) { + false; + false; + false; + true; + (copy x) && (move x); + r.f && r.f; + false; + let R{f: _} = r; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/binary_bit_and.exp b/third_party/move/move-compiler-v2/tests/checking/typing/binary_bit_and.exp index 176d035a54ab7..51af76228c585 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/binary_bit_and.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/binary_bit_and.exp @@ -3,7 +3,7 @@ module 0x8675309::M { struct R { f: u64, } - private fun t0(x: u64,r: M::R) { + private fun t0(x: u64,r: 0x8675309::M::R) { 0; 0; 0; @@ -13,11 +13,32 @@ module 0x8675309::M { 0; 0; BitAnd(Copy(x), Move(x)); - BitAnd(select M::R.f(r), select M::R.f(r)); - BitAnd(BitAnd(BitAnd(1, select M::R.f(r)), select M::R.f(r)), 0); + BitAnd(select M::R.f(r), select M::R.f(r)); + BitAnd(BitAnd(BitAnd(1, select M::R.f(r)), select M::R.f(r)), 0); { let M::R{ f: _ } = r; Tuple() } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R { + f: u64, + } + fun t0(x: u64, r: R) { + 0; + 0; + 0; + 0u8; + 0u8; + 0u128; + 0u128; + 0; + (copy x) & (move x); + r.f & r.f; + 1 & r.f & r.f & 0; + let R{f: _} = r; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/binary_bit_or.exp b/third_party/move/move-compiler-v2/tests/checking/typing/binary_bit_or.exp index a0dd5a3086d89..e1a72e723b680 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/binary_bit_or.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/binary_bit_or.exp @@ -3,7 +3,7 @@ module 0x8675309::M { struct R { f: u64, } - private fun t0(x: u64,r: M::R) { + private fun t0(x: u64,r: 0x8675309::M::R) { 0; 1; 1; @@ -13,11 +13,32 @@ module 0x8675309::M { 1; 1; BitOr(Copy(x), Move(x)); - BitOr(select M::R.f(r), select M::R.f(r)); - BitOr(BitOr(BitOr(1, select M::R.f(r)), select M::R.f(r)), 0); + BitOr(select M::R.f(r), select M::R.f(r)); + BitOr(BitOr(BitOr(1, select M::R.f(r)), select M::R.f(r)), 0); { let M::R{ f: _ } = r; Tuple() } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R { + f: u64, + } + fun t0(x: u64, r: R) { + 0; + 1; + 1; + 1u8; + 1u8; + 1u128; + 1u128; + 1; + (copy x) | (move x); + r.f | r.f; + 1 | r.f | r.f | 0; + let R{f: _} = r; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/binary_div.exp b/third_party/move/move-compiler-v2/tests/checking/typing/binary_div.exp index 619ea3afb311a..dd1fa987c3b92 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/binary_div.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/binary_div.exp @@ -3,7 +3,7 @@ module 0x8675309::M { struct R { f: u64, } - private fun t0(x: u64,r: M::R) { + private fun t0(x: u64,r: 0x8675309::M::R) { Div(0, 0); Div(1, 0); 0; @@ -13,11 +13,32 @@ module 0x8675309::M { 0; 0; Div(Copy(x), Move(x)); - Div(select M::R.f(r), select M::R.f(r)); - Div(Div(Div(1, select M::R.f(r)), select M::R.f(r)), 0); + Div(select M::R.f(r), select M::R.f(r)); + Div(Div(Div(1, select M::R.f(r)), select M::R.f(r)), 0); { let M::R{ f: _ } = r; Tuple() } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R { + f: u64, + } + fun t0(x: u64, r: R) { + 0 / 0; + 1 / 0; + 0; + 0u8; + 0u8; + 0u128; + 0u128; + 0; + (copy x) / (move x); + r.f / r.f; + 1 / r.f / r.f / 0; + let R{f: _} = r; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/binary_geq.exp b/third_party/move/move-compiler-v2/tests/checking/typing/binary_geq.exp index 1cb8410cde8ec..c7e5cc27f39b7 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/binary_geq.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/binary_geq.exp @@ -3,7 +3,7 @@ module 0x8675309::M { struct R { f: u64, } - private fun t0(x: u64,r: M::R) { + private fun t0(x: u64,r: 0x8675309::M::R) { true; true; false; @@ -13,11 +13,32 @@ module 0x8675309::M { false; false; Ge(Copy(x), Move(x)); - Ge(select M::R.f(r), select M::R.f(r)); - And(Ge(1, select M::R.f(r)), Ge(select M::R.f(r), 0)); + Ge(select M::R.f(r), select M::R.f(r)); + And(Ge(1, select M::R.f(r)), Ge(select M::R.f(r), 0)); { let M::R{ f: _ } = r; Tuple() } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R { + f: u64, + } + fun t0(x: u64, r: R) { + true; + true; + false; + false; + false; + false; + false; + false; + (copy x) >= (move x); + r.f >= r.f; + 1 >= r.f && r.f >= 0; + let R{f: _} = r; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/binary_gt.exp b/third_party/move/move-compiler-v2/tests/checking/typing/binary_gt.exp index 550c2c2a85560..525e08a390065 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/binary_gt.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/binary_gt.exp @@ -3,7 +3,7 @@ module 0x8675309::M { struct R { f: u64, } - private fun t0(x: u64,r: M::R) { + private fun t0(x: u64,r: 0x8675309::M::R) { false; true; false; @@ -13,11 +13,32 @@ module 0x8675309::M { false; false; Gt(Copy(x), Move(x)); - Gt(select M::R.f(r), select M::R.f(r)); - And(Gt(1, select M::R.f(r)), Gt(select M::R.f(r), 0)); + Gt(select M::R.f(r), select M::R.f(r)); + And(Gt(1, select M::R.f(r)), Gt(select M::R.f(r), 0)); { let M::R{ f: _ } = r; Tuple() } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R { + f: u64, + } + fun t0(x: u64, r: R) { + false; + true; + false; + false; + false; + false; + false; + false; + (copy x) > (move x); + r.f > r.f; + 1 > r.f && r.f > 0; + let R{f: _} = r; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/binary_leq.exp b/third_party/move/move-compiler-v2/tests/checking/typing/binary_leq.exp index 72c2b34c7462a..46bcecd2e7496 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/binary_leq.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/binary_leq.exp @@ -3,7 +3,7 @@ module 0x8675309::M { struct R { f: u64, } - private fun t0(x: u64,r: M::R) { + private fun t0(x: u64,r: 0x8675309::M::R) { true; false; true; @@ -13,11 +13,32 @@ module 0x8675309::M { true; true; Le(Copy(x), Move(x)); - Le(select M::R.f(r), select M::R.f(r)); - And(Le(1, select M::R.f(r)), Le(select M::R.f(r), 0)); + Le(select M::R.f(r), select M::R.f(r)); + And(Le(1, select M::R.f(r)), Le(select M::R.f(r), 0)); { let M::R{ f: _ } = r; Tuple() } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R { + f: u64, + } + fun t0(x: u64, r: R) { + true; + false; + true; + true; + true; + true; + true; + true; + (copy x) <= (move x); + r.f <= r.f; + 1 <= r.f && r.f <= 0; + let R{f: _} = r; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/binary_lt.exp b/third_party/move/move-compiler-v2/tests/checking/typing/binary_lt.exp index 39c7c05043c27..6e41d78887518 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/binary_lt.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/binary_lt.exp @@ -3,7 +3,7 @@ module 0x8675309::M { struct R { f: u64, } - private fun t0(x: u64,r: M::R) { + private fun t0(x: u64,r: 0x8675309::M::R) { false; false; true; @@ -13,11 +13,32 @@ module 0x8675309::M { true; true; Lt(Copy(x), Move(x)); - Lt(select M::R.f(r), select M::R.f(r)); - And(Lt(1, select M::R.f(r)), Lt(select M::R.f(r), 0)); + Lt(select M::R.f(r), select M::R.f(r)); + And(Lt(1, select M::R.f(r)), Lt(select M::R.f(r), 0)); { let M::R{ f: _ } = r; Tuple() } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R { + f: u64, + } + fun t0(x: u64, r: R) { + false; + false; + true; + true; + true; + true; + true; + true; + (copy x) < (move x); + r.f < r.f; + 1 < r.f && r.f < 0; + let R{f: _} = r; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/binary_mod.exp b/third_party/move/move-compiler-v2/tests/checking/typing/binary_mod.exp index 354e15f5bb020..3e85e951d274e 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/binary_mod.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/binary_mod.exp @@ -3,7 +3,7 @@ module 0x8675309::M { struct R { f: u64, } - private fun t0(x: u64,r: M::R) { + private fun t0(x: u64,r: 0x8675309::M::R) { Mod(0, 0); Mod(1, 0); 0; @@ -13,11 +13,32 @@ module 0x8675309::M { 0; 0; Mod(Copy(x), Move(x)); - Mod(select M::R.f(r), select M::R.f(r)); - Mod(Mod(Mod(1, select M::R.f(r)), select M::R.f(r)), 0); + Mod(select M::R.f(r), select M::R.f(r)); + Mod(Mod(Mod(1, select M::R.f(r)), select M::R.f(r)), 0); { let M::R{ f: _ } = r; Tuple() } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R { + f: u64, + } + fun t0(x: u64, r: R) { + 0 % 0; + 1 % 0; + 0; + 0u8; + 0u8; + 0u128; + 0u128; + 0; + (copy x) % (move x); + r.f % r.f; + 1 % r.f % r.f % 0; + let R{f: _} = r; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/binary_mul.exp b/third_party/move/move-compiler-v2/tests/checking/typing/binary_mul.exp index 061c338dc982b..2481477f406fe 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/binary_mul.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/binary_mul.exp @@ -3,7 +3,7 @@ module 0x8675309::M { struct R { f: u64, } - private fun t0(x: u64,r: M::R) { + private fun t0(x: u64,r: 0x8675309::M::R) { 0; 0; 0; @@ -13,11 +13,32 @@ module 0x8675309::M { 0; 0; Mul(Copy(x), Move(x)); - Mul(select M::R.f(r), select M::R.f(r)); - Mul(Mul(Mul(1, select M::R.f(r)), select M::R.f(r)), 0); + Mul(select M::R.f(r), select M::R.f(r)); + Mul(Mul(Mul(1, select M::R.f(r)), select M::R.f(r)), 0); { let M::R{ f: _ } = r; Tuple() } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R { + f: u64, + } + fun t0(x: u64, r: R) { + 0; + 0; + 0; + 0u8; + 0u8; + 0u128; + 0u128; + 0; + (copy x) * (move x); + r.f * r.f; + 1 * r.f * r.f * 0; + let R{f: _} = r; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/binary_or.exp b/third_party/move/move-compiler-v2/tests/checking/typing/binary_or.exp index ba12114e3fabb..f46f636d7c160 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/binary_or.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/binary_or.exp @@ -3,13 +3,13 @@ module 0x8675309::M { struct R { f: bool, } - private fun t0(x: bool,r: M::R) { + private fun t0(x: bool,r: 0x8675309::M::R) { true; true; true; true; Or(Copy(x), Move(x)); - Or(select M::R.f(r), select M::R.f(r)); + Or(select M::R.f(r), select M::R.f(r)); true; { let M::R{ f: _ } = r; @@ -17,3 +17,20 @@ module 0x8675309::M { } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R { + f: bool, + } + fun t0(x: bool, r: R) { + true; + true; + true; + true; + (copy x) || (move x); + r.f || r.f; + true; + let R{f: _} = r; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/binary_shl.exp b/third_party/move/move-compiler-v2/tests/checking/typing/binary_shl.exp index d5774d480eedc..5f0d862687573 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/binary_shl.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/binary_shl.exp @@ -4,7 +4,7 @@ module 0x8675309::M { f: u64, b: u8, } - private fun t0(x: u64,b: u8,r: M::R) { + private fun t0(x: u64,b: u8,r: 0x8675309::M::R) { 0; 1; 0; @@ -13,8 +13,29 @@ module 0x8675309::M { 0; 0; Shl(Copy(x), Copy(b)); - Shl(select M::R.f(r), select M::R.b(r)); - Shl(Shl(Shl(1, select M::R.b(r)), select M::R.b(r)), 0); + Shl(select M::R.f(r), select M::R.b(r)); + Shl(Shl(Shl(1, select M::R.b(r)), select M::R.b(r)), 0); M::R{ f: _, b: _ } = r } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R { + f: u64, + b: u8, + } + fun t0(x: u64, b: u8, r: R) { + 0; + 1; + 0; + 0; + 1u8; + 0u128; + 0; + (copy x) << (copy b); + r.f << r.b; + 1 << r.b << r.b << 0u8; + R{f: _,b: _} = r + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/binary_shr.exp b/third_party/move/move-compiler-v2/tests/checking/typing/binary_shr.exp index 9f84205f4b470..c55184dca4e32 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/binary_shr.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/binary_shr.exp @@ -4,7 +4,7 @@ module 0x8675309::M { f: u64, b: u8, } - private fun t0(x: u64,b: u8,r: M::R) { + private fun t0(x: u64,b: u8,r: 0x8675309::M::R) { 0; 1; 0; @@ -13,8 +13,29 @@ module 0x8675309::M { 0; 0; Shr(Copy(x), Copy(b)); - Shr(select M::R.f(r), select M::R.b(r)); - Shr(Shr(Shr(1, select M::R.b(r)), select M::R.b(r)), 0); + Shr(select M::R.f(r), select M::R.b(r)); + Shr(Shr(Shr(1, select M::R.b(r)), select M::R.b(r)), 0); M::R{ f: _, b: _ } = r } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R { + f: u64, + b: u8, + } + fun t0(x: u64, b: u8, r: R) { + 0; + 1; + 0; + 0; + 1u8; + 0u128; + 0; + (copy x) >> (copy b); + r.f >> r.b; + 1 >> r.b >> r.b >> 0u8; + R{f: _,b: _} = r + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/binary_sub.exp b/third_party/move/move-compiler-v2/tests/checking/typing/binary_sub.exp index 7165eb499e522..902548d10ec08 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/binary_sub.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/binary_sub.exp @@ -3,7 +3,7 @@ module 0x8675309::M { struct R { f: u64, } - private fun t0(x: u64,r: M::R) { + private fun t0(x: u64,r: 0x8675309::M::R) { 0; 1; Sub(0, 1); @@ -13,11 +13,32 @@ module 0x8675309::M { Sub(0, 1); Sub(0, 1); Sub(Copy(x), Move(x)); - Sub(select M::R.f(r), select M::R.f(r)); - Sub(Sub(Sub(1, select M::R.f(r)), select M::R.f(r)), 0); + Sub(select M::R.f(r), select M::R.f(r)); + Sub(Sub(Sub(1, select M::R.f(r)), select M::R.f(r)), 0); { let M::R{ f: _ } = r; Tuple() } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R { + f: u64, + } + fun t0(x: u64, r: R) { + 0; + 1; + 0 - 1; + 0u8 - 1u8; + 0u8 - 1u8; + 0u128 - 1u128; + 0u128 - 1u128; + 0 - 1; + (copy x) - (move x); + r.f - r.f; + 1 - r.f - r.f - 0; + let R{f: _} = r; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/binary_xor.exp b/third_party/move/move-compiler-v2/tests/checking/typing/binary_xor.exp index e0ca221882df9..b5faec5a1be9c 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/binary_xor.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/binary_xor.exp @@ -3,7 +3,7 @@ module 0x8675309::M { struct R { f: u64, } - private fun t0(x: u64,r: M::R) { + private fun t0(x: u64,r: 0x8675309::M::R) { 0; 1; 1; @@ -13,11 +13,32 @@ module 0x8675309::M { 1; 1; Xor(Copy(x), Move(x)); - Xor(select M::R.f(r), select M::R.f(r)); - Xor(Xor(Xor(1, select M::R.f(r)), select M::R.f(r)), 0); + Xor(select M::R.f(r), select M::R.f(r)); + Xor(Xor(Xor(1, select M::R.f(r)), select M::R.f(r)), 0); { let M::R{ f: _ } = r; Tuple() } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R { + f: u64, + } + fun t0(x: u64, r: R) { + 0; + 1; + 1; + 1u8; + 1u8; + 1u128; + 1u128; + 1; + (copy x) ^ (move x); + r.f ^ r.f; + 1 ^ r.f ^ r.f ^ 0; + let R{f: _} = r; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/bind_with_type_annot.exp b/third_party/move/move-compiler-v2/tests/checking/typing/bind_with_type_annot.exp index 76be5734e6def..622c066db0cde 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/bind_with_type_annot.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/bind_with_type_annot.exp @@ -6,7 +6,7 @@ module 0x8675309::M { private fun t0() { 0; { - let (x: u64, b: bool, M::R{ f }): (u64, bool, M::R) = Tuple(0, false, pack M::R(0)); + let (x: u64, b: bool, M::R{ f }): (u64, bool, R) = Tuple(0, false, pack M::R(0)); 0; false; 0; @@ -14,3 +14,17 @@ module 0x8675309::M { } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R { + f: u64, + } + fun t0() { + 0; + let (x,b,R{f: f}) = (0, false, R{f: 0}); + 0; + false; + 0; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/block_empty.exp b/third_party/move/move-compiler-v2/tests/checking/typing/block_empty.exp index 010d6c24957fd..6d5fb67404227 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/block_empty.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/block_empty.exp @@ -7,3 +7,12 @@ module 0x8675309::M { Tuple() } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + fun t0() { + (); + (); + (); + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/block_single_expr.exp b/third_party/move/move-compiler-v2/tests/checking/typing/block_single_expr.exp index d443f1578d571..998992acaf010 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/block_single_expr.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/block_single_expr.exp @@ -12,3 +12,16 @@ module 0x8675309::M { Tuple() } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R { + } + fun t0() { + 0; + &0; + &mut 0; + R{} = R{}; + (0, false); + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/block_with_statements.exp b/third_party/move/move-compiler-v2/tests/checking/typing/block_with_statements.exp index ab55de9be63c6..01a807ee43c9e 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/block_with_statements.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/block_with_statements.exp @@ -8,8 +8,8 @@ module 0x8675309::M { Borrow(Immutable)(0); Borrow(Mutable)(1); M::R{ dummy_field: _ } = { - let r: M::R = { - let r: M::R = pack M::R(false); + let r: R = { + let r: R = pack M::R(false); r }; r @@ -18,3 +18,22 @@ module 0x8675309::M { Tuple() } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R { + } + fun t0() { + 0; + &0; + &mut 1; + R{} = { + let r = { + let r = R{}; + r + }; + r + }; + (0, false); + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/borrow_field.exp b/third_party/move/move-compiler-v2/tests/checking/typing/borrow_field.exp index aa470df8dbe0c..fb3de2221bc38 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/borrow_field.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/borrow_field.exp @@ -3,7 +3,17 @@ module 0x8675309::M { struct S { f: u64, } - private fun t0(s: &M::S,s_mut: &mut M::S,s_mut2: &mut M::S): (&u64, &u64, &mut u64) { - Tuple(Borrow(Immutable)(select M::S.f<&M::S>(s)), Borrow(Immutable)(select M::S.f<&mut M::S>(s_mut)), Borrow(Mutable)(select M::S.f<&mut M::S>(s_mut2))) + private fun t0(s: &0x8675309::M::S,s_mut: &mut 0x8675309::M::S,s_mut2: &mut 0x8675309::M::S): (&u64, &u64, &mut u64) { + Tuple(Borrow(Immutable)(select M::S.f<&S>(s)), Borrow(Immutable)(select M::S.f<&mut S>(s_mut)), Borrow(Mutable)(select M::S.f<&mut S>(s_mut2))) } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct S { + f: u64, + } + fun t0(s: &S, s_mut: &mut S, s_mut2: &mut S): (&u64, &u64, &mut u64) { + (&s.f, &s_mut.f, &mut s_mut2.f) + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/borrow_field_chain.exp b/third_party/move/move-compiler-v2/tests/checking/typing/borrow_field_chain.exp index 94a934431a457..7a6a1d92c128d 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/borrow_field_chain.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/borrow_field_chain.exp @@ -1,24 +1,48 @@ // -- Model dump before bytecode pipeline module 0x8675309::M { struct X1 { - x2: M::X2, + x2: 0x8675309::M::X2, } struct X2 { - x3: M::X3, + x3: 0x8675309::M::X3, } struct X3 { f: u64, } - private fun t0(x1: &M::X1,x1_mut: &mut M::X1) { - Borrow(Immutable)(select M::X1.x2<&M::X1>(x1)); - Borrow(Immutable)(select M::X2.x3(select M::X1.x2<&M::X1>(x1))); - Borrow(Immutable)(select M::X3.f(select M::X2.x3(select M::X1.x2<&M::X1>(x1)))); - Borrow(Immutable)(select M::X1.x2<&mut M::X1>(x1_mut)); - Borrow(Immutable)(select M::X2.x3(select M::X1.x2<&mut M::X1>(x1_mut))); - Borrow(Immutable)(select M::X3.f(select M::X2.x3(select M::X1.x2<&mut M::X1>(x1_mut)))); - Borrow(Mutable)(select M::X1.x2<&mut M::X1>(x1_mut)); - Borrow(Mutable)(select M::X2.x3(select M::X1.x2<&mut M::X1>(x1_mut))); - Borrow(Mutable)(select M::X3.f(select M::X2.x3(select M::X1.x2<&mut M::X1>(x1_mut)))); + private fun t0(x1: &0x8675309::M::X1,x1_mut: &mut 0x8675309::M::X1) { + Borrow(Immutable)(select M::X1.x2<&X1>(x1)); + Borrow(Immutable)(select M::X2.x3(select M::X1.x2<&X1>(x1))); + Borrow(Immutable)(select M::X3.f(select M::X2.x3(select M::X1.x2<&X1>(x1)))); + Borrow(Immutable)(select M::X1.x2<&mut X1>(x1_mut)); + Borrow(Immutable)(select M::X2.x3(select M::X1.x2<&mut X1>(x1_mut))); + Borrow(Immutable)(select M::X3.f(select M::X2.x3(select M::X1.x2<&mut X1>(x1_mut)))); + Borrow(Mutable)(select M::X1.x2<&mut X1>(x1_mut)); + Borrow(Mutable)(select M::X2.x3(select M::X1.x2<&mut X1>(x1_mut))); + Borrow(Mutable)(select M::X3.f(select M::X2.x3(select M::X1.x2<&mut X1>(x1_mut)))); Tuple() } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct X1 { + x2: X2, + } + struct X2 { + x3: X3, + } + struct X3 { + f: u64, + } + fun t0(x1: &X1, x1_mut: &mut X1) { + &x1.x2; + &x1.x2.x3; + &x1.x2.x3.f; + &x1_mut.x2; + &x1_mut.x2.x3; + &x1_mut.x2.x3.f; + &mut x1_mut.x2; + &mut x1_mut.x2.x3; + &mut x1_mut.x2.x3.f; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/borrow_field_complex_root_expr.exp b/third_party/move/move-compiler-v2/tests/checking/typing/borrow_field_complex_root_expr.exp index 2fc210c2e303e..2e51aff34975f 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/borrow_field_complex_root_expr.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/borrow_field_complex_root_expr.exp @@ -3,36 +3,54 @@ module 0x8675309::M { struct S { f: u64, } - private fun t0(cond: bool,s: &M::S,s_mut: &mut M::S) { - Borrow(Immutable)(select M::S.f<&M::S>(if cond { + private fun t0(cond: bool,s: &0x8675309::M::S,s_mut: &mut 0x8675309::M::S) { + Borrow(Immutable)(select M::S.f<&S>(if cond { s } else { s })); - Borrow(Immutable)(select M::S.f<&M::S>(if cond { + Borrow(Immutable)(select M::S.f<&S>(if cond { Freeze(false)(s_mut) } else { s })); - Borrow(Immutable)(select M::S.f<&M::S>(if cond { + Borrow(Immutable)(select M::S.f<&S>(if cond { s } else { Freeze(false)(s_mut) })); - Borrow(Immutable)(select M::S.f<&mut M::S>(if cond { + Borrow(Immutable)(select M::S.f<&mut S>(if cond { s_mut } else { s_mut })); - Borrow(Mutable)(select M::S.f<&mut M::S>(if cond { + Borrow(Mutable)(select M::S.f<&mut S>(if cond { s_mut } else { s_mut })); - Borrow(Immutable)(select M::S.f<&M::S>({ - let s: M::S = pack M::S(0); + Borrow(Immutable)(select M::S.f<&S>({ + let s: S = pack M::S(0); Borrow(Immutable)(s) })); Tuple() } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct S has drop { + f: u64, + } + fun t0(cond: bool, s: &S, s_mut: &mut S) { + &(if (cond) s else s).f; + &(if (cond) /*freeze*/s_mut else s).f; + &(if (cond) s else /*freeze*/s_mut).f; + &(if (cond) s_mut else s_mut).f; + &mut (if (cond) s_mut else s_mut).f; + &{ + let s = S{f: 0}; + &s + }.f; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/borrow_field_non_ref_root.exp b/third_party/move/move-compiler-v2/tests/checking/typing/borrow_field_non_ref_root.exp index 0a38afe6bcae3..87875ab352442 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/borrow_field_non_ref_root.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/borrow_field_non_ref_root.exp @@ -3,15 +3,15 @@ module 0x8675309::M { struct S { f: u64, } - private fun t0(cond: bool,s: M::S) { - Borrow(Immutable)(select M::S.f(s)); - Borrow(Mutable)(select M::S.f(s)); - Borrow(Immutable)(select M::S.f(if cond { + private fun t0(cond: bool,s: 0x8675309::M::S) { + Borrow(Immutable)(select M::S.f(s)); + Borrow(Mutable)(select M::S.f(s)); + Borrow(Immutable)(select M::S.f(if cond { pack M::S(0) } else { pack M::S(1) })); - Borrow(Mutable)(select M::S.f(if cond { + Borrow(Mutable)(select M::S.f(if cond { pack M::S(0) } else { pack M::S(1) @@ -19,3 +19,16 @@ module 0x8675309::M { Tuple() } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct S has drop { + f: u64, + } + fun t0(cond: bool, s: S) { + &s.f; + &mut s.f; + &(if (cond) S{f: 0} else S{f: 1}).f; + &mut (if (cond) S{f: 0} else S{f: 1}).f; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/borrow_local.exp b/third_party/move/move-compiler-v2/tests/checking/typing/borrow_local.exp index 8ad47b62f6fa0..6469134b48c13 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/borrow_local.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/borrow_local.exp @@ -6,7 +6,7 @@ module 0x8675309::M { struct S { dummy_field: bool, } - private fun t0(b: bool,u: u64,s: M::S,r: M::R): M::R { + private fun t0(b: bool,u: u64,s: 0x8675309::M::S,r: 0x8675309::M::R): 0x8675309::M::R { Borrow(Immutable)(b); Borrow(Mutable)(b); Borrow(Immutable)(u); @@ -17,15 +17,15 @@ module 0x8675309::M { Borrow(Mutable)(r); r } - private fun t1(): M::R { + private fun t1(): 0x8675309::M::R { { let b: bool = true; { let u: u64 = 0; { - let s: M::S = pack M::S(false); + let s: S = pack M::S(false); { - let r: M::R = pack M::R(false); + let r: R = pack M::R(false); Borrow(Immutable)(b); Borrow(Mutable)(b); Borrow(Immutable)(u); @@ -41,3 +41,37 @@ module 0x8675309::M { } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R { + } + struct S has drop { + } + fun t0(b: bool, u: u64, s: S, r: R): R { + &b; + &mut b; + &u; + &mut u; + &s; + &mut s; + &r; + &mut r; + r + } + fun t1(): R { + let b = true; + let u = 0; + let s = S{}; + let r = R{}; + &b; + &mut b; + &u; + &mut u; + &s; + &mut s; + &r; + &mut r; + r + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/borrow_local_temp.exp b/third_party/move/move-compiler-v2/tests/checking/typing/borrow_local_temp.exp index 7a4a44001c2a9..695b878ef0ff7 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/borrow_local_temp.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/borrow_local_temp.exp @@ -16,3 +16,19 @@ module 0x8675309::M { Tuple() } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R { + } + struct S has drop { + } + fun t0() { + &true; + &mut false; + &0; + &mut 1; + &S{}; + &mut S{}; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/break_any_type.exp b/third_party/move/move-compiler-v2/tests/checking/typing/break_any_type.exp index cd7b6720f3e26..2b911015619f5 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/break_any_type.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/break_any_type.exp @@ -3,7 +3,7 @@ module 0x8675309::M { struct Coin { dummy_field: bool, } - private fun foo(c: M::Coin) { + private fun foo(c: 0x8675309::M::Coin) { M::Coin{ dummy_field: _ } = c; Tuple() } @@ -27,3 +27,20 @@ module 0x8675309::M { } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct Coin { + } + fun foo(c: Coin) { + Coin{} = c; + } + fun t0() { + while (true) { + 0 + (break); + } + } + fun t1() { + while (true) foo(break) + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/break_outside_loop.exp b/third_party/move/move-compiler-v2/tests/checking/typing/break_outside_loop.exp index a670f268e2b0c..f403ecd7de819 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/break_outside_loop.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/break_outside_loop.exp @@ -24,6 +24,21 @@ module 0x8675309::M { } } // end 0x8675309::M +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + fun bar() { + break; + } + fun baz(x: u64): u64 { + if (x >= 5) break; + 0 + } + fun foo() { + while (true) break; + break + } +} + Diagnostics: error: missing enclosing loop statement diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/cast.exp b/third_party/move/move-compiler-v2/tests/checking/typing/cast.exp index bf716645ad244..59ec0b8dcbb7a 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/cast.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/cast.exp @@ -37,3 +37,20 @@ module 0x8675309::M { } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + fun t0(x8: u8, x64: u64, x128: u128) { + let _ = x8; + let _ = x64; + let _ = x128; + let _ = x64 as u8; + let _ = x128 as u64; + let _ = x8 as u128; + let _ = x128 as u8; + let _ = x8 as u64; + let _ = x64 as u128; + let _ = 340282366920938463463374607431768211455u128 as u8; + let _ = 340282366920938463463374607431768211455u128 as u64; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/constant_all_valid_types.exp b/third_party/move/move-compiler-v2/tests/checking/typing/constant_all_valid_types.exp index f66ba14550703..39492187167e2 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/constant_all_valid_types.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/constant_all_valid_types.exp @@ -41,3 +41,46 @@ module _0 { Tuple() } } // end _0 + +// -- Sourcified model before bytecode pipeline +module 0x42::M { + fun t1(): u8 { + 0u8 + } + fun t2(): u64 { + 0 + } + fun t3(): u128 { + 0u128 + } + fun t4(): bool { + false + } + fun t5(): address { + 0x0 + } + fun t6(): vector { + vector[1u8, 35u8] + } + fun t7(): vector { + vector[97u8, 98u8, 99u8, 100u8] + } + fun t8(): vector
{ + vector[0x0, 0x1] + } + fun t9(): u8 { + 0u8 + } +} +script { + fun t() { + 0u8; + 0; + 0u128; + false; + 0x0; + vector[1u8, 35u8]; + vector[97u8, 98u8, 99u8, 100u8]; + vector[0x0, 0x1]; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/constant_folding.exp b/third_party/move/move-compiler-v2/tests/checking/typing/constant_folding.exp index 097ca8ea8e451..0df0d44c38389 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/constant_folding.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/constant_folding.exp @@ -1,3 +1,7 @@ // -- Model dump before bytecode pipeline module 0x42::constant_folding { } // end 0x42::constant_folding + +// -- Sourcified model before bytecode pipeline +module 0x42::constant_folding { +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/constant_supported_exps.exp b/third_party/move/move-compiler-v2/tests/checking/typing/constant_supported_exps.exp index c5c471f77575f..5fa35de19b8d6 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/constant_supported_exps.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/constant_supported_exps.exp @@ -1,3 +1,7 @@ // -- Model dump before bytecode pipeline module 0x42::M { } // end 0x42::M + +// -- Sourcified model before bytecode pipeline +module 0x42::M { +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/continue_any_type.exp b/third_party/move/move-compiler-v2/tests/checking/typing/continue_any_type.exp index d24bcf657bd5c..43502815f4f30 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/continue_any_type.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/continue_any_type.exp @@ -3,7 +3,7 @@ module 0x8675309::M { struct Coin { dummy_field: bool, } - private fun foo(c: M::Coin) { + private fun foo(c: 0x8675309::M::Coin) { M::Coin{ dummy_field: _ } = c; Tuple() } @@ -27,3 +27,20 @@ module 0x8675309::M { } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct Coin { + } + fun foo(c: Coin) { + Coin{} = c; + } + fun t0() { + while (true) { + 0 + (continue); + } + } + fun t1() { + while (true) foo(continue) + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/continue_outside_loop.exp b/third_party/move/move-compiler-v2/tests/checking/typing/continue_outside_loop.exp index e77ad864b8a12..674634a3cf6e1 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/continue_outside_loop.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/continue_outside_loop.exp @@ -12,6 +12,14 @@ module 0x8675309::M { } } // end 0x8675309::M +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + fun foo() { + while (true) continue; + continue + } +} + Diagnostics: error: missing enclosing loop statement diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/decl_unpack_references.exp b/third_party/move/move-compiler-v2/tests/checking/typing/decl_unpack_references.exp index 9a0164bc1800c..d6881be7a2b73 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/decl_unpack_references.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/decl_unpack_references.exp @@ -1,8 +1,8 @@ // -- Model dump before bytecode pipeline module 0x8675309::M { struct R { - s1: M::S, - s2: M::S, + s1: 0x8675309::M::S, + s2: 0x8675309::M::S, } struct S { f: u64, @@ -12,7 +12,7 @@ module 0x8675309::M { let M::R{ s1: M::S{ f }, s2 }; f: u64 = 0; f; - s2: M::S = pack M::S(0); + s2: S = pack M::S(0); s2; Tuple() } @@ -22,7 +22,7 @@ module 0x8675309::M { let M::R{ s1: M::S{ f }, s2 }; f: &u64 = Borrow(Immutable)(0); f; - s2: &M::S = Borrow(Immutable)(pack M::S(0)); + s2: &S = Borrow(Immutable)(pack M::S(0)); s2; Tuple() } @@ -32,9 +32,41 @@ module 0x8675309::M { let M::R{ s1: M::S{ f }, s2 }; f: &mut u64 = Borrow(Mutable)(0); f; - s2: &mut M::S = Borrow(Mutable)(pack M::S(0)); + s2: &mut S = Borrow(Mutable)(pack M::S(0)); s2; Tuple() } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R { + s1: S, + s2: S, + } + struct S has drop { + f: u64, + } + fun t0() { + let R{s1: S{f: f},s2: s2}; + f = 0; + f; + s2 = S{f: 0}; + s2; + } + fun t1() { + let R{s1: S{f: f},s2: s2}; + f = &0; + f; + s2 = &S{f: 0}; + s2; + } + fun t2() { + let R{s1: S{f: f},s2: s2}; + f = &mut 0; + f; + s2 = &mut S{f: 0}; + s2; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/declare_with_type_annot.exp b/third_party/move/move-compiler-v2/tests/checking/typing/declare_with_type_annot.exp index 1963ff3280348..c92de114750b8 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/declare_with_type_annot.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/declare_with_type_annot.exp @@ -31,8 +31,18 @@ module 0x8675309::M { } private fun t0() { { - let (x: u64, b: bool, M::R{ f }): (u64, bool, M::R); + let (x: u64, b: bool, M::R{ f }): (u64, bool, R); Tuple() } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R { + f: u64, + } + fun t0() { + let (x,b,R{f: f}); + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/derefrence.exp b/third_party/move/move-compiler-v2/tests/checking/typing/derefrence.exp index bf84fdebe47b4..a98c47c892c1c 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/derefrence.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/derefrence.exp @@ -2,24 +2,48 @@ module 0x8675309::M { struct S { f: u64, - x: M::X, + x: 0x8675309::M::X, } struct X { dummy_field: bool, } - private fun t0(x: &u64,x_mut: &mut u64,s: &M::S,s_mut: &mut M::S) { + private fun t0(x: &u64,x_mut: &mut u64,s: &0x8675309::M::S,s_mut: &mut 0x8675309::M::S) { Deref(x); Deref(x_mut); Deref(s); - Deref(Borrow(Immutable)(select M::S.f<&M::S>(s))); - select M::S.f<&M::S>(s); - Deref(Borrow(Immutable)(select M::S.x<&M::S>(s))); + Deref(Borrow(Immutable)(select M::S.f<&S>(s))); + select M::S.f<&S>(s); + Deref(Borrow(Immutable)(select M::S.x<&S>(s))); Deref(s_mut); - Deref(Borrow(Immutable)(select M::S.f<&mut M::S>(s_mut))); - Deref(Borrow(Mutable)(select M::S.f<&mut M::S>(s_mut))); - select M::S.f<&mut M::S>(s_mut); - Deref(Borrow(Immutable)(select M::S.x<&mut M::S>(s_mut))); - Deref(Borrow(Mutable)(select M::S.x<&mut M::S>(s_mut))); + Deref(Borrow(Immutable)(select M::S.f<&mut S>(s_mut))); + Deref(Borrow(Mutable)(select M::S.f<&mut S>(s_mut))); + select M::S.f<&mut S>(s_mut); + Deref(Borrow(Immutable)(select M::S.x<&mut S>(s_mut))); + Deref(Borrow(Mutable)(select M::S.x<&mut S>(s_mut))); Tuple() } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct S has copy, drop { + f: u64, + x: X, + } + struct X has copy, drop { + } + fun t0(x: &u64, x_mut: &mut u64, s: &S, s_mut: &mut S) { + *x; + *x_mut; + *s; + *&s.f; + s.f; + *&s.x; + *s_mut; + *&s_mut.f; + *&mut s_mut.f; + s_mut.f; + *&s_mut.x; + *&mut s_mut.x; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/dummy_field.exp b/third_party/move/move-compiler-v2/tests/checking/typing/dummy_field.exp index 31d482ecaceb0..56d305e825796 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/dummy_field.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/dummy_field.exp @@ -7,32 +7,58 @@ module 0x42::test { dummy_field: bool, } public entry fun test(addr: address) - acquires test::R(*) + acquires 0x42::test::R(*) { { - let test::R{ dummy_field: _dummy_field } = MoveFrom(addr); + let test::R{ dummy_field: _dummy_field } = MoveFrom(addr); Tuple() } } private fun test2(): bool { { - let r: test::R = pack test::R(true); - select test::R.dummy_field(r) + let r: R = pack test::R(true); + select test::R.dummy_field(r) } } public entry fun test3(addr: address) - acquires test::T(*) + acquires 0x42::test::T(*) { { - let test::T{ dummy_field: _ } = MoveFrom(addr); + let test::T{ dummy_field: _ } = MoveFrom(addr); Tuple() } } public entry fun test4(s: &signer) { { - let r: test::T = pack test::T(false); - MoveTo(s, r); + let r: T = pack test::T(false); + MoveTo(s, r); Tuple() } } } // end 0x42::test + +// -- Sourcified model before bytecode pipeline +module 0x42::test { + struct T has drop, store, key { + } + struct R has drop, store, key { + } + public entry fun test(addr: address) + acquires R + { + let R{} = move_from(addr); + } + fun test2(): bool { + let r = R{}; + r.dummy_field + } + public entry fun test3(addr: address) + acquires T + { + let T{} = move_from(addr); + } + public entry fun test4(s: &signer) { + let r = T{}; + move_to(s, r); + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/entry_on_any_vis.exp b/third_party/move/move-compiler-v2/tests/checking/typing/entry_on_any_vis.exp index cd2aba36667c8..57b08d2aad09a 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/entry_on_any_vis.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/entry_on_any_vis.exp @@ -10,3 +10,13 @@ module 0x2::M { Tuple() } } // end 0x2::M + +// -- Sourcified model before bytecode pipeline +module 0x2::M { + entry fun f1() { + } + public entry fun f2() { + } + friend entry fun f3() { + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/entry_signature_no_warning.exp b/third_party/move/move-compiler-v2/tests/checking/typing/entry_signature_no_warning.exp index 241ce607db4dd..d51e71724aaac 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/entry_signature_no_warning.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/entry_signature_no_warning.exp @@ -9,13 +9,31 @@ module 0x42::M { public entry fun signer_ref(_: &signer) { Tuple() } - public entry fun struct_arg(_: M::CoolStruct) { + public entry fun struct_arg(_: 0x42::M::CoolStruct) { Tuple() } - public entry fun struct_ret(): M::CoolStruct { + public entry fun struct_ret(): 0x42::M::CoolStruct { pack M::CoolStruct(false) } public entry fun u64_ret(): u64 { 0 } } // end 0x42::M + +// -- Sourcified model before bytecode pipeline +module 0x42::M { + struct CoolStruct has drop { + } + public entry fun late_signer(_u: u64, _s: signer) { + } + public entry fun signer_ref(_: &signer) { + } + public entry fun struct_arg(_: CoolStruct) { + } + public entry fun struct_ret(): CoolStruct { + CoolStruct{} + } + public entry fun u64_ret(): u64 { + 0 + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/eq.exp b/third_party/move/move-compiler-v2/tests/checking/typing/eq.exp index e36049a6df034..14f1dbac9fd8a 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/eq.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/eq.exp @@ -9,7 +9,7 @@ module 0x8675309::M { struct S { u: u64, } - private fun t0(r: &M::R,r_mut: &mut M::R,s: M::S,s_ref: &M::S,s_mut: &mut M::S) { + private fun t0(r: &0x8675309::M::R,r_mut: &mut 0x8675309::M::R,s: 0x8675309::M::S,s_ref: &0x8675309::M::S,s_mut: &mut 0x8675309::M::S) { false; false; false; @@ -18,19 +18,55 @@ module 0x8675309::M { Eq(Borrow(Immutable)(0), Borrow(Immutable)(1)); false; false; - Eq(Borrow(Immutable)(s), s_ref); - Eq(Freeze(false)(Borrow(Mutable)(s)), s_ref); - Eq(Freeze(false)(Borrow(Mutable)(s)), Freeze(false)(s_mut)); - Eq(Borrow(Immutable)(s), Freeze(false)(s_mut)); - Eq(s_ref, Freeze(false)(s_mut)); - Eq(Freeze(false)(s_mut), Freeze(false)(s_mut)); - Eq(pack M::S(0), s); - Eq(r, r); - Eq(Freeze(false)(r_mut), Freeze(false)(r_mut)); - Eq(r, Freeze(false)(r_mut)); - Eq(Freeze(false)(r_mut), r); - Eq>(pack M::G(1), pack M::G(1)); - Eq>(pack M::G(1), pack M::G(1)); + Eq(Borrow(Immutable)(s), s_ref); + Eq(Freeze(false)(Borrow(Mutable)(s)), s_ref); + Eq(Freeze(false)(Borrow(Mutable)(s)), Freeze(false)(s_mut)); + Eq(Borrow(Immutable)(s), Freeze(false)(s_mut)); + Eq(s_ref, Freeze(false)(s_mut)); + Eq(Freeze(false)(s_mut), Freeze(false)(s_mut)); + Eq(pack M::S(0), s); + Eq(r, r); + Eq(Freeze(false)(r_mut), Freeze(false)(r_mut)); + Eq(r, Freeze(false)(r_mut)); + Eq(Freeze(false)(r_mut), r); + Eq>(pack M::G(1), pack M::G(1)); + Eq>(pack M::G(1), pack M::G(1)); Tuple() } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct G has drop { + f: T, + } + struct R { + f: u64, + } + struct S has drop { + u: u64, + } + fun t0(r: &R, r_mut: &mut R, s: S, s_ref: &S, s_mut: &mut S) { + false; + false; + false; + false; + false; + &0 == &1; + false; + false; + &s == s_ref; + /*freeze*/&mut s == s_ref; + /*freeze*/&mut s == /*freeze*/s_mut; + &s == /*freeze*/s_mut; + s_ref == /*freeze*/s_mut; + /*freeze*/s_mut == /*freeze*/s_mut; + S{u: 0} == s; + r == r; + /*freeze*/r_mut == /*freeze*/r_mut; + r == /*freeze*/r_mut; + /*freeze*/r_mut == r; + G{f: 1} == G{f: 1}; + G{f: 1} == G{f: 1}; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/eq_inline.exp b/third_party/move/move-compiler-v2/tests/checking/typing/eq_inline.exp index 66175e1b1b2f8..4135375126682 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/eq_inline.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/eq_inline.exp @@ -16,3 +16,12 @@ module 0x42::m { Tuple() } } // end 0x42::m + +// -- Sourcified model before bytecode pipeline +module 0x42::m { + inline fun foo(f: |&u64|) { + } + fun g() { + (); + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/eq_inline_typed.exp b/third_party/move/move-compiler-v2/tests/checking/typing/eq_inline_typed.exp index c7449303ddf2c..d4ac8aa2042a4 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/eq_inline_typed.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/eq_inline_typed.exp @@ -16,3 +16,12 @@ module 0x42::m { Tuple() } } // end 0x42::m + +// -- Sourcified model before bytecode pipeline +module 0x42::m { + inline fun foo(f: |&u64|) { + } + fun g() { + (); + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/eq_ref.exp b/third_party/move/move-compiler-v2/tests/checking/typing/eq_ref.exp index cd2f23dae1abf..c7ed238eae972 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/eq_ref.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/eq_ref.exp @@ -13,3 +13,16 @@ module 0x42::m { Tuple() } } // end 0x42::m + +// -- Sourcified model before bytecode pipeline +module 0x42::m { + fun mut_ref_to_mut_ref(x: u64, y: u64) { + /*freeze*/&mut x == /*freeze*/&mut y; + } + fun mut_ref_to_ref(x: u64, y: u64) { + /*freeze*/&mut x == &y; + } + fun ref_to_ref(x: u64, y: u64) { + &x == &y; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/exp_list.exp b/third_party/move/move-compiler-v2/tests/checking/typing/exp_list.exp index 2545066f07559..4ecc70487d887 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/exp_list.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/exp_list.exp @@ -6,10 +6,25 @@ module 0x8675309::M { struct S { dummy_field: bool, } - private fun t0(): (u64, M::S, M::R>) { - Tuple(0, pack M::S(false), pack M::R>(pack M::R(1))) + private fun t0(): (u64, 0x8675309::M::S, 0x8675309::M::R<0x8675309::M::R>) { + Tuple(0, pack M::S(false), pack M::R>(pack M::R(1))) } - private fun t1(s: &M::S,r: &mut M::R): (u64, &M::S, &mut M::R) { + private fun t1(s: &0x8675309::M::S,r: &mut 0x8675309::M::R): (u64, &0x8675309::M::S, &mut 0x8675309::M::R) { Tuple(0, s, r) } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R { + f: T, + } + struct S { + } + fun t0(): (u64, S, R>) { + (0, S{}, R>{f: R{f: 1}}) + } + fun t1(s: &S, r: &mut R): (u64, &S, &mut R) { + (0, s, r) + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/explicit_copy.exp b/third_party/move/move-compiler-v2/tests/checking/typing/explicit_copy.exp index 7d8da10d750b3..302b50e6dc637 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/explicit_copy.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/explicit_copy.exp @@ -8,7 +8,7 @@ module 0x8675309::M { } private fun t() { { - let s: M::S = pack M::S(false); + let s: S = pack M::S(false); Copy(0); Copy(s); s; @@ -17,3 +17,18 @@ module 0x8675309::M { } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R { + } + struct S has copy, drop { + } + fun t() { + let s = S{}; + copy 0; + copy s; + s; + 0; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/explicit_move.exp b/third_party/move/move-compiler-v2/tests/checking/typing/explicit_move.exp index 27cbe3d3c17ea..ac1cb7ef24a48 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/explicit_move.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/explicit_move.exp @@ -10,9 +10,9 @@ module 0x8675309::M { { let u: u64 = 0; { - let s: M::S = pack M::S(false); + let s: S = pack M::S(false); { - let r: M::R = pack M::R(false); + let r: R = pack M::R(false); Move(u); Move(s); M::R{ dummy_field: _ } = Move(r); @@ -22,3 +22,19 @@ module 0x8675309::M { } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R { + } + struct S has drop { + } + fun t() { + let u = 0; + let s = S{}; + let r = R{}; + move u; + move s; + R{} = move r; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/global_builtins.exp b/third_party/move/move-compiler-v2/tests/checking/typing/global_builtins.exp index 90546524be56a..04b8d2231d938 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/global_builtins.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/global_builtins.exp @@ -4,18 +4,18 @@ module 0x8675309::M { dummy_field: bool, } private fun t0(a: &signer) - acquires M::R(*) + acquires 0x8675309::M::R(*) { { - let _: bool = exists(0x0); + let _: bool = exists(0x0); { - let (): () = MoveTo(a, pack M::R(false)); + let (): () = MoveTo(a, pack M::R(false)); { - let _: &M::R = BorrowGlobal(Immutable)(0x0); + let _: &R = BorrowGlobal(Immutable)(0x0); { - let _: &mut M::R = BorrowGlobal(Mutable)(0x0); + let _: &mut R = BorrowGlobal(Mutable)(0x0); { - let M::R{ dummy_field: _ } = MoveFrom(0x0); + let M::R{ dummy_field: _ } = MoveFrom(0x0); Tuple() } } @@ -24,18 +24,18 @@ module 0x8675309::M { } } private fun t1(a: &signer) - acquires M::R(*) + acquires 0x8675309::M::R(*) { { - let _: bool = exists(0x0); + let _: bool = exists(0x0); { - let (): () = MoveTo(a, pack M::R(false)); + let (): () = MoveTo(a, pack M::R(false)); { - let _: &M::R = BorrowGlobal(Immutable)(0x0); + let _: &R = BorrowGlobal(Immutable)(0x0); { - let _: &mut M::R = BorrowGlobal(Mutable)(0x0); + let _: &mut R = BorrowGlobal(Mutable)(0x0); { - let M::R{ dummy_field: _ } = MoveFrom(0x0); + let M::R{ dummy_field: _ } = MoveFrom(0x0); Tuple() } } @@ -44,3 +44,27 @@ module 0x8675309::M { } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R has key { + } + fun t0(a: &signer) + acquires R + { + let _ = exists(0x0); + let () = move_to(a, R{}); + let _ = borrow_global(0x0); + let _ = borrow_global_mut(0x0); + let R{} = move_from(0x0); + } + fun t1(a: &signer) + acquires R + { + let _ = exists(0x0); + let () = move_to(a, R{}); + let _ = borrow_global(0x0); + let _ = borrow_global_mut(0x0); + let R{} = move_from(0x0); + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/global_builtins_inferred.exp b/third_party/move/move-compiler-v2/tests/checking/typing/global_builtins_inferred.exp index 8e154566ebee7..f8c0150058c56 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/global_builtins_inferred.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/global_builtins_inferred.exp @@ -4,10 +4,10 @@ module 0x42::m { addr: address, } public fun foo(input: address): address - acquires m::A(*) + acquires 0x42::m::A(*) { { - let a: m::A = MoveFrom(input); + let a: A = MoveFrom(input); { let m::A{ addr } = a; addr @@ -15,3 +15,17 @@ module 0x42::m { } } } // end 0x42::m + +// -- Sourcified model before bytecode pipeline +module 0x42::m { + struct A has key { + addr: address, + } + public fun foo(input: address): address + acquires A + { + let a = move_from(input); + let A{addr: addr} = a; + addr + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/hex_and_decimal_address.exp b/third_party/move/move-compiler-v2/tests/checking/typing/hex_and_decimal_address.exp index 579a7a863a3ef..9831e1b3d18c1 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/hex_and_decimal_address.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/hex_and_decimal_address.exp @@ -3,10 +3,10 @@ module 0x7b::M { struct S { dummy_field: bool, } - public fun s(): M::S { + public fun s(): 0x7b::M::S { pack M::S(false) } - public fun take(_s: M::S) { + public fun take(_s: 0x7b::M::S) { Tuple() } } // end 0x7b::M @@ -19,3 +19,22 @@ module _0 { Tuple() } } // end _0 + +// -- Sourcified model before bytecode pipeline +module 0x7b::M { + struct S has copy, drop { + } + public fun s(): S { + S{} + } + public fun take(_s: S) { + } +} +script { + fun main() { + 0x7b::M::take(0x7b::M::s()); + 0x7b::M::take(0x7b::M::s()); + 0x7b::M::take(0x7b::M::s()); + 0x7b::M::take(0x7b::M::s()); + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/if_branches_subtype.exp b/third_party/move/move-compiler-v2/tests/checking/typing/if_branches_subtype.exp index 9d0e1d8462b55..4efc4b81f3766 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/if_branches_subtype.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/if_branches_subtype.exp @@ -49,3 +49,17 @@ module 0x8675309::M { } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + fun t0(cond: bool, u: &u64, u_mut: &mut u64) { + let _ = if (cond) u else /*freeze*/u_mut; + let _ = if (cond) /*freeze*/u_mut else u; + let _ = if (cond) /*freeze*/u_mut else /*freeze*/u_mut; + } + fun t1(cond: bool, u: &u64, u_mut: &mut u64) { + let (_,_) = if (cond) (u, u) else (/*freeze*/u_mut, /*freeze*/u_mut); + let (_,_) = if (cond) (/*freeze*/u_mut, u) else (u, /*freeze*/u_mut); + let (_,_) = if (cond) (u, /*freeze*/u_mut) else (/*freeze*/u_mut, u); + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/if_condition.exp b/third_party/move/move-compiler-v2/tests/checking/typing/if_condition.exp index 554498b46c986..f0b20328e1276 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/if_condition.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/if_condition.exp @@ -25,3 +25,15 @@ module 0x8675309::M { } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + fun t0() { + if (true) (); + if (false) () + } + fun t1() { + if (true) (); + if (false) () + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/if_default_else.exp b/third_party/move/move-compiler-v2/tests/checking/typing/if_default_else.exp index 4794c6c8e1d7c..e3fd81b609527 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/if_default_else.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/if_default_else.exp @@ -24,3 +24,14 @@ module 0x8675309::M { } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + fun t0(cond: bool) { + if (cond) (); + let () = if (cond) (); + let () = if (cond) { + 0; + }; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/if_matched_branches.exp b/third_party/move/move-compiler-v2/tests/checking/typing/if_matched_branches.exp index 780bf81624ba8..1ddad9454c1b9 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/if_matched_branches.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/if_matched_branches.exp @@ -45,7 +45,7 @@ module 0x8675309::M { } else { Tuple(1, true) }; - (_: u64, _: u64, _: &u64, M::R{ dummy_field: _ }): (u64, u64, &u64, M::R) = if cond { + (_: u64, _: u64, _: &u64, M::R{ dummy_field: _ }): (u64, u64, &u64, R) = if cond { Tuple(0, 0, Borrow(Immutable)(0), pack M::R(false)) } else { Tuple(1, 1, Borrow(Immutable)(1), pack M::R(false)) @@ -53,3 +53,23 @@ module 0x8675309::M { Tuple() } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R { + } + fun t0(cond: bool) { + if (cond) (); + } + fun t1(cond: bool) { + if (cond) 0 else 0; + if (cond) false else false; + R{} = if (cond) R{} else R{}; + if (cond) &0 else &1; + if (cond) &mut 0 else &mut 1; + } + fun t2(cond: bool) { + if (cond) (0, false) else (1, true); + (_,_,_,R{}) = if (cond) (0, 0, &0, R{}) else (1, 1, &1, R{}); + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/implicit_deref_borrow_field.exp b/third_party/move/move-compiler-v2/tests/checking/typing/implicit_deref_borrow_field.exp index 091162a89bff2..5fa0efa999196 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/implicit_deref_borrow_field.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/implicit_deref_borrow_field.exp @@ -3,7 +3,17 @@ module 0x8675309::M { struct S { f: u64, } - private fun t0(s: &M::S,s_mut: &mut M::S): (u64, u64) { - Tuple(select M::S.f<&M::S>(s), select M::S.f<&mut M::S>(s_mut)) + private fun t0(s: &0x8675309::M::S,s_mut: &mut 0x8675309::M::S): (u64, u64) { + Tuple(select M::S.f<&S>(s), select M::S.f<&mut S>(s_mut)) } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct S { + f: u64, + } + fun t0(s: &S, s_mut: &mut S): (u64, u64) { + (s.f, s_mut.f) + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/implicit_deref_borrow_field_chain.exp b/third_party/move/move-compiler-v2/tests/checking/typing/implicit_deref_borrow_field_chain.exp index a295429bd20ef..9767a4568682a 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/implicit_deref_borrow_field_chain.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/implicit_deref_borrow_field_chain.exp @@ -1,19 +1,38 @@ // -- Model dump before bytecode pipeline module 0x8675309::M { struct X1 { - x2: M::X2, + x2: 0x8675309::M::X2, } struct X2 { - x3: M::X3, + x3: 0x8675309::M::X3, } struct X3 { f: u64, } - private fun t0(x1: &M::X1,x1_mut: &mut M::X1,x2: &M::X2,x2_mut: &mut M::X2) { - select M::X3.f(select M::X2.x3(select M::X1.x2<&M::X1>(x1))); - select M::X3.f(select M::X2.x3(select M::X1.x2<&mut M::X1>(x1_mut))); - select M::X3.f(select M::X2.x3<&M::X2>(x2)); - select M::X3.f(select M::X2.x3<&mut M::X2>(x2_mut)); + private fun t0(x1: &0x8675309::M::X1,x1_mut: &mut 0x8675309::M::X1,x2: &0x8675309::M::X2,x2_mut: &mut 0x8675309::M::X2) { + select M::X3.f(select M::X2.x3(select M::X1.x2<&X1>(x1))); + select M::X3.f(select M::X2.x3(select M::X1.x2<&mut X1>(x1_mut))); + select M::X3.f(select M::X2.x3<&X2>(x2)); + select M::X3.f(select M::X2.x3<&mut X2>(x2_mut)); Tuple() } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct X1 { + x2: X2, + } + struct X2 { + x3: X3, + } + struct X3 { + f: u64, + } + fun t0(x1: &X1, x1_mut: &mut X1, x2: &X2, x2_mut: &mut X2) { + x1.x2.x3.f; + x1_mut.x2.x3.f; + x2.x3.f; + x2_mut.x3.f; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/implicit_deref_borrow_field_complex_root_expr.exp b/third_party/move/move-compiler-v2/tests/checking/typing/implicit_deref_borrow_field_complex_root_expr.exp index 6a875a79a8dd8..0d2b566b8124e 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/implicit_deref_borrow_field_complex_root_expr.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/implicit_deref_borrow_field_complex_root_expr.exp @@ -3,31 +3,48 @@ module 0x8675309::M { struct S { f: u64, } - private fun t0(cond: bool,s: &M::S,s_mut: &mut M::S) { - select M::S.f<&M::S>(if cond { + private fun t0(cond: bool,s: &0x8675309::M::S,s_mut: &mut 0x8675309::M::S) { + select M::S.f<&S>(if cond { s } else { s }); - select M::S.f<&M::S>(if cond { + select M::S.f<&S>(if cond { Freeze(false)(s_mut) } else { s }); - select M::S.f<&M::S>(if cond { + select M::S.f<&S>(if cond { s } else { Freeze(false)(s_mut) }); - select M::S.f<&mut M::S>(if cond { + select M::S.f<&mut S>(if cond { s_mut } else { s_mut }); - select M::S.f<&M::S>({ - let s: M::S = pack M::S(0); + select M::S.f<&S>({ + let s: S = pack M::S(0); Borrow(Immutable)(s) }); Tuple() } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct S has drop { + f: u64, + } + fun t0(cond: bool, s: &S, s_mut: &mut S) { + (if (cond) s else s).f; + (if (cond) /*freeze*/s_mut else s).f; + (if (cond) s else /*freeze*/s_mut).f; + (if (cond) s_mut else s_mut).f; + { + let s = S{f: 0}; + &s + }.f; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/implicit_deref_borrow_field_non_ref_non_local_root.exp b/third_party/move/move-compiler-v2/tests/checking/typing/implicit_deref_borrow_field_non_ref_non_local_root.exp index 71ba5235e8226..08019a77055c7 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/implicit_deref_borrow_field_non_ref_non_local_root.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/implicit_deref_borrow_field_non_ref_non_local_root.exp @@ -3,21 +3,21 @@ module 0x8675309::M { struct S { f: u64, } - private fun bar(): M::S { + private fun bar(): 0x8675309::M::S { pack M::S(0) } - private fun foo(): &M::S { + private fun foo(): &0x8675309::M::S { Abort(0) } - private fun t0(cond: bool,_s: M::S) { - select M::S.f<&M::S>(M::foo()); - select M::S.f(M::bar()); - select M::S.f<&M::S>(if cond { + private fun t0(cond: bool,_s: 0x8675309::M::S) { + select M::S.f<&S>(M::foo()); + select M::S.f(M::bar()); + select M::S.f<&S>(if cond { M::foo() } else { Borrow(Immutable)(M::bar()) }); - select M::S.f(if cond { + select M::S.f(if cond { Deref(M::foo()) } else { M::bar() @@ -25,3 +25,22 @@ module 0x8675309::M { Tuple() } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct S has copy, drop { + f: u64, + } + fun bar(): S { + S{f: 0} + } + fun foo(): &S { + abort 0 + } + fun t0(cond: bool, _s: S) { + foo().f; + bar().f; + (if (cond) foo() else &bar()).f; + (if (cond) *foo() else bar()).f; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/implicit_deref_borrow_field_non_ref_root.exp b/third_party/move/move-compiler-v2/tests/checking/typing/implicit_deref_borrow_field_non_ref_root.exp index 32221dc6ce4a4..f6826224d11d1 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/implicit_deref_borrow_field_non_ref_root.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/implicit_deref_borrow_field_non_ref_root.exp @@ -3,9 +3,9 @@ module 0x8675309::M { struct S { f: u64, } - private fun t0(cond: bool,s: M::S) { - select M::S.f(s); - select M::S.f(if cond { + private fun t0(cond: bool,s: 0x8675309::M::S) { + select M::S.f(s); + select M::S.f(if cond { pack M::S(0) } else { pack M::S(1) @@ -13,3 +13,14 @@ module 0x8675309::M { Tuple() } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct S has drop { + f: u64, + } + fun t0(cond: bool, s: S) { + s.f; + (if (cond) S{f: 0} else S{f: 1}).f; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/large_binop.exp b/third_party/move/move-compiler-v2/tests/checking/typing/large_binop.exp index f73d7143c36ca..3f70f2058995c 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/large_binop.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/large_binop.exp @@ -5,3 +5,10 @@ module _0 { Tuple() } } // end _0 + +// -- Sourcified model before bytecode pipeline +script { + fun main() { + true; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/loop_body.exp b/third_party/move/move-compiler-v2/tests/checking/typing/loop_body.exp index c38a819cc31da..1c34ecf7e75a0 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/loop_body.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/loop_body.exp @@ -59,3 +59,38 @@ module 0x8675309::M { } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + fun t0() { + loop () + } + fun t1() { + loop () + } + fun t2() { + loop () + } + fun t3() { + loop { + 0; + } + } + fun t4() { + loop if (true) () + } + fun t5() { + loop break; + loop break; + loop return () + } + fun t6() { + loop continue + } + fun t7() { + loop continue + } + fun t8() { + loop loop break + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/loop_result_type.exp b/third_party/move/move-compiler-v2/tests/checking/typing/loop_result_type.exp index 6e4b1c4bce1ba..c14b82e5a0425 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/loop_result_type.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/loop_result_type.exp @@ -9,7 +9,7 @@ module 0x2::M { private fun foo(_x: u64) { Tuple() } - private fun t0(): X::R { + private fun t0(): 0x2::X::R { loop { Tuple() } @@ -25,7 +25,7 @@ module 0x2::M { Tuple() }) } - private fun t3(): X::R { + private fun t3(): 0x2::X::R { { let x: X::R = loop { 0; @@ -52,3 +52,35 @@ module 0x2::M { } } } // end 0x2::M + +// -- Sourcified model before bytecode pipeline +module 0x2::X { + struct R { + } +} +module 0x2::M { + use 0x2::X; + fun foo(_x: u64) { + } + fun t0(): X::R { + loop () + } + fun t1(): u64 { + loop { + 0; + } + } + fun t2() { + foo(loop ()) + } + fun t3(): X::R { + let x = loop { + 0; + }; + x + } + fun t4() { + let () = loop break; + let () = loop if (false) break; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/main_arguments.exp b/third_party/move/move-compiler-v2/tests/checking/typing/main_arguments.exp index f48682cc04cc9..b6b7ad1aeadb6 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/main_arguments.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/main_arguments.exp @@ -4,3 +4,9 @@ module _0 { Tuple() } } // end _0 + +// -- Sourcified model before bytecode pipeline +script { + fun main(_sender: signer, _a: address, _x8: u8, _x64: u64, _x128: u128, _b: bool, _v8: vector, _va: vector
, _v64: vector, _v128: vector, _vb: vector, _vv8: vector>, _vva: vector>, _vv64: vector>, _vv128: vector>, _vvb: vector>, _vvv8: vector>>, _vvva: vector>>, _vvv64: vector>>, _vvv128: vector>>, _vvvb: vector>>, _vvvv8: vector>>>, _vvvva: vector>>>, _vvvv64: vector>>>, _vvvv128: vector>>>, _vvvvb: vector>>>) { + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/main_arguments_various_caes.exp b/third_party/move/move-compiler-v2/tests/checking/typing/main_arguments_various_caes.exp index a729ac9e9d988..43625a99b9391 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/main_arguments_various_caes.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/main_arguments_various_caes.exp @@ -9,13 +9,33 @@ module 0x42::M { struct S { dummy_field: bool, } - public fun eat(r: M::R) { + public fun eat(r: 0x42::M::R) { M::R{ dummy_field: _ } = r } } // end 0x42::M module _0 { use 0x42::M::{S, R, Cup}; // resolved as: 0x42::M - private fun main(_s: &signer,_a0: #0,_a1: vector<#0>,_a2: vector>,_a3: M::S,_a4: M::R,_a5: M::Cup,_a6: M::Cup<#0>,_a7: vector) { + private fun main(_s: &signer,_a0: #0,_a1: vector<#0>,_a2: vector>,_a3: 0x42::M::S,_a4: 0x42::M::R,_a5: 0x42::M::Cup,_a6: 0x42::M::Cup<#0>,_a7: vector<0x42::M::S>) { Abort(0) } } // end _0 + +// -- Sourcified model before bytecode pipeline +module 0x42::M { + struct Cup { + f1: T, + } + struct R { + } + struct S { + } + public fun eat(r: R) { + R{} = r + } +} +script { + use 0x42::M; + fun main(_s: &signer, _a0: T, _a1: vector, _a2: vector>, _a3: M::S, _a4: M::R, _a5: M::Cup, _a6: M::Cup, _a7: vector) { + abort 0 + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/main_call_entry.exp b/third_party/move/move-compiler-v2/tests/checking/typing/main_call_entry.exp index f8cdb6a2f8ceb..ca739da5a5a17 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/main_call_entry.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/main_call_entry.exp @@ -9,3 +9,14 @@ module _0 { X::foo() } } // end _0 + +// -- Sourcified model before bytecode pipeline +module 0x2::X { + public entry fun foo() { + } +} +script { + fun main() { + 0x2::X::foo() + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/main_with_type_parameters.exp b/third_party/move/move-compiler-v2/tests/checking/typing/main_with_type_parameters.exp index cb4ca6a2d2269..4ce4ef16c689a 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/main_with_type_parameters.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/main_with_type_parameters.exp @@ -4,3 +4,9 @@ module _0 { Tuple() } } // end _0 + +// -- Sourcified model before bytecode pipeline +script { + fun main() { + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/module_call_entry_function.exp b/third_party/move/move-compiler-v2/tests/checking/typing/module_call_entry_function.exp index cf5eb639e99ea..e0bbe04193eb2 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/module_call_entry_function.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/module_call_entry_function.exp @@ -49,3 +49,49 @@ module 0x2::M { M::f_script() } } // end 0x2::M + +// -- Sourcified model before bytecode pipeline +module 0x2::Y { + friend 0x2::M; + friend fun f_friend() { + } +} +module 0x2::X { + public fun f_public() { + } + public entry fun f_script() { + } +} +module 0x2::M { + use 0x2::Y; + use 0x2::X; + friend fun f_friend() { + } + public fun f_public() { + } + public entry fun f_script() { + } + fun f_private() { + } + public entry fun f_script_call_friend() { + Y::f_friend() + } + public entry fun f_script_call_public() { + X::f_public() + } + public entry fun f_script_call_script() { + X::f_script() + } + public entry fun f_script_call_self_friend() { + f_friend() + } + public entry fun f_script_call_self_private() { + f_private() + } + public entry fun f_script_call_self_public() { + f_public() + } + public entry fun f_script_call_self_script() { + f_script() + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/move_from_type_argument.exp b/third_party/move/move-compiler-v2/tests/checking/typing/move_from_type_argument.exp index 8e154566ebee7..f8c0150058c56 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/move_from_type_argument.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/move_from_type_argument.exp @@ -4,10 +4,10 @@ module 0x42::m { addr: address, } public fun foo(input: address): address - acquires m::A(*) + acquires 0x42::m::A(*) { { - let a: m::A = MoveFrom(input); + let a: A = MoveFrom(input); { let m::A{ addr } = a; addr @@ -15,3 +15,17 @@ module 0x42::m { } } } // end 0x42::m + +// -- Sourcified model before bytecode pipeline +module 0x42::m { + struct A has key { + addr: address, + } + public fun foo(input: address): address + acquires A + { + let a = move_from(input); + let A{addr: addr} = a; + addr + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/mutable_eq_and_neq.exp b/third_party/move/move-compiler-v2/tests/checking/typing/mutable_eq_and_neq.exp index 21143c8c8fed3..6d09192fac363 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/mutable_eq_and_neq.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/mutable_eq_and_neq.exp @@ -4,14 +4,14 @@ module 0x8675309::M { f: bool, } struct P { - b1: M::B, - b2: M::B, + b1: 0x8675309::M::B, + b2: 0x8675309::M::B, } struct S { f: u64, g: u64, } - private fun t(r1: &mut u64,r2: &mut u64,s: &mut M::S) { + private fun t(r1: &mut u64,r2: &mut u64,s: &mut 0x8675309::M::S) { Eq(Freeze(false)(r1), Freeze(false)(r1)); Eq(Freeze(false)(r1), Freeze(false)(r2)); Eq(Freeze(false)(r2), Freeze(false)(r2)); @@ -20,26 +20,67 @@ module 0x8675309::M { Neq(Freeze(false)(r1), Freeze(false)(r2)); Neq(Freeze(false)(r2), Freeze(false)(r2)); Neq(Freeze(false)(r2), Freeze(false)(r2)); - Eq(Freeze(false)(Borrow(Mutable)(select M::S.f<&mut M::S>(s))), Freeze(false)(Borrow(Mutable)(select M::S.f<&mut M::S>(s)))); - Eq(Freeze(false)(Borrow(Mutable)(select M::S.f<&mut M::S>(s))), Freeze(false)(Borrow(Mutable)(select M::S.g<&mut M::S>(s)))); - Eq(Freeze(false)(Borrow(Mutable)(select M::S.g<&mut M::S>(s))), Freeze(false)(Borrow(Mutable)(select M::S.f<&mut M::S>(s)))); - Eq(Freeze(false)(Borrow(Mutable)(select M::S.g<&mut M::S>(s))), Freeze(false)(Borrow(Mutable)(select M::S.g<&mut M::S>(s)))); - Neq(Freeze(false)(Borrow(Mutable)(select M::S.f<&mut M::S>(s))), Freeze(false)(Borrow(Mutable)(select M::S.f<&mut M::S>(s)))); - Neq(Freeze(false)(Borrow(Mutable)(select M::S.f<&mut M::S>(s))), Freeze(false)(Borrow(Mutable)(select M::S.g<&mut M::S>(s)))); - Neq(Freeze(false)(Borrow(Mutable)(select M::S.g<&mut M::S>(s))), Freeze(false)(Borrow(Mutable)(select M::S.f<&mut M::S>(s)))); - Neq(Freeze(false)(Borrow(Mutable)(select M::S.g<&mut M::S>(s))), Freeze(false)(Borrow(Mutable)(select M::S.g<&mut M::S>(s)))); + Eq(Freeze(false)(Borrow(Mutable)(select M::S.f<&mut S>(s))), Freeze(false)(Borrow(Mutable)(select M::S.f<&mut S>(s)))); + Eq(Freeze(false)(Borrow(Mutable)(select M::S.f<&mut S>(s))), Freeze(false)(Borrow(Mutable)(select M::S.g<&mut S>(s)))); + Eq(Freeze(false)(Borrow(Mutable)(select M::S.g<&mut S>(s))), Freeze(false)(Borrow(Mutable)(select M::S.f<&mut S>(s)))); + Eq(Freeze(false)(Borrow(Mutable)(select M::S.g<&mut S>(s))), Freeze(false)(Borrow(Mutable)(select M::S.g<&mut S>(s)))); + Neq(Freeze(false)(Borrow(Mutable)(select M::S.f<&mut S>(s))), Freeze(false)(Borrow(Mutable)(select M::S.f<&mut S>(s)))); + Neq(Freeze(false)(Borrow(Mutable)(select M::S.f<&mut S>(s))), Freeze(false)(Borrow(Mutable)(select M::S.g<&mut S>(s)))); + Neq(Freeze(false)(Borrow(Mutable)(select M::S.g<&mut S>(s))), Freeze(false)(Borrow(Mutable)(select M::S.f<&mut S>(s)))); + Neq(Freeze(false)(Borrow(Mutable)(select M::S.g<&mut S>(s))), Freeze(false)(Borrow(Mutable)(select M::S.g<&mut S>(s)))); Tuple() } - private fun t1(p: &mut M::P) { + private fun t1(p: &mut 0x8675309::M::P) { { - let comp: bool = Eq(Freeze(false)(Borrow(Mutable)(select M::P.b1<&mut M::P>(p))), Freeze(false)(Borrow(Mutable)(select M::P.b2<&mut M::P>(p)))); - select M::B.f(select M::P.b1<&mut M::P>(p)) = comp + let comp: bool = Eq(Freeze(false)(Borrow(Mutable)(select M::P.b1<&mut P>(p))), Freeze(false)(Borrow(Mutable)(select M::P.b2<&mut P>(p)))); + select M::B.f(select M::P.b1<&mut P>(p)) = comp } } - private fun t2(p: &mut M::P) { + private fun t2(p: &mut 0x8675309::M::P) { { - let comp: bool = Neq(Freeze(false)(Borrow(Mutable)(select M::P.b1<&mut M::P>(p))), Freeze(false)(Borrow(Mutable)(select M::P.b2<&mut M::P>(p)))); - select M::B.f(select M::P.b1<&mut M::P>(p)) = comp + let comp: bool = Neq(Freeze(false)(Borrow(Mutable)(select M::P.b1<&mut P>(p))), Freeze(false)(Borrow(Mutable)(select M::P.b2<&mut P>(p)))); + select M::B.f(select M::P.b1<&mut P>(p)) = comp } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct B { + f: bool, + } + struct P { + b1: B, + b2: B, + } + struct S { + f: u64, + g: u64, + } + fun t(r1: &mut u64, r2: &mut u64, s: &mut S) { + /*freeze*/r1 == /*freeze*/r1; + /*freeze*/r1 == /*freeze*/r2; + /*freeze*/r2 == /*freeze*/r2; + /*freeze*/r2 == /*freeze*/r2; + /*freeze*/r1 != /*freeze*/r1; + /*freeze*/r1 != /*freeze*/r2; + /*freeze*/r2 != /*freeze*/r2; + /*freeze*/r2 != /*freeze*/r2; + /*freeze*/&mut s.f == /*freeze*/&mut s.f; + /*freeze*/&mut s.f == /*freeze*/&mut s.g; + /*freeze*/&mut s.g == /*freeze*/&mut s.f; + /*freeze*/&mut s.g == /*freeze*/&mut s.g; + /*freeze*/&mut s.f != /*freeze*/&mut s.f; + /*freeze*/&mut s.f != /*freeze*/&mut s.g; + /*freeze*/&mut s.g != /*freeze*/&mut s.f; + /*freeze*/&mut s.g != /*freeze*/&mut s.g; + } + fun t1(p: &mut P) { + let comp = /*freeze*/&mut p.b1 == /*freeze*/&mut p.b2; + p.b1.f = comp + } + fun t2(p: &mut P) { + let comp = /*freeze*/&mut p.b1 != /*freeze*/&mut p.b2; + p.b1.f = comp + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/mutate.exp b/third_party/move/move-compiler-v2/tests/checking/typing/mutate.exp index f293fbeeac9c4..aa834bfc75fc4 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/mutate.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/mutate.exp @@ -3,10 +3,10 @@ module 0x8675309::M { struct S { f: u64, } - private fun bar(s: &mut M::S): &mut M::S { + private fun bar(s: &mut 0x8675309::M::S): &mut 0x8675309::M::S { s } - private fun baz(): M::S { + private fun baz(): 0x8675309::M::S { pack M::S(0) } private fun foo(x: &mut u64): &mut u64 { @@ -14,21 +14,52 @@ module 0x8675309::M { } private fun t0() { Borrow(Mutable)(0) = 1; - Borrow(Mutable)(select M::S.f(pack M::S(0))) = 1; + Borrow(Mutable)(select M::S.f(pack M::S(0))) = 1; M::foo(Borrow(Mutable)(0)) = 1; - select M::S.f<&mut M::S>(M::bar(Borrow(Mutable)(pack M::S(0)))) = 1; - Borrow(Mutable)(select M::S.f<&mut M::S>(M::bar(Borrow(Mutable)(pack M::S(0))))) = 1; - select M::S.f(M::baz()) = 1; - Borrow(Mutable)(select M::S.f(M::baz())) = 1; + select M::S.f<&mut S>(M::bar(Borrow(Mutable)(pack M::S(0)))) = 1; + Borrow(Mutable)(select M::S.f<&mut S>(M::bar(Borrow(Mutable)(pack M::S(0))))) = 1; + select M::S.f(M::baz()) = 1; + Borrow(Mutable)(select M::S.f(M::baz())) = 1; Tuple() } private fun t1() { { - let r: &mut M::S = Borrow(Mutable)(pack M::S(0)); + let r: &mut S = Borrow(Mutable)(pack M::S(0)); r = pack M::S(1); - select M::S.f<&mut M::S>(r) = 1; - Borrow(Mutable)(select M::S.f<&mut M::S>(r)) = 1; + select M::S.f<&mut S>(r) = 1; + Borrow(Mutable)(select M::S.f<&mut S>(r)) = 1; Tuple() } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct S has copy, drop { + f: u64, + } + fun bar(s: &mut S): &mut S { + s + } + fun baz(): S { + S{f: 0} + } + fun foo(x: &mut u64): &mut u64 { + x + } + fun t0() { + *&mut 0 = 1; + *&mut S{f: 0}.f = 1; + *foo(&mut 0) = 1; + bar(&mut S{f: 0}).f = 1; + *&mut bar(&mut S{f: 0}).f = 1; + baz().f = 1; + *&mut baz().f = 1; + } + fun t1() { + let r = &mut S{f: 0}; + *r = S{f: 1}; + r.f = 1; + *&mut r.f = 1; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/neq.exp b/third_party/move/move-compiler-v2/tests/checking/typing/neq.exp index c4c982bba8e20..348b5cf618bd4 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/neq.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/neq.exp @@ -9,7 +9,7 @@ module 0x8675309::M { struct S { u: u64, } - private fun t0(r: &M::R,r_mut: &mut M::R,s: M::S,s_ref: &M::S,s_mut: &mut M::S) { + private fun t0(r: &0x8675309::M::R,r_mut: &mut 0x8675309::M::R,s: 0x8675309::M::S,s_ref: &0x8675309::M::S,s_mut: &mut 0x8675309::M::S) { true; true; true; @@ -18,19 +18,55 @@ module 0x8675309::M { Neq(Borrow(Immutable)(0), Borrow(Immutable)(1)); true; true; - Neq(Borrow(Immutable)(s), s_ref); - Neq(Freeze(false)(Borrow(Mutable)(s)), s_ref); - Neq(Freeze(false)(Borrow(Mutable)(s)), Freeze(false)(s_mut)); - Neq(Borrow(Immutable)(s), Freeze(false)(s_mut)); - Neq(s_ref, Freeze(false)(s_mut)); - Neq(Freeze(false)(s_mut), Freeze(false)(s_mut)); - Neq(pack M::S(0), s); - Neq(r, r); - Neq(Freeze(false)(r_mut), Freeze(false)(r_mut)); - Neq(r, Freeze(false)(r_mut)); - Neq(Freeze(false)(r_mut), r); - Neq>(pack M::G(1), pack M::G(2)); - Neq>(pack M::G(1), pack M::G(2)); + Neq(Borrow(Immutable)(s), s_ref); + Neq(Freeze(false)(Borrow(Mutable)(s)), s_ref); + Neq(Freeze(false)(Borrow(Mutable)(s)), Freeze(false)(s_mut)); + Neq(Borrow(Immutable)(s), Freeze(false)(s_mut)); + Neq(s_ref, Freeze(false)(s_mut)); + Neq(Freeze(false)(s_mut), Freeze(false)(s_mut)); + Neq(pack M::S(0), s); + Neq(r, r); + Neq(Freeze(false)(r_mut), Freeze(false)(r_mut)); + Neq(r, Freeze(false)(r_mut)); + Neq(Freeze(false)(r_mut), r); + Neq>(pack M::G(1), pack M::G(2)); + Neq>(pack M::G(1), pack M::G(2)); Tuple() } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct G has drop { + f: T, + } + struct R { + f: u64, + } + struct S has drop { + u: u64, + } + fun t0(r: &R, r_mut: &mut R, s: S, s_ref: &S, s_mut: &mut S) { + true; + true; + true; + true; + true; + &0 != &1; + true; + true; + &s != s_ref; + /*freeze*/&mut s != s_ref; + /*freeze*/&mut s != /*freeze*/s_mut; + &s != /*freeze*/s_mut; + s_ref != /*freeze*/s_mut; + /*freeze*/s_mut != /*freeze*/s_mut; + S{u: 0} != s; + r != r; + /*freeze*/r_mut != /*freeze*/r_mut; + r != /*freeze*/r_mut; + /*freeze*/r_mut != r; + G{f: 1} != G{f: 2}; + G{f: 1} != G{f: 2}; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/nested_post_process.exp b/third_party/move/move-compiler-v2/tests/checking/typing/nested_post_process.exp index d82dc536aca59..dec031e483fb0 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/nested_post_process.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/nested_post_process.exp @@ -8,11 +8,11 @@ module 0x42::simple_map { value: #1, } struct SimpleMap { - data: vector>, + data: vector<0x42::simple_map::Element<#0, #1>>, } - public fun borrow(map: &simple_map::SimpleMap<#0, #1>,key: �):  { + public fun borrow(map: &0x42::simple_map::SimpleMap<#0, #1>,key: �):  { { - let maybe_idx: option::Option = simple_map::find(map, key); + let maybe_idx: 0x1::option::Option = simple_map::find(map, key); if option::is_some(Borrow(Immutable)(maybe_idx)) { Tuple() } else { @@ -20,20 +20,20 @@ module 0x42::simple_map { }; { let idx: u64 = option::extract(Borrow(Mutable)(maybe_idx)); - Borrow(Immutable)(select simple_map::Element.value<&simple_map::Element>(vector::borrow>(Borrow(Immutable)(select simple_map::SimpleMap.data<&simple_map::SimpleMap>(map)), idx))) + Borrow(Immutable)(select simple_map::Element.value<&Element>(vector::borrow>(Borrow(Immutable)(select simple_map::SimpleMap.data<&SimpleMap>(map)), idx))) } } } - private fun find(map: &simple_map::SimpleMap<#0, #1>,key: �): option::Option { + private fun find(map: &0x42::simple_map::SimpleMap<#0, #1>,key: �): 0x1::option::Option { { - let leng: u64 = vector::length>(Borrow(Immutable)(select simple_map::SimpleMap.data<&simple_map::SimpleMap>(map))); + let leng: u64 = vector::length>(Borrow(Immutable)(select simple_map::SimpleMap.data<&SimpleMap>(map))); { let i: u64 = 0; loop { if Lt(i, leng) { { - let element: &simple_map::Element = vector::borrow>(Borrow(Immutable)(select simple_map::SimpleMap.data<&simple_map::SimpleMap>(map)), i); - if Eq(Borrow(Immutable)(select simple_map::Element.key<&simple_map::Element>(element)), key) { + let element: &Element = vector::borrow>(Borrow(Immutable)(select simple_map::SimpleMap.data<&SimpleMap>(map)), i); + if Eq(Borrow(Immutable)(select simple_map::Element.key<&Element>(element)), key) { return option::some(i) } else { Tuple() @@ -50,3 +50,30 @@ module 0x42::simple_map { } } } // end 0x42::simple_map + +// -- Sourcified model before bytecode pipeline +module 0x42::simple_map { + struct Element has copy, drop, store { + key: Key, + value: Value, + } + struct SimpleMap has copy, drop, store { + data: vector>, + } + public fun borrow(map: &SimpleMap, key: &Key): &Value { + let maybe_idx = find(map, key); + if (0x1::option::is_some(&maybe_idx)) () else abort 0x1::error::invalid_argument(2); + let idx = 0x1::option::extract(&mut maybe_idx); + &0x1::vector::borrow>(&map.data, idx).value + } + fun find(map: &SimpleMap, key: &Key): 0x1::option::Option { + let leng = 0x1::vector::length>(&map.data); + let i = 0; + while (i < leng) { + let element = 0x1::vector::borrow>(&map.data, i); + if (&element.key == key) return 0x1::option::some(i); + i = i + 1; + }; + 0x1::option::none() + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/other_builtins.exp b/third_party/move/move-compiler-v2/tests/checking/typing/other_builtins.exp index f55b1ebdbb292..8410c9263c7b4 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/other_builtins.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/other_builtins.exp @@ -19,3 +19,16 @@ module 0x8675309::M { Tuple() } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + fun any(): T { + abort 0 + } + fun foo(x: &mut u64) { + /*freeze*/x; + /*freeze*/&mut any>(); + if (false) () else abort *x; + if (true) () else abort 0; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/phantom_param_struct_decl.exp b/third_party/move/move-compiler-v2/tests/checking/typing/phantom_param_struct_decl.exp index 4e1a345132678..9397cd73cadd2 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/phantom_param_struct_decl.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/phantom_param_struct_decl.exp @@ -4,8 +4,8 @@ module 0x42::M1 { a: u64, } struct S2 { - a: M1::S1<#0>, - b: vector>, + a: 0x42::M1::S1<#0>, + b: vector<0x42::M1::S1<#0>>, } struct S3 { a: #1, @@ -15,6 +15,27 @@ module 0x42::M1 { a: u64, } struct S5 { - a: M1::S4<#0>, + a: 0x42::M1::S4<#0>, } } // end 0x42::M1 + +// -- Sourcified model before bytecode pipeline +module 0x42::M1 { + struct S1 { + a: u64, + } + struct S2 { + a: S1, + b: vector>, + } + struct S3 { + a: T2, + b: T4, + } + struct S4 { + a: u64, + } + struct S5 { + a: S4, + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/return_any_type.exp b/third_party/move/move-compiler-v2/tests/checking/typing/return_any_type.exp index bdaaf2919cd70..b056763411ee1 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/return_any_type.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/return_any_type.exp @@ -3,7 +3,7 @@ module 0x8675309::M { struct Coin { dummy_field: bool, } - private fun foo(c: M::Coin) { + private fun foo(c: 0x8675309::M::Coin) { M::Coin{ dummy_field: _ } = c; Tuple() } @@ -16,3 +16,18 @@ module 0x8675309::M { Tuple() } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct Coin { + } + fun foo(c: Coin) { + Coin{} = c; + } + fun t0() { + 0 + (return ()); + } + fun t1() { + foo(return ()); + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/return_type_explicit_exp.exp b/third_party/move/move-compiler-v2/tests/checking/typing/return_type_explicit_exp.exp index 087f85511cbb4..4266fc83608c4 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/return_type_explicit_exp.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/return_type_explicit_exp.exp @@ -13,7 +13,7 @@ module 0x8675309::M { private fun t1(): u64 { return 0 } - private fun t2(): (u64, bool, M::R) { + private fun t2(): (u64, bool, 0x8675309::M::R) { loop { if true { return Tuple(0, false, pack M::R(false)) @@ -24,3 +24,19 @@ module 0x8675309::M { Abort(0) } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R { + } + fun t0() { + if (true) () else () + } + fun t1(): u64 { + 0 + } + fun t2(): (u64, bool, R) { + while (true) return (0, false, R{}); + abort 0 + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/return_type_last_exp.exp b/third_party/move/move-compiler-v2/tests/checking/typing/return_type_last_exp.exp index d469d10153e28..1ad84ba57f52a 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/return_type_last_exp.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/return_type_last_exp.exp @@ -9,7 +9,21 @@ module 0x8675309::M { private fun t1(): u64 { 0 } - private fun t2(): (u64, bool, M::R) { + private fun t2(): (u64, bool, 0x8675309::M::R) { Tuple(0, false, pack M::R(false)) } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R { + } + fun t0() { + } + fun t1(): u64 { + 0 + } + fun t2(): (u64, bool, R) { + (0, false, R{}) + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/seq_ignores_value.exp b/third_party/move/move-compiler-v2/tests/checking/typing/seq_ignores_value.exp index 36751b65e11ae..ccb4861ab2f24 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/seq_ignores_value.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/seq_ignores_value.exp @@ -24,3 +24,21 @@ module 0x8675309::M { Tuple() } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct S has drop { + } + fun t0() { + (); + } + fun t1() { + 0; + } + fun t2() { + (0, false, S{}); + } + fun t3() { + if (true) (0, false, S{}) else (0, false, S{}); + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/shadowing.exp b/third_party/move/move-compiler-v2/tests/checking/typing/shadowing.exp index 7c470644e168e..5330d3e7bd8c3 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/shadowing.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/shadowing.exp @@ -41,3 +41,44 @@ module 0x8675309::M { Tuple() } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct S { + f: u64, + b: bool, + } + fun t0() { + { + false; + }; + 0; + { + false; + }; + 0; + { + { + 0x0; + }; + false; + }; + 0; + } + fun t1(cond: bool) { + if (cond) { + false; + } else { + 0x0; + }; + 0; + } + fun t2() { + loop { + let S{f: _,b: x} = S{f: 0,b: false}; + false; + break + }; + 0; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/spec_block_ok.exp b/third_party/move/move-compiler-v2/tests/checking/typing/spec_block_ok.exp index 34634cdef94de..e0af192eb67db 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/spec_block_ok.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/spec_block_ok.exp @@ -6,3 +6,14 @@ module 0x8675309::M { } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + fun specs_in_fun(_x: u64) { + + /* spec { + } + */ + + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/struct_no_field_list.exp b/third_party/move/move-compiler-v2/tests/checking/typing/struct_no_field_list.exp index 9b406f3159e49..cf2cabae91622 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/struct_no_field_list.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/struct_no_field_list.exp @@ -3,7 +3,7 @@ module 0x42::m { struct S { dummy_field: bool, } - private fun f(_s: m::S): m::S { + private fun f(_s: 0x42::m::S): 0x42::m::S { pack m::S(false) } private fun d() { @@ -19,3 +19,17 @@ module 0x42::m { } } } // end 0x42::m + +// -- Sourcified model before bytecode pipeline +module 0x42::m { + struct S has copy, drop { + } + fun f(_s: S): S { + S{} + } + fun d() { + let S{} = S{}; + let S{} = S{}; + let S{} = S{}; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/subtype_annotation.exp b/third_party/move/move-compiler-v2/tests/checking/typing/subtype_annotation.exp index 5b93526f7596c..237df485ea5b1 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/subtype_annotation.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/subtype_annotation.exp @@ -20,3 +20,23 @@ module 0x8675309::M { Tuple() } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct S has drop { + } + fun t0() { + &mut 0; + /*freeze*/&mut 0; + &0; + &mut S{}; + /*freeze*/&mut S{}; + &S{}; + } + fun t1() { + (&mut 0, &mut 0); + (&mut 0, /*freeze*/&mut 0); + (/*freeze*/&mut 0, &mut 0); + (/*freeze*/&mut 0, /*freeze*/&mut 0); + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/subtype_args.exp b/third_party/move/move-compiler-v2/tests/checking/typing/subtype_args.exp index 47591d5ea5698..371c553c2f185 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/subtype_args.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/subtype_args.exp @@ -18,8 +18,8 @@ module 0x8675309::M { 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))); + M::imm(Freeze(false)(Borrow(Mutable)(pack M::S(false)))); + M::imm(Borrow(Immutable)(pack M::S(false))); Tuple() } private fun t1() { @@ -34,3 +34,32 @@ module 0x8675309::M { Tuple() } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct S has drop { + } + fun imm(_x: &T) { + } + fun imm_imm(_x: &T, _y: &T) { + } + fun imm_mut(_x: &T, _y: &mut T) { + } + fun mut_imm(_x: &mut T, _y: &T) { + } + fun t0() { + imm(/*freeze*/&mut 0); + imm(&0); + imm(/*freeze*/&mut S{}); + imm(&S{}); + } + fun t1() { + imm_mut(/*freeze*/&mut 0, &mut 0); + mut_imm(&mut 0, /*freeze*/&mut 0); + imm_imm(/*freeze*/&mut 0, /*freeze*/&mut 0); + } + inline fun t2(f: |(&u64, &mut u64)|) { + f(&mut 0, &mut 0); + f(&0, &mut 0); + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/subtype_assign.exp b/third_party/move/move-compiler-v2/tests/checking/typing/subtype_assign.exp index 4a999869cd4a7..d4493825059b4 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/subtype_assign.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/subtype_assign.exp @@ -33,3 +33,28 @@ module 0x8675309::M { } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct S { + } + fun t0() { + let x; + x = /*freeze*/&mut 0; + x; + } + fun t1() { + let (x,y); + (x,y) = (&mut 0, /*freeze*/&mut 0); + x; + y; + let (x,y); + (x,y) = (/*freeze*/&mut 0, &mut 0); + x; + y; + let (x,y); + (x,y) = (/*freeze*/&mut 0, /*freeze*/&mut 0); + x; + y; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/subtype_bind.exp b/third_party/move/move-compiler-v2/tests/checking/typing/subtype_bind.exp index 70b49a9c85fe5..f0f96e40b7d90 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/subtype_bind.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/subtype_bind.exp @@ -29,3 +29,24 @@ module 0x8675309::M { } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct S { + } + fun t0() { + let x = /*freeze*/&mut 0; + x; + } + fun t1() { + let (x,y) = (&mut 0, /*freeze*/&mut 0); + x; + y; + let (x,y) = (/*freeze*/&mut 0, &mut 0); + x; + y; + let (x,y) = (/*freeze*/&mut 0, /*freeze*/&mut 0); + x; + y; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/subtype_return.exp b/third_party/move/move-compiler-v2/tests/checking/typing/subtype_return.exp index c7ac66f03b81d..b015634b5f61d 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/subtype_return.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/subtype_return.exp @@ -6,7 +6,7 @@ module 0x8675309::M { private fun t0(u: &mut u64): &u64 { Freeze(false)(u) } - private fun t1(s: &mut M::S): &M::S { + private fun t1(s: &mut 0x8675309::M::S): &0x8675309::M::S { Freeze(false)(s) } private fun t2(u1: &mut u64,u2: &mut u64): (&u64, &mut u64) { @@ -19,3 +19,24 @@ module 0x8675309::M { Tuple(Freeze(false)(u1), Freeze(false)(u2)) } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct S { + } + fun t0(u: &mut u64): &u64 { + /*freeze*/u + } + fun t1(s: &mut S): &S { + /*freeze*/s + } + fun t2(u1: &mut u64, u2: &mut u64): (&u64, &mut u64) { + (/*freeze*/u1, u2) + } + fun t3(u1: &mut u64, u2: &mut u64): (&mut u64, &u64) { + (u1, /*freeze*/u2) + } + fun t4(u1: &mut u64, u2: &mut u64): (&u64, &u64) { + (/*freeze*/u1, /*freeze*/u2) + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/tuple.exp b/third_party/move/move-compiler-v2/tests/checking/typing/tuple.exp index 132846113b36a..9179e41d22c3a 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/tuple.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/tuple.exp @@ -3,13 +3,27 @@ module 0x42::tuple { struct S { f: u64, } - private fun tuple(x: u64): (u64, tuple::S) { + private fun tuple(x: u64): (u64, 0x42::tuple::S) { Tuple(x, pack tuple::S(Add(x, 1))) } private fun use_tuple(x: u64): u64 { { - let (x: u64, tuple::S{ f: y }): (u64, tuple::S) = tuple::tuple(x); + let (x: u64, tuple::S{ f: y }): (u64, S) = tuple::tuple(x); Add(x, y) } } } // end 0x42::tuple + +// -- Sourcified model before bytecode pipeline +module 0x42::tuple { + struct S { + f: u64, + } + fun tuple(x: u64): (u64, S) { + (x, S{f: x + 1}) + } + fun use_tuple(x: u64): u64 { + let (x,S{f: y}) = tuple(x); + x + y + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/type_variable_join_single_pack.exp b/third_party/move/move-compiler-v2/tests/checking/typing/type_variable_join_single_pack.exp index 0d0ae4c52ac2e..ab361d197f9af 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/type_variable_join_single_pack.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/type_variable_join_single_pack.exp @@ -6,13 +6,27 @@ module 0x42::M { } private fun t0() { { - let b: M::Box = pack M::Box(0, 1); + let b: Box = pack M::Box(0, 1); Deref(Borrow(Immutable)(b)); { - let b2: M::Box> = pack M::Box>(Deref(Borrow(Immutable)(b)), b); + let b2: Box> = pack M::Box>(Deref(Borrow(Immutable)(b)), b); b2; Tuple() } } } } // end 0x42::M + +// -- Sourcified model before bytecode pipeline +module 0x42::M { + struct Box has copy, drop { + f1: T, + f2: T, + } + fun t0() { + let b = Box{f1: 0,f2: 1}; + *&b; + let b2 = Box>{f1: *&b,f2: b}; + b2; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/type_variable_join_single_unpack.exp b/third_party/move/move-compiler-v2/tests/checking/typing/type_variable_join_single_unpack.exp index 63252d1509136..744ddbce697f8 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/type_variable_join_single_unpack.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/type_variable_join_single_unpack.exp @@ -4,7 +4,7 @@ module 0x8675309::M { f1: #0, f2: #0, } - private fun new(): M::Box<#0> { + private fun new(): 0x8675309::M::Box<#0> { Abort(0) } private fun t0() { @@ -13,7 +13,7 @@ module 0x8675309::M { f1; f2; { - let M::Box>{ f1, f2 } = M::new>(); + let M::Box>{ f1, f2 } = M::new>(); f1; f2; Tuple() @@ -21,3 +21,22 @@ module 0x8675309::M { } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct Box has drop { + f1: T, + f2: T, + } + fun new(): Box { + abort 0 + } + fun t0() { + let Box{f1: f1,f2: f2} = new(); + f1; + f2; + let Box>{f1: f1,f2: f2} = new>(); + f1; + f2; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/type_variable_join_single_unpack_assign.exp b/third_party/move/move-compiler-v2/tests/checking/typing/type_variable_join_single_unpack_assign.exp index 141500cd03452..324811e2bf95c 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/type_variable_join_single_unpack_assign.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/type_variable_join_single_unpack_assign.exp @@ -4,7 +4,7 @@ module 0x8675309::M { f1: #0, f2: #0, } - private fun new(): M::Box<#0> { + private fun new(): 0x8675309::M::Box<#0> { Abort(0) } private fun t0() { @@ -16,10 +16,10 @@ module 0x8675309::M { f1; f2; { - let f1: M::Box; + let f1: Box; { - let f2: M::Box; - M::Box>{ f1, f2 } = M::new>(); + let f2: Box; + M::Box>{ f1, f2 } = M::new>(); f1; f2; Tuple() @@ -29,3 +29,26 @@ module 0x8675309::M { } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct Box has drop { + f1: T, + f2: T, + } + fun new(): Box { + abort 0 + } + fun t0() { + let f1; + let f2; + Box{f1: f1,f2: f2} = new(); + f1; + f2; + let f1; + let f2; + Box>{f1: f1,f2: f2} = new>(); + f1; + f2; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/type_variable_join_threaded_pack.exp b/third_party/move/move-compiler-v2/tests/checking/typing/type_variable_join_threaded_pack.exp index 00bbfae97d9e5..b2bad04f60ca2 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/type_variable_join_threaded_pack.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/type_variable_join_threaded_pack.exp @@ -3,13 +3,13 @@ module 0x2::Container { struct T { f: #0, } - public fun get(_self: &Container::T<#0>): #0 { + public fun get(_self: &0x2::Container::T<#0>): #0 { Abort(0) } - public fun new(): Container::T<#0> { + public fun new(): 0x2::Container::T<#0> { Abort(0) } - public fun put(_self: &mut Container::T<#0>,_item: #0) { + public fun put(_self: &mut 0x2::Container::T<#0>,_item: #0) { Abort(0) } } // end 0x2::Container @@ -19,13 +19,13 @@ module 0x2::M { f1: #0, f2: #0, } - private fun t0(): M::Box { + private fun t0(): 0x2::M::Box { { let v: Container::T = Container::new(); { let x: u64 = Container::get(Borrow(Immutable)(v)); { - let b: M::Box = pack M::Box(x, x); + let b: Box = pack M::Box(x, x); Container::put(Borrow(Mutable)(v), 0); b } @@ -33,3 +33,33 @@ module 0x2::M { } } } // end 0x2::M + +// -- Sourcified model before bytecode pipeline +module 0x2::Container { + struct T has drop { + f: V, + } + public fun get(_self: &T): V { + abort 0 + } + public fun new(): T { + abort 0 + } + public fun put(_self: &mut T, _item: V) { + abort 0 + } +} +module 0x2::M { + use 0x2::Container; + struct Box has drop { + f1: T, + f2: T, + } + fun t0(): Box { + let v = Container::new(); + let x = Container::get(&v); + let b = Box{f1: x,f2: x}; + Container::put(&mut v, 0); + b + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/unary_not.exp b/third_party/move/move-compiler-v2/tests/checking/typing/unary_not.exp index da126c647eb2c..b3ef557ff8284 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/unary_not.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/unary_not.exp @@ -3,16 +3,32 @@ module 0x8675309::M { struct R { f: bool, } - private fun t0(x: bool,r: M::R) { + private fun t0(x: bool,r: 0x8675309::M::R) { false; true; Not(x); Not(Copy(x)); Not(Move(x)); - Not(select M::R.f(r)); + Not(select M::R.f(r)); { let M::R{ f: _ } = r; Tuple() } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R { + f: bool, + } + fun t0(x: bool, r: R) { + false; + true; + !x; + !(copy x); + !(move x); + !r.f; + let R{f: _} = r; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/unit.exp b/third_party/move/move-compiler-v2/tests/checking/typing/unit.exp index 0e7cba1feba85..d3915ca4454d9 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/unit.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/unit.exp @@ -5,3 +5,10 @@ module 0x8675309::M { Tuple() } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + fun foo() { + (); + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/unused_lambda_param.exp b/third_party/move/move-compiler-v2/tests/checking/typing/unused_lambda_param.exp index 27ff8573fad05..26dddef4b0ac9 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/unused_lambda_param.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/unused_lambda_param.exp @@ -24,3 +24,19 @@ module 0xc0ffee::m { Tuple() } } // end 0xc0ffee::m + +// -- Sourcified model before bytecode pipeline +module 0xc0ffee::m { + inline fun test(p: u64, f: |u64|u64): u64 { + f(p) + } + fun unused_lambda() { + 1; + } + fun unused_lambda_suppressed1() { + 1; + } + fun unused_lambda_suppressed2() { + 1; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/unused_lambda_param_typed.exp b/third_party/move/move-compiler-v2/tests/checking/typing/unused_lambda_param_typed.exp index ca98b47e485f2..a8cb39a936fa9 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/unused_lambda_param_typed.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/unused_lambda_param_typed.exp @@ -24,3 +24,19 @@ module 0xc0ffee::m { Tuple() } } // end 0xc0ffee::m + +// -- Sourcified model before bytecode pipeline +module 0xc0ffee::m { + inline fun test(p: u64, f: |u64|u64): u64 { + f(p) + } + fun unused_lambda() { + 1; + } + fun unused_lambda_suppressed1() { + 1; + } + fun unused_lambda_suppressed2() { + 1; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/unused_local.exp b/third_party/move/move-compiler-v2/tests/checking/typing/unused_local.exp index 0e221c884baf1..f1d8f4b665dd0 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/unused_local.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/unused_local.exp @@ -104,3 +104,37 @@ module 0x8675309::M { Tuple() } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct S { + f: u64, + g: bool, + } + fun t0() { + } + fun t1() { + } + fun t2() { + let S{f: f,g: g}; + } + fun two_unused(x: u64, y: bool) { + } + fun unused_local_suppressed1() { + } + fun unused_local_suppressed2() { + } + native fun unused_native_ok(x: u64, y: bool) ; + fun unused_param(x: u64) { + } + fun unused_param1_used_param2(x: u64, y: bool): bool { + y + } + fun unused_param2_used_param1(x: u64, y: bool): u64 { + x + } + fun unused_param_suppressed1(_: u64) { + } + fun unused_param_suppressed2(_x: u64) { + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/use_local.exp b/third_party/move/move-compiler-v2/tests/checking/typing/use_local.exp index d211b57c21a2e..6f1a2a0fe293d 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/use_local.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/use_local.exp @@ -8,9 +8,9 @@ module 0x8675309::M { } private fun t() { { - let s: M::S = pack M::S(false); + let s: S = pack M::S(false); { - let r: M::R = pack M::R(false); + let r: R = pack M::R(false); 0; s; M::R{ dummy_field: _ } = r; @@ -19,3 +19,18 @@ module 0x8675309::M { } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R { + } + struct S has drop { + } + fun t() { + let s = S{}; + let r = R{}; + 0; + s; + R{} = r; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/v1-examples/multi_pool_money_market_token.exp b/third_party/move/move-compiler-v2/tests/checking/typing/v1-examples/multi_pool_money_market_token.exp index afd5f2f73d767..6cff64e15ab04 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/v1-examples/multi_pool_money_market_token.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/v1-examples/multi_pool_money_market_token.exp @@ -22,25 +22,25 @@ module 0x2::Token { type: #0, value: u64, } - public fun create(type: #0,value: u64): Token::Coin<#0> { + public fun create(type: #0,value: u64): 0x2::Token::Coin<#0> { pack Token::Coin(type, value) } - public fun value(coin: &Token::Coin<#0>): u64 { - select Token::Coin.value<&Token::Coin>(coin) + public fun value(coin: &0x2::Token::Coin<#0>): u64 { + select Token::Coin.value<&Coin>(coin) } - public fun deposit(coin: &mut Token::Coin<#0>,check: Token::Coin<#0>) { + public fun deposit(coin: &mut 0x2::Token::Coin<#0>,check: 0x2::Token::Coin<#0>) { { let Token::Coin{ type, value } = check; - if Eq(Borrow(Immutable)(select Token::Coin.type<&mut Token::Coin>(coin)), Borrow(Immutable)(type)) { + if Eq(Borrow(Immutable)(select Token::Coin.type<&mut Coin>(coin)), Borrow(Immutable)(type)) { Tuple() } else { Abort(42) }; - select Token::Coin.value<&mut Token::Coin>(coin) = Add(select Token::Coin.value<&mut Token::Coin>(coin), value); + select Token::Coin.value<&mut Coin>(coin) = Add(select Token::Coin.value<&mut Coin>(coin), value); Tuple() } } - public fun destroy_zero(coin: Token::Coin<#0>) { + public fun destroy_zero(coin: 0x2::Token::Coin<#0>) { { let Token::Coin{ type: _, value } = coin; if Eq(value, 0) { @@ -50,57 +50,57 @@ module 0x2::Token { } } } - public fun join(xus: Token::Coin<#0>,coin2: Token::Coin<#0>): Token::Coin<#0> { + public fun join(xus: 0x2::Token::Coin<#0>,coin2: 0x2::Token::Coin<#0>): 0x2::Token::Coin<#0> { Token::deposit(Borrow(Mutable)(xus), coin2); xus } - public fun split(coin: Token::Coin<#0>,amount: u64): (Token::Coin<#0>, Token::Coin<#0>) { + public fun split(coin: 0x2::Token::Coin<#0>,amount: u64): (0x2::Token::Coin<#0>, 0x2::Token::Coin<#0>) { { - let other: Token::Coin = Token::withdraw(Borrow(Mutable)(coin), amount); + let other: Coin = Token::withdraw(Borrow(Mutable)(coin), amount); Tuple(coin, other) } } - public fun withdraw(coin: &mut Token::Coin<#0>,amount: u64): Token::Coin<#0> { - if Ge(select Token::Coin.value<&mut Token::Coin>(coin), amount) { + public fun withdraw(coin: &mut 0x2::Token::Coin<#0>,amount: u64): 0x2::Token::Coin<#0> { + if Ge(select Token::Coin.value<&mut Coin>(coin), amount) { Tuple() } else { Abort(10) }; - select Token::Coin.value<&mut Token::Coin>(coin) = Sub(select Token::Coin.value<&mut Token::Coin>(coin), amount); - pack Token::Coin(Deref(Borrow(Immutable)(select Token::Coin.type<&mut Token::Coin>(coin))), amount) + select Token::Coin.value<&mut Coin>(coin) = Sub(select Token::Coin.value<&mut Coin>(coin), amount); + pack Token::Coin(Deref(Borrow(Immutable)(select Token::Coin.type<&mut Coin>(coin))), amount) } } // end 0x2::Token module 0x2::Map { struct T { } - public native fun empty(): Map::T<#0, #1>; - public native fun remove(m: &Map::T<#0, #1>,k: �): #1; - public native fun contains_key(m: &Map::T<#0, #1>,k: �): bool; - public native fun get(m: &Map::T<#0, #1>,k: �):  - public native fun get_mut(m: &mut Map::T<#0, #1>,k: �): &mut #1; - public native fun insert(m: &Map::T<#0, #1>,k: #0,v: #1); + public native fun empty(): 0x2::Map::T<#0, #1>; + public native fun remove(m: &0x2::Map::T<#0, #1>,k: �): #1; + public native fun contains_key(m: &0x2::Map::T<#0, #1>,k: �): bool; + public native fun get(m: &0x2::Map::T<#0, #1>,k: �):  + public native fun get_mut(m: &mut 0x2::Map::T<#0, #1>,k: �): &mut #1; + public native fun insert(m: &0x2::Map::T<#0, #1>,k: #0,v: #1); } // end 0x2::Map module 0x3::OneToOneMarket { use std::signer; use 0x2::Map; // resolved as: 0x2::Map use 0x2::Token; // resolved as: 0x2::Token struct BorrowRecord { - record: Map::T, + record: 0x2::Map::T, } struct DepositRecord { - record: Map::T, + record: 0x2::Map::T, } struct Pool { - coin: Token::Coin<#0>, + coin: 0x2::Token::Coin<#0>, } struct Price { price: u64, } - public fun borrow(account: &signer,pool_owner: address,amount: u64): Token::Coin<#1> - acquires OneToOneMarket::Price(*) - acquires OneToOneMarket::Pool(*) - acquires OneToOneMarket::DepositRecord(*) - acquires OneToOneMarket::BorrowRecord(*) + public fun borrow(account: &signer,pool_owner: address,amount: u64): 0x2::Token::Coin<#1> + acquires 0x3::OneToOneMarket::Price(*) + acquires 0x3::OneToOneMarket::Pool(*) + acquires 0x3::OneToOneMarket::DepositRecord(*) + acquires 0x3::OneToOneMarket::BorrowRecord(*) { if Le(amount, OneToOneMarket::max_borrow_amount(account, pool_owner)) { Tuple() @@ -109,46 +109,46 @@ module 0x3::OneToOneMarket { }; OneToOneMarket::update_borrow_record(account, pool_owner, amount); { - let pool: &mut OneToOneMarket::Pool = BorrowGlobal(Mutable)>(pool_owner); - Token::withdraw(Borrow(Mutable)(select OneToOneMarket::Pool.coin<&mut OneToOneMarket::Pool>(pool)), amount) + let pool: &mut Pool = BorrowGlobal(Mutable)>(pool_owner); + Token::withdraw(Borrow(Mutable)(select OneToOneMarket::Pool.coin<&mut Pool>(pool)), amount) } } - public fun deposit(account: &signer,pool_owner: address,coin: Token::Coin<#0>) - acquires OneToOneMarket::Pool(*) - acquires OneToOneMarket::DepositRecord(*) + public fun deposit(account: &signer,pool_owner: address,coin: 0x2::Token::Coin<#0>) + acquires 0x3::OneToOneMarket::Pool(*) + acquires 0x3::OneToOneMarket::DepositRecord(*) { { let amount: u64 = Token::value(Borrow(Immutable)(coin)); OneToOneMarket::update_deposit_record(account, pool_owner, amount); { - let pool: &mut OneToOneMarket::Pool = BorrowGlobal(Mutable)>(pool_owner); - Token::deposit(Borrow(Mutable)(select OneToOneMarket::Pool.coin<&mut OneToOneMarket::Pool>(pool)), coin) + let pool: &mut Pool = BorrowGlobal(Mutable)>(pool_owner); + Token::deposit(Borrow(Mutable)(select OneToOneMarket::Pool.coin<&mut Pool>(pool)), coin) } } } - private fun accept(account: &signer,init: Token::Coin<#0>) { + private fun accept(account: &signer,init: 0x2::Token::Coin<#0>) { { let sender: address = signer::address_of(account); - if Not(exists>(sender)) { + if Not(exists>(sender)) { Tuple() } else { Abort(42) }; - MoveTo>(account, pack OneToOneMarket::Pool(init)) + MoveTo>(account, pack OneToOneMarket::Pool(init)) } } private fun borrowed_amount(account: &signer,pool_owner: address): u64 - acquires OneToOneMarket::BorrowRecord(*) + acquires 0x3::OneToOneMarket::BorrowRecord(*) { { let sender: address = signer::address_of(account); - if Not(exists>(sender)) { + if Not(exists>(sender)) { return 0 } else { Tuple() }; { - let record: &Map::T = Borrow(Immutable)(select OneToOneMarket::BorrowRecord.record<&OneToOneMarket::BorrowRecord>(BorrowGlobal(Immutable)>(sender))); + let record: &Map::T = Borrow(Immutable)(select OneToOneMarket::BorrowRecord.record<&BorrowRecord>(BorrowGlobal(Immutable)>(sender))); if Map::contains_key(record, Borrow(Immutable)(pool_owner)) { Deref(Map::get(record, Borrow(Immutable)(pool_owner))) } else { @@ -158,17 +158,17 @@ module 0x3::OneToOneMarket { } } private fun deposited_amount(account: &signer,pool_owner: address): u64 - acquires OneToOneMarket::DepositRecord(*) + acquires 0x3::OneToOneMarket::DepositRecord(*) { { let sender: address = signer::address_of(account); - if Not(exists>(sender)) { + if Not(exists>(sender)) { return 0 } else { Tuple() }; { - let record: &Map::T = Borrow(Immutable)(select OneToOneMarket::DepositRecord.record<&OneToOneMarket::DepositRecord>(BorrowGlobal(Immutable)>(sender))); + let record: &Map::T = Borrow(Immutable)(select OneToOneMarket::DepositRecord.record<&DepositRecord>(BorrowGlobal(Immutable)>(sender))); if Map::contains_key(record, Borrow(Immutable)(pool_owner)) { Deref(Map::get(record, Borrow(Immutable)(pool_owner))) } else { @@ -178,17 +178,17 @@ module 0x3::OneToOneMarket { } } private fun max_borrow_amount(account: &signer,pool_owner: address): u64 - acquires OneToOneMarket::Price(*) - acquires OneToOneMarket::Pool(*) - acquires OneToOneMarket::DepositRecord(*) - acquires OneToOneMarket::BorrowRecord(*) + acquires 0x3::OneToOneMarket::Price(*) + acquires 0x3::OneToOneMarket::Pool(*) + acquires 0x3::OneToOneMarket::DepositRecord(*) + acquires 0x3::OneToOneMarket::BorrowRecord(*) { { let input_deposited: u64 = OneToOneMarket::deposited_amount(account, pool_owner); { let output_deposited: u64 = OneToOneMarket::borrowed_amount(account, pool_owner); { - let input_into_output: u64 = Mul(input_deposited, select OneToOneMarket::Price.price<&OneToOneMarket::Price>(BorrowGlobal(Immutable)>(pool_owner))); + let input_into_output: u64 = Mul(input_deposited, select OneToOneMarket::Price.price<&Price>(BorrowGlobal(Immutable)>(pool_owner))); { let max_output: u64 = if Lt(input_into_output, output_deposited) { 0 @@ -197,8 +197,8 @@ module 0x3::OneToOneMarket { }; { let available_output: u64 = { - let pool: &OneToOneMarket::Pool = BorrowGlobal(Immutable)>(pool_owner); - Token::value(Borrow(Immutable)(select OneToOneMarket::Pool.coin<&OneToOneMarket::Pool>(pool))) + let pool: &Pool = BorrowGlobal(Immutable)>(pool_owner); + Token::value(Borrow(Immutable)(select OneToOneMarket::Pool.coin<&Pool>(pool))) }; if Lt(max_output, available_output) { max_output @@ -211,23 +211,23 @@ module 0x3::OneToOneMarket { } } } - public fun register_price(account: &signer,initial_in: Token::Coin<#0>,initial_out: Token::Coin<#1>,price: u64) { + public fun register_price(account: &signer,initial_in: 0x2::Token::Coin<#0>,initial_out: 0x2::Token::Coin<#1>,price: u64) { OneToOneMarket::accept(account, initial_in); OneToOneMarket::accept(account, initial_out); - MoveTo>(account, pack OneToOneMarket::Price(price)) + MoveTo>(account, pack OneToOneMarket::Price(price)) } private fun update_borrow_record(account: &signer,pool_owner: address,amount: u64) - acquires OneToOneMarket::BorrowRecord(*) + acquires 0x3::OneToOneMarket::BorrowRecord(*) { { let sender: address = signer::address_of(account); - if Not(exists>(sender)) { - MoveTo>(account, pack OneToOneMarket::BorrowRecord(Map::empty())) + if Not(exists>(sender)) { + MoveTo>(account, pack OneToOneMarket::BorrowRecord(Map::empty())) } else { Tuple() }; { - let record: &mut Map::T = Borrow(Mutable)(select OneToOneMarket::BorrowRecord.record<&mut OneToOneMarket::BorrowRecord>(BorrowGlobal(Mutable)>(sender))); + let record: &mut Map::T = Borrow(Mutable)(select OneToOneMarket::BorrowRecord.record<&mut BorrowRecord>(BorrowGlobal(Mutable)>(sender))); if Map::contains_key(Freeze(false)(record), Borrow(Immutable)(pool_owner)) { { let old_amount: u64 = Map::remove(Freeze(false)(record), Borrow(Immutable)(pool_owner)); @@ -242,17 +242,17 @@ module 0x3::OneToOneMarket { } } private fun update_deposit_record(account: &signer,pool_owner: address,amount: u64) - acquires OneToOneMarket::DepositRecord(*) + acquires 0x3::OneToOneMarket::DepositRecord(*) { { let sender: address = signer::address_of(account); - if Not(exists>(sender)) { - MoveTo>(account, pack OneToOneMarket::DepositRecord(Map::empty())) + if Not(exists>(sender)) { + MoveTo>(account, pack OneToOneMarket::DepositRecord(Map::empty())) } else { Tuple() }; { - let record: &mut Map::T = Borrow(Mutable)(select OneToOneMarket::DepositRecord.record<&mut OneToOneMarket::DepositRecord>(BorrowGlobal(Mutable)>(sender))); + let record: &mut Map::T = Borrow(Mutable)(select OneToOneMarket::DepositRecord.record<&mut DepositRecord>(BorrowGlobal(Mutable)>(sender))); if Map::contains_key(Freeze(false)(record), Borrow(Immutable)(pool_owner)) { { let old_amount: u64 = Map::remove(Freeze(false)(record), Borrow(Immutable)(pool_owner)); @@ -274,7 +274,7 @@ module 0x70dd::ToddNickels { dummy_field: bool, } struct Wallet { - nickels: Token::Coin, + nickels: 0x2::Token::Coin<0x70dd::ToddNickels::T>, } public fun init(account: &signer) { if Eq
(signer::address_of(account), 0x70dd) { @@ -282,19 +282,181 @@ module 0x70dd::ToddNickels { } else { Abort(42) }; - MoveTo(account, pack ToddNickels::Wallet(Token::create(pack ToddNickels::T(false), 0))) + MoveTo(account, pack ToddNickels::Wallet(Token::create(pack ToddNickels::T(false), 0))) } - public fun destroy(c: Token::Coin) - acquires ToddNickels::Wallet(*) + public fun destroy(c: 0x2::Token::Coin<0x70dd::ToddNickels::T>) + acquires 0x70dd::ToddNickels::Wallet(*) { - Token::deposit(Borrow(Mutable)(select ToddNickels::Wallet.nickels<&mut ToddNickels::Wallet>(BorrowGlobal(Mutable)(0x70dd))), c) + Token::deposit(Borrow(Mutable)(select ToddNickels::Wallet.nickels<&mut Wallet>(BorrowGlobal(Mutable)(0x70dd))), c) } - public fun mint(account: &signer): Token::Coin { + public fun mint(account: &signer): 0x2::Token::Coin<0x70dd::ToddNickels::T> { if Eq
(signer::address_of(account), 0x70dd) { Tuple() } else { Abort(42) }; - Token::create(pack ToddNickels::T(false), 5) + Token::create(pack ToddNickels::T(false), 5) } } // end 0x70dd::ToddNickels + +// -- Sourcified model before bytecode pipeline +module 0x2::Token { + struct Coin has store { + type: AssetType, + value: u64, + } + public fun create(type: ATy, value: u64): Coin { + Coin{type: type,value: value} + } + public fun value(coin: &Coin): u64 { + coin.value + } + public fun deposit(coin: &mut Coin, check: Coin) { + let Coin{type: type,value: value} = check; + if (&coin.type == &type) () else abort 42; + coin.value = coin.value + value; + } + public fun destroy_zero(coin: Coin) { + let Coin{type: _,value: value} = coin; + if (value == 0) () else abort 11 + } + public fun join(xus: Coin, coin2: Coin): Coin { + deposit(&mut xus, coin2); + xus + } + public fun split(coin: Coin, amount: u64): (Coin, Coin) { + let other = withdraw(&mut coin, amount); + (coin, other) + } + public fun withdraw(coin: &mut Coin, amount: u64): Coin { + if (coin.value >= amount) () else abort 10; + coin.value = coin.value - amount; + Coin{type: *&coin.type,value: amount} + } +} +module 0x2::Map { + struct T has copy, drop, store { + } + public native fun empty(): T ; + public native fun remove(m: &T, k: &K): V ; + public native fun contains_key(m: &T, k: &K): bool ; + public native fun get(m: &T, k: &K): &V ; + public native fun get_mut(m: &mut T, k: &K): &mut V ; + public native fun insert(m: &T, k: K, v: V) ; +} +module 0x3::OneToOneMarket { + use 0x2::Token; + use 0x2::Map; + struct BorrowRecord has key { + record: Map::T, + } + struct DepositRecord has key { + record: Map::T, + } + struct Pool has key { + coin: Token::Coin, + } + struct Price has key { + price: u64, + } + public fun borrow(account: &signer, pool_owner: address, amount: u64): Token::Coin + acquires Priceacquires Poolacquires DepositRecordacquires BorrowRecord + { + if (amount <= max_borrow_amount(account, pool_owner)) () else abort 1025; + update_borrow_record(account, pool_owner, amount); + let pool = borrow_global_mut>(pool_owner); + Token::withdraw(&mut pool.coin, amount) + } + public fun deposit(account: &signer, pool_owner: address, coin: Token::Coin) + acquires Poolacquires DepositRecord + { + let amount = Token::value(&coin); + update_deposit_record(account, pool_owner, amount); + let pool = borrow_global_mut>(pool_owner); + Token::deposit(&mut pool.coin, coin) + } + fun accept(account: &signer, init: Token::Coin) { + let sender = 0x1::signer::address_of(account); + if (!exists>(sender)) () else abort 42; + move_to>(account, Pool{coin: init}) + } + fun borrowed_amount(account: &signer, pool_owner: address): u64 + acquires BorrowRecord + { + let sender = 0x1::signer::address_of(account); + if (!exists>(sender)) return 0; + let record = &borrow_global>(sender).record; + if (Map::contains_key(record, &pool_owner)) *Map::get(record, &pool_owner) else 0 + } + fun deposited_amount(account: &signer, pool_owner: address): u64 + acquires DepositRecord + { + let sender = 0x1::signer::address_of(account); + if (!exists>(sender)) return 0; + let record = &borrow_global>(sender).record; + if (Map::contains_key(record, &pool_owner)) *Map::get(record, &pool_owner) else 0 + } + fun max_borrow_amount(account: &signer, pool_owner: address): u64 + acquires Priceacquires Poolacquires DepositRecordacquires BorrowRecord + { + let input_deposited = deposited_amount(account, pool_owner); + let output_deposited = borrowed_amount(account, pool_owner); + let input_into_output = input_deposited * borrow_global>(pool_owner).price; + let max_output = if (input_into_output < output_deposited) 0 else input_into_output - output_deposited; + let available_output = { + let pool = borrow_global>(pool_owner); + Token::value(&pool.coin) + }; + if (max_output < available_output) max_output else available_output + } + public fun register_price(account: &signer, initial_in: Token::Coin, initial_out: Token::Coin, price: u64) { + accept(account, initial_in); + accept(account, initial_out); + move_to>(account, Price{price: price}) + } + fun update_borrow_record(account: &signer, pool_owner: address, amount: u64) + acquires BorrowRecord + { + let sender = 0x1::signer::address_of(account); + if (!exists>(sender)) move_to>(account, BorrowRecord{record: Map::empty()}); + let record = &mut borrow_global_mut>(sender).record; + if (Map::contains_key(/*freeze*/record, &pool_owner)) { + let old_amount = Map::remove(/*freeze*/record, &pool_owner); + amount = amount + old_amount; + }; + Map::insert(/*freeze*/record, pool_owner, amount) + } + fun update_deposit_record(account: &signer, pool_owner: address, amount: u64) + acquires DepositRecord + { + let sender = 0x1::signer::address_of(account); + if (!exists>(sender)) move_to>(account, DepositRecord{record: Map::empty()}); + let record = &mut borrow_global_mut>(sender).record; + if (Map::contains_key(/*freeze*/record, &pool_owner)) { + let old_amount = Map::remove(/*freeze*/record, &pool_owner); + amount = amount + old_amount; + }; + Map::insert(/*freeze*/record, pool_owner, amount) + } +} +module 0x70dd::ToddNickels { + use 0x2::Token; + struct T has copy, drop, store { + } + struct Wallet has key { + nickels: Token::Coin, + } + public fun init(account: &signer) { + if (0x1::signer::address_of(account) == 0x70dd) () else abort 42; + move_to(account, Wallet{nickels: Token::create(T{}, 0)}) + } + public fun destroy(c: Token::Coin) + acquires Wallet + { + Token::deposit(&mut borrow_global_mut(0x70dd).nickels, c) + } + public fun mint(account: &signer): Token::Coin { + if (0x1::signer::address_of(account) == 0x70dd) () else abort 42; + Token::create(T{}, 5) + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/v1-examples/simple_money_market_token.exp b/third_party/move/move-compiler-v2/tests/checking/typing/v1-examples/simple_money_market_token.exp index b2f8b5a64657b..fb55569ddefc7 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/v1-examples/simple_money_market_token.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/v1-examples/simple_money_market_token.exp @@ -4,25 +4,25 @@ module 0x2::Token { type: #0, value: u64, } - public fun create(type: #0,value: u64): Token::Coin<#0> { + public fun create(type: #0,value: u64): 0x2::Token::Coin<#0> { pack Token::Coin(type, value) } - public fun value(coin: &Token::Coin<#0>): u64 { - select Token::Coin.value<&Token::Coin>(coin) + public fun value(coin: &0x2::Token::Coin<#0>): u64 { + select Token::Coin.value<&Coin>(coin) } - public fun deposit(coin: &mut Token::Coin<#0>,check: Token::Coin<#0>) { + public fun deposit(coin: &mut 0x2::Token::Coin<#0>,check: 0x2::Token::Coin<#0>) { { let Token::Coin{ type, value } = check; - if Eq(Borrow(Immutable)(select Token::Coin.type<&mut Token::Coin>(coin)), Borrow(Immutable)(type)) { + if Eq(Borrow(Immutable)(select Token::Coin.type<&mut Coin>(coin)), Borrow(Immutable)(type)) { Tuple() } else { Abort(42) }; - select Token::Coin.value<&mut Token::Coin>(coin) = Add(select Token::Coin.value<&mut Token::Coin>(coin), value); + select Token::Coin.value<&mut Coin>(coin) = Add(select Token::Coin.value<&mut Coin>(coin), value); Tuple() } } - public fun destroy_zero(coin: Token::Coin<#0>) { + public fun destroy_zero(coin: 0x2::Token::Coin<#0>) { { let Token::Coin{ type: _, value } = coin; if Eq(value, 0) { @@ -32,24 +32,24 @@ module 0x2::Token { } } } - public fun join(xus: Token::Coin<#0>,coin2: Token::Coin<#0>): Token::Coin<#0> { + public fun join(xus: 0x2::Token::Coin<#0>,coin2: 0x2::Token::Coin<#0>): 0x2::Token::Coin<#0> { Token::deposit(Borrow(Mutable)(xus), coin2); xus } - public fun split(coin: Token::Coin<#0>,amount: u64): (Token::Coin<#0>, Token::Coin<#0>) { + public fun split(coin: 0x2::Token::Coin<#0>,amount: u64): (0x2::Token::Coin<#0>, 0x2::Token::Coin<#0>) { { - let other: Token::Coin = Token::withdraw(Borrow(Mutable)(coin), amount); + let other: Coin = Token::withdraw(Borrow(Mutable)(coin), amount); Tuple(coin, other) } } - public fun withdraw(coin: &mut Token::Coin<#0>,amount: u64): Token::Coin<#0> { - if Ge(select Token::Coin.value<&mut Token::Coin>(coin), amount) { + public fun withdraw(coin: &mut 0x2::Token::Coin<#0>,amount: u64): 0x2::Token::Coin<#0> { + if Ge(select Token::Coin.value<&mut Coin>(coin), amount) { Tuple() } else { Abort(10) }; - select Token::Coin.value<&mut Token::Coin>(coin) = Sub(select Token::Coin.value<&mut Token::Coin>(coin), amount); - pack Token::Coin(Deref(Borrow(Immutable)(select Token::Coin.type<&mut Token::Coin>(coin))), amount) + select Token::Coin.value<&mut Coin>(coin) = Sub(select Token::Coin.value<&mut Coin>(coin), amount); + pack Token::Coin(Deref(Borrow(Immutable)(select Token::Coin.type<&mut Coin>(coin))), amount) } } // end 0x2::Token module 0x70dd::ToddNickels { @@ -59,7 +59,7 @@ module 0x70dd::ToddNickels { dummy_field: bool, } struct Wallet { - nickels: Token::Coin, + nickels: 0x2::Token::Coin<0x70dd::ToddNickels::T>, } public fun init(account: &signer) { if Eq
(signer::address_of(account), 0x70dd) { @@ -67,20 +67,20 @@ module 0x70dd::ToddNickels { } else { Abort(42) }; - MoveTo(account, pack ToddNickels::Wallet(Token::create(pack ToddNickels::T(false), 0))) + MoveTo(account, pack ToddNickels::Wallet(Token::create(pack ToddNickels::T(false), 0))) } - public fun destroy(c: Token::Coin) - acquires ToddNickels::Wallet(*) + public fun destroy(c: 0x2::Token::Coin<0x70dd::ToddNickels::T>) + acquires 0x70dd::ToddNickels::Wallet(*) { - Token::deposit(Borrow(Mutable)(select ToddNickels::Wallet.nickels<&mut ToddNickels::Wallet>(BorrowGlobal(Mutable)(0x70dd))), c) + Token::deposit(Borrow(Mutable)(select ToddNickels::Wallet.nickels<&mut Wallet>(BorrowGlobal(Mutable)(0x70dd))), c) } - public fun mint(account: &signer): Token::Coin { + public fun mint(account: &signer): 0x2::Token::Coin<0x70dd::ToddNickels::T> { if Eq
(signer::address_of(account), 0x70dd) { Tuple() } else { Abort(42) }; - Token::create(pack ToddNickels::T(false), 5) + Token::create(pack ToddNickels::T(false), 5) } } // end 0x70dd::ToddNickels module 0xb055::OneToOneMarket { @@ -93,16 +93,16 @@ module 0xb055::OneToOneMarket { record: u64, } struct Pool { - coin: Token::Coin<#0>, + coin: 0x2::Token::Coin<#0>, } struct Price { price: u64, } - public fun borrow(account: &signer,amount: u64): Token::Coin<#1> - acquires OneToOneMarket::Price(*) - acquires OneToOneMarket::Pool(*) - acquires OneToOneMarket::DepositRecord(*) - acquires OneToOneMarket::BorrowRecord(*) + public fun borrow(account: &signer,amount: u64): 0x2::Token::Coin<#1> + acquires 0xb055::OneToOneMarket::Price(*) + acquires 0xb055::OneToOneMarket::Pool(*) + acquires 0xb055::OneToOneMarket::DepositRecord(*) + acquires 0xb055::OneToOneMarket::BorrowRecord(*) { if Le(amount, OneToOneMarket::max_borrow_amount(account)) { Tuple() @@ -111,72 +111,72 @@ module 0xb055::OneToOneMarket { }; OneToOneMarket::update_borrow_record(account, amount); { - let pool: &mut OneToOneMarket::Pool = BorrowGlobal(Mutable)>(0xb055); - Token::withdraw(Borrow(Mutable)(select OneToOneMarket::Pool.coin<&mut OneToOneMarket::Pool>(pool)), amount) + let pool: &mut Pool = BorrowGlobal(Mutable)>(0xb055); + Token::withdraw(Borrow(Mutable)(select OneToOneMarket::Pool.coin<&mut Pool>(pool)), amount) } } - public fun deposit(account: &signer,coin: Token::Coin<#0>) - acquires OneToOneMarket::Pool(*) - acquires OneToOneMarket::DepositRecord(*) + public fun deposit(account: &signer,coin: 0x2::Token::Coin<#0>) + acquires 0xb055::OneToOneMarket::Pool(*) + acquires 0xb055::OneToOneMarket::DepositRecord(*) { { let amount: u64 = Token::value(Borrow(Immutable)(coin)); OneToOneMarket::update_deposit_record(account, amount); { - let pool: &mut OneToOneMarket::Pool = BorrowGlobal(Mutable)>(0xb055); - Token::deposit(Borrow(Mutable)(select OneToOneMarket::Pool.coin<&mut OneToOneMarket::Pool>(pool)), coin) + let pool: &mut Pool = BorrowGlobal(Mutable)>(0xb055); + Token::deposit(Borrow(Mutable)(select OneToOneMarket::Pool.coin<&mut Pool>(pool)), coin) } } } - private fun accept(account: &signer,init: Token::Coin<#0>) { + private fun accept(account: &signer,init: 0x2::Token::Coin<#0>) { { let sender: address = signer::address_of(account); - if Not(exists>(sender)) { + if Not(exists>(sender)) { Tuple() } else { Abort(42) }; - MoveTo>(account, pack OneToOneMarket::Pool(init)) + MoveTo>(account, pack OneToOneMarket::Pool(init)) } } private fun borrowed_amount(account: &signer): u64 - acquires OneToOneMarket::BorrowRecord(*) + acquires 0xb055::OneToOneMarket::BorrowRecord(*) { { let sender: address = signer::address_of(account); - if Not(exists>(sender)) { + if Not(exists>(sender)) { return 0 } else { Tuple() }; - select OneToOneMarket::BorrowRecord.record<&OneToOneMarket::BorrowRecord>(BorrowGlobal(Immutable)>(sender)) + select OneToOneMarket::BorrowRecord.record<&BorrowRecord>(BorrowGlobal(Immutable)>(sender)) } } private fun deposited_amount(account: &signer): u64 - acquires OneToOneMarket::DepositRecord(*) + acquires 0xb055::OneToOneMarket::DepositRecord(*) { { let sender: address = signer::address_of(account); - if Not(exists>(sender)) { + if Not(exists>(sender)) { return 0 } else { Tuple() }; - select OneToOneMarket::DepositRecord.record<&OneToOneMarket::DepositRecord>(BorrowGlobal(Immutable)>(sender)) + select OneToOneMarket::DepositRecord.record<&DepositRecord>(BorrowGlobal(Immutable)>(sender)) } } private fun max_borrow_amount(account: &signer): u64 - acquires OneToOneMarket::Price(*) - acquires OneToOneMarket::Pool(*) - acquires OneToOneMarket::DepositRecord(*) - acquires OneToOneMarket::BorrowRecord(*) + acquires 0xb055::OneToOneMarket::Price(*) + acquires 0xb055::OneToOneMarket::Pool(*) + acquires 0xb055::OneToOneMarket::DepositRecord(*) + acquires 0xb055::OneToOneMarket::BorrowRecord(*) { { let input_deposited: u64 = OneToOneMarket::deposited_amount(account); { let output_deposited: u64 = OneToOneMarket::borrowed_amount(account); { - let input_into_output: u64 = Mul(input_deposited, select OneToOneMarket::Price.price<&OneToOneMarket::Price>(BorrowGlobal(Immutable)>(0xb055))); + let input_into_output: u64 = Mul(input_deposited, select OneToOneMarket::Price.price<&Price>(BorrowGlobal(Immutable)>(0xb055))); { let max_output: u64 = if Lt(input_into_output, output_deposited) { 0 @@ -185,8 +185,8 @@ module 0xb055::OneToOneMarket { }; { let available_output: u64 = { - let pool: &OneToOneMarket::Pool = BorrowGlobal(Immutable)>(0xb055); - Token::value(Borrow(Immutable)(select OneToOneMarket::Pool.coin<&OneToOneMarket::Pool>(pool))) + let pool: &Pool = BorrowGlobal(Immutable)>(0xb055); + Token::value(Borrow(Immutable)(select OneToOneMarket::Pool.coin<&Pool>(pool))) }; if Lt(max_output, available_output) { max_output @@ -199,7 +199,7 @@ module 0xb055::OneToOneMarket { } } } - public fun register_price(account: &signer,initial_in: Token::Coin<#0>,initial_out: Token::Coin<#1>,price: u64) { + public fun register_price(account: &signer,initial_in: 0x2::Token::Coin<#0>,initial_out: 0x2::Token::Coin<#1>,price: u64) { { let sender: address = signer::address_of(account); if Eq
(sender, 0xb055) { @@ -209,39 +209,182 @@ module 0xb055::OneToOneMarket { }; OneToOneMarket::accept(account, initial_in); OneToOneMarket::accept(account, initial_out); - MoveTo>(account, pack OneToOneMarket::Price(price)) + MoveTo>(account, pack OneToOneMarket::Price(price)) } } private fun update_borrow_record(account: &signer,amount: u64) - acquires OneToOneMarket::BorrowRecord(*) + acquires 0xb055::OneToOneMarket::BorrowRecord(*) { { let sender: address = signer::address_of(account); - if Not(exists>(sender)) { - MoveTo>(account, pack OneToOneMarket::BorrowRecord(0)) + if Not(exists>(sender)) { + MoveTo>(account, pack OneToOneMarket::BorrowRecord(0)) } else { Tuple() }; { - let record: &mut u64 = Borrow(Mutable)(select OneToOneMarket::BorrowRecord.record<&mut OneToOneMarket::BorrowRecord>(BorrowGlobal(Mutable)>(sender))); + let record: &mut u64 = Borrow(Mutable)(select OneToOneMarket::BorrowRecord.record<&mut BorrowRecord>(BorrowGlobal(Mutable)>(sender))); record = Add(Deref(record), amount) } } } private fun update_deposit_record(account: &signer,amount: u64) - acquires OneToOneMarket::DepositRecord(*) + acquires 0xb055::OneToOneMarket::DepositRecord(*) { { let sender: address = signer::address_of(account); - if Not(exists>(sender)) { - MoveTo>(account, pack OneToOneMarket::DepositRecord(0)) + if Not(exists>(sender)) { + MoveTo>(account, pack OneToOneMarket::DepositRecord(0)) } else { Tuple() }; { - let record: &mut u64 = Borrow(Mutable)(select OneToOneMarket::DepositRecord.record<&mut OneToOneMarket::DepositRecord>(BorrowGlobal(Mutable)>(sender))); + let record: &mut u64 = Borrow(Mutable)(select OneToOneMarket::DepositRecord.record<&mut DepositRecord>(BorrowGlobal(Mutable)>(sender))); record = Add(Deref(record), amount) } } } } // end 0xb055::OneToOneMarket + +// -- Sourcified model before bytecode pipeline +module 0x2::Token { + struct Coin has store { + type: AssetType, + value: u64, + } + public fun create(type: ATy, value: u64): Coin { + Coin{type: type,value: value} + } + public fun value(coin: &Coin): u64 { + coin.value + } + public fun deposit(coin: &mut Coin, check: Coin) { + let Coin{type: type,value: value} = check; + if (&coin.type == &type) () else abort 42; + coin.value = coin.value + value; + } + public fun destroy_zero(coin: Coin) { + let Coin{type: _,value: value} = coin; + if (value == 0) () else abort 11 + } + public fun join(xus: Coin, coin2: Coin): Coin { + deposit(&mut xus, coin2); + xus + } + public fun split(coin: Coin, amount: u64): (Coin, Coin) { + let other = withdraw(&mut coin, amount); + (coin, other) + } + public fun withdraw(coin: &mut Coin, amount: u64): Coin { + if (coin.value >= amount) () else abort 10; + coin.value = coin.value - amount; + Coin{type: *&coin.type,value: amount} + } +} +module 0x70dd::ToddNickels { + use 0x2::Token; + struct T has copy, drop, store { + } + struct Wallet has key { + nickels: Token::Coin, + } + public fun init(account: &signer) { + if (0x1::signer::address_of(account) == 0x70dd) () else abort 42; + move_to(account, Wallet{nickels: Token::create(T{}, 0)}) + } + public fun destroy(c: Token::Coin) + acquires Wallet + { + Token::deposit(&mut borrow_global_mut(0x70dd).nickels, c) + } + public fun mint(account: &signer): Token::Coin { + if (0x1::signer::address_of(account) == 0x70dd) () else abort 42; + Token::create(T{}, 5) + } +} +module 0xb055::OneToOneMarket { + use 0x2::Token; + struct BorrowRecord has key { + record: u64, + } + struct DepositRecord has key { + record: u64, + } + struct Pool has key { + coin: Token::Coin, + } + struct Price has key { + price: u64, + } + public fun borrow(account: &signer, amount: u64): Token::Coin + acquires Priceacquires Poolacquires DepositRecordacquires BorrowRecord + { + if (amount <= max_borrow_amount(account)) () else abort 1025; + update_borrow_record(account, amount); + let pool = borrow_global_mut>(0xb055); + Token::withdraw(&mut pool.coin, amount) + } + public fun deposit(account: &signer, coin: Token::Coin) + acquires Poolacquires DepositRecord + { + let amount = Token::value(&coin); + update_deposit_record(account, amount); + let pool = borrow_global_mut>(0xb055); + Token::deposit(&mut pool.coin, coin) + } + fun accept(account: &signer, init: Token::Coin) { + let sender = 0x1::signer::address_of(account); + if (!exists>(sender)) () else abort 42; + move_to>(account, Pool{coin: init}) + } + fun borrowed_amount(account: &signer): u64 + acquires BorrowRecord + { + let sender = 0x1::signer::address_of(account); + if (!exists>(sender)) return 0; + borrow_global>(sender).record + } + fun deposited_amount(account: &signer): u64 + acquires DepositRecord + { + let sender = 0x1::signer::address_of(account); + if (!exists>(sender)) return 0; + borrow_global>(sender).record + } + fun max_borrow_amount(account: &signer): u64 + acquires Priceacquires Poolacquires DepositRecordacquires BorrowRecord + { + let input_deposited = deposited_amount(account); + let output_deposited = borrowed_amount(account); + let input_into_output = input_deposited * borrow_global>(0xb055).price; + let max_output = if (input_into_output < output_deposited) 0 else input_into_output - output_deposited; + let available_output = { + let pool = borrow_global>(0xb055); + Token::value(&pool.coin) + }; + if (max_output < available_output) max_output else available_output + } + public fun register_price(account: &signer, initial_in: Token::Coin, initial_out: Token::Coin, price: u64) { + let sender = 0x1::signer::address_of(account); + if (sender == 0xb055) () else abort 42; + accept(account, initial_in); + accept(account, initial_out); + move_to>(account, Price{price: price}) + } + fun update_borrow_record(account: &signer, amount: u64) + acquires BorrowRecord + { + let sender = 0x1::signer::address_of(account); + if (!exists>(sender)) move_to>(account, BorrowRecord{record: 0}); + let record = &mut borrow_global_mut>(sender).record; + *record = *record + amount + } + fun update_deposit_record(account: &signer, amount: u64) + acquires DepositRecord + { + let sender = 0x1::signer::address_of(account); + if (!exists>(sender)) move_to>(account, DepositRecord{record: 0}); + let record = &mut borrow_global_mut>(sender).record; + *record = *record + amount + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/values.exp b/third_party/move/move-compiler-v2/tests/checking/typing/values.exp index 4b5bcacdedbcc..4946b50f1eaf6 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/values.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/values.exp @@ -9,3 +9,14 @@ module 0x8675309::M { Tuple() } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + fun t() { + 0x1; + 0; + 10000; + true; + false; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/vector_basic_cases.exp b/third_party/move/move-compiler-v2/tests/checking/typing/vector_basic_cases.exp index fd4c8a5d38bce..e06c3d6abf801 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/vector_basic_cases.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/vector_basic_cases.exp @@ -8,7 +8,7 @@ module 0x42::Test { [Number(0), Number(1), Number(2)]; [Number(0), Number(1), Number(2)]; [Address(Numerical(0000000000000000000000000000000000000000000000000000000000000000)), Address(Numerical(0000000000000000000000000000000000000000000000000000000000000001))]; - Vector(pack Test::X(false), pack Test::X(false)); + Vector(pack Test::X(false), pack Test::X(false)); Vector>(Vector
(), Vector
()); Vector>>(Vector>(Vector
(), Vector
()), Vector>()); Tuple() @@ -22,9 +22,36 @@ module 0x42::Test { [Number(0)]; [Number(0)]; [Address(Numerical(0000000000000000000000000000000000000000000000000000000000000000))]; - Vector(pack Test::X(false)); + Vector(pack Test::X(false)); Vector>(Vector
()); Vector>>(Vector>(Vector
())); Tuple() } } // end 0x42::Test + +// -- Sourcified model before bytecode pipeline +module 0x42::Test { + struct X has drop { + } + fun many() { + vector[0u8, 1u8, 2u8]; + vector[0, 1, 2]; + vector[0u128, 1u128, 2u128]; + vector[0x0, 0x1]; + vector[X{}, X{}]; + vector[vector[], vector[]]; + vector[vector[vector[], vector[]], vector[]]; + } + fun none() { + vector[]; + } + fun one() { + vector[0u8]; + vector[0]; + vector[0u128]; + vector[0x0]; + vector[X{}]; + vector[vector[]]; + vector[vector[vector[]]]; + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/while_body.exp b/third_party/move/move-compiler-v2/tests/checking/typing/while_body.exp index c71c0fe643d07..e2b63bd3fa16b 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/while_body.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/while_body.exp @@ -91,3 +91,22 @@ module 0x8675309::M { } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + fun t0(cond: bool) { + while (cond) (); + while (cond) (); + while (cond) (); + while (cond) { + 0; + }; + while (cond) if (cond) (); + while (cond) break; + while (cond) break; + while (cond) continue; + while (cond) continue; + while (cond) return (); + while (cond) while (cond) break + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/while_condition.exp b/third_party/move/move-compiler-v2/tests/checking/typing/while_condition.exp index a939866f306f8..039489df286e3 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/while_condition.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/while_condition.exp @@ -33,3 +33,15 @@ module 0x8675309::M { } } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + fun t0() { + while (true) (); + while (false) () + } + fun t1() { + while (true) (); + while (false) () + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/unused/local_var.exp b/third_party/move/move-compiler-v2/tests/checking/unused/local_var.exp index da933d7ffa6a1..4dd44d731fac7 100644 --- a/third_party/move/move-compiler-v2/tests/checking/unused/local_var.exp +++ b/third_party/move/move-compiler-v2/tests/checking/unused/local_var.exp @@ -4,3 +4,10 @@ module 0xc0ffee::m { 5 } } // end 0xc0ffee::m + +// -- Sourcified model before bytecode pipeline +module 0xc0ffee::m { + public fun test(): u64 { + 5 + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/unused/unused_enum.exp b/third_party/move/move-compiler-v2/tests/checking/unused/unused_enum.exp index 118953e1f7238..1905db1c3f9dc 100644 --- a/third_party/move/move-compiler-v2/tests/checking/unused/unused_enum.exp +++ b/third_party/move/move-compiler-v2/tests/checking/unused/unused_enum.exp @@ -4,10 +4,23 @@ module 0x42::enum_types { enum MessageHolder { Empty, Message { - message: string::String, + message: 0x1::string::String, } NewMessage { - message: string::String, + message: 0x1::string::String, } } } // end 0x42::enum_types + +// -- Sourcified model before bytecode pipeline +module 0x42::enum_types { + enum MessageHolder has drop, key { + Empty, + Message { + message: 0x1::string::String, + } + NewMessage { + message: 0x1::string::String, + } + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/variants/variants_allow_match_empty_block.exp b/third_party/move/move-compiler-v2/tests/checking/variants/variants_allow_match_empty_block.exp index 763597db69434..211d1c533310f 100644 --- a/third_party/move/move-compiler-v2/tests/checking/variants/variants_allow_match_empty_block.exp +++ b/third_party/move/move-compiler-v2/tests/checking/variants/variants_allow_match_empty_block.exp @@ -4,3 +4,9 @@ module 0x815::m { Tuple() } } // end 0x815::m + +// -- Sourcified model before bytecode pipeline +module 0x815::m { + fun match() { + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/variants/variants_allow_match_fun_1.exp b/third_party/move/move-compiler-v2/tests/checking/variants/variants_allow_match_fun_1.exp index 310eee4728c3c..649c566da4103 100644 --- a/third_party/move/move-compiler-v2/tests/checking/variants/variants_allow_match_fun_1.exp +++ b/third_party/move/move-compiler-v2/tests/checking/variants/variants_allow_match_fun_1.exp @@ -10,18 +10,41 @@ module 0x815::m { z: u32, } } - private fun caller(c: m::CommonFields): bool { + private fun caller(c: 0x815::m::CommonFields): bool { m::match(c) } - private fun match(c: m::CommonFields): bool { + private fun match(c: 0x815::m::CommonFields): bool { match (c) { m::CommonFields::Foo{ x, y: _ } => { Gt(x, 0) } - _: m::CommonFields => { + _: CommonFields => { false } } } } // end 0x815::m + +// -- Sourcified model before bytecode pipeline +module 0x815::m { + enum CommonFields { + Foo { + x: u64, + y: u8, + } + Bar { + x: u64, + z: u32, + } + } + fun caller(c: CommonFields): bool { + match(c) + } + fun match(c: CommonFields): bool { + match (c) { + CommonFields::Foo{x: x,y: _} => x > 0, + _ => false, + } + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/variants/variants_allow_match_fun_2.exp b/third_party/move/move-compiler-v2/tests/checking/variants/variants_allow_match_fun_2.exp index 4f144439aeab2..3c6136be07907 100644 --- a/third_party/move/move-compiler-v2/tests/checking/variants/variants_allow_match_fun_2.exp +++ b/third_party/move/move-compiler-v2/tests/checking/variants/variants_allow_match_fun_2.exp @@ -15,12 +15,12 @@ module 0x815::m { } private fun match(): bool { { - let c: m::CommonFields = pack m::CommonFields::Foo(0, 0); + let c: CommonFields = pack m::CommonFields::Foo(0, 0); match (c) { m::CommonFields::Foo{ x, y: _ } => { Gt(x, 0) } - _: m::CommonFields => { + _: CommonFields => { false } } @@ -28,3 +28,27 @@ module 0x815::m { } } } // end 0x815::m + +// -- Sourcified model before bytecode pipeline +module 0x815::m { + enum CommonFields { + Foo { + x: u64, + y: u8, + } + Bar { + x: u64, + z: u32, + } + } + fun caller(): bool { + match() + } + fun match(): bool { + let c = CommonFields::Foo{x: 0,y: 0u8}; + match (c) { + CommonFields::Foo{x: x,y: _} => x > 0, + _ => false, + } + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/variants/variants_allow_match_fun_3.exp b/third_party/move/move-compiler-v2/tests/checking/variants/variants_allow_match_fun_3.exp index fd62c81d4e4be..0dfccce0f9d65 100644 --- a/third_party/move/move-compiler-v2/tests/checking/variants/variants_allow_match_fun_3.exp +++ b/third_party/move/move-compiler-v2/tests/checking/variants/variants_allow_match_fun_3.exp @@ -10,18 +10,41 @@ module 0x815::m { z: u32, } } - private fun caller(c: m::CommonFields): bool { + private fun caller(c: 0x815::m::CommonFields): bool { And(m::match(c, 22), true) } - private fun match(c: m::CommonFields,t: u64): bool { + private fun match(c: 0x815::m::CommonFields,t: u64): bool { match (c) { m::CommonFields::Foo{ x, y: _ } => { Gt(x, t) } - _: m::CommonFields => { + _: CommonFields => { false } } } } // end 0x815::m + +// -- Sourcified model before bytecode pipeline +module 0x815::m { + enum CommonFields { + Foo { + x: u64, + y: u8, + } + Bar { + x: u64, + z: u32, + } + } + fun caller(c: CommonFields): bool { + match(c, 22) && true + } + fun match(c: CommonFields, t: u64): bool { + match (c) { + CommonFields::Foo{x: x,y: _} => x > t, + _ => false, + } + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/variants/variants_allow_match_var.exp b/third_party/move/move-compiler-v2/tests/checking/variants/variants_allow_match_var.exp index b9760d48fca83..175da89836607 100644 --- a/third_party/move/move-compiler-v2/tests/checking/variants/variants_allow_match_var.exp +++ b/third_party/move/move-compiler-v2/tests/checking/variants/variants_allow_match_var.exp @@ -10,7 +10,7 @@ module 0x815::m { z: u32, } } - private fun match(c: m::CommonFields,t: u64): bool { + private fun match(c: 0x815::m::CommonFields,t: u64): bool { match (c) { m::CommonFields::Foo{ x, y: _ } => { { @@ -18,10 +18,33 @@ module 0x815::m { match } } - _: m::CommonFields => { + _: CommonFields => { false } } } } // end 0x815::m + +// -- Sourcified model before bytecode pipeline +module 0x815::m { + enum CommonFields { + Foo { + x: u64, + y: u8, + } + Bar { + x: u64, + z: u32, + } + } + fun match(c: CommonFields, t: u64): bool { + match (c) { + CommonFields::Foo{x: x,y: _} => { + let match = x > t; + match + }, + _ => false, + } + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/variants/variants_constants.exp b/third_party/move/move-compiler-v2/tests/checking/variants/variants_constants.exp index 3dd980bb022e7..134c88e0ca58d 100644 --- a/third_party/move/move-compiler-v2/tests/checking/variants/variants_constants.exp +++ b/third_party/move/move-compiler-v2/tests/checking/variants/variants_constants.exp @@ -11,29 +11,29 @@ module 0x815::m { } private fun t0(): bool { { - let c: m::Color = pack m::Color::Red(); - Eq(select_variants m::Color.RGB.red(c), 1) + let c: Color = pack m::Color::Red(); + Eq(select_variants m::Color.RGB.red(c), 1) } } private fun t1(): bool { { - let c: m::Color = pack m::Color::Red(); - Eq(select_variants m::Color.RGB.red(c), 1) + let c: Color = pack m::Color::Red(); + Eq(select_variants m::Color.RGB.red(c), 1) } } private fun t2(): bool { { - let c: m::Color = pack m::Color::Blue(); - Eq(select_variants m::Color.RGB.red(c), 1) + let c: Color = pack m::Color::Blue(); + Eq(select_variants m::Color.RGB.red(c), 1) } } private fun t3(): bool { { - let c: m::Color = pack m::Color::Blue(); - Eq(select_variants m::Color.RGB.red(c), 1) + let c: Color = pack m::Color::Blue(); + Eq(select_variants m::Color.RGB.red(c), 1) } } - private fun t4(c: &m::Color) { + private fun t4(c: &0x815::m::Color) { match (c) { m::Color::Red => { Abort(1) @@ -46,6 +46,41 @@ module 0x815::m { } } // end 0x815::m +// -- Sourcified model before bytecode pipeline +module 0x815::m { + enum Color { + RGB { + red: u64, + green: u64, + blue: u64, + } + Red, + Blue, + } + fun t0(): bool { + let c = Color::Red{}; + c.RGB.red == 1 + } + fun t1(): bool { + let c = Color::Red{}; + c.RGB.red == 1 + } + fun t2(): bool { + let c = Color::Blue{}; + c.RGB.red == 1 + } + fun t3(): bool { + let c = Color::Blue{}; + c.RGB.red == 1 + } + fun t4(c: &Color) { + match (c) { + Color::Red{} => abort 1, + Color::Blue{} => abort 2, + } + } +} + Diagnostics: error: match not exhaustive diff --git a/third_party/move/move-compiler-v2/tests/checking/variants/variants_ok.exp b/third_party/move/move-compiler-v2/tests/checking/variants/variants_ok.exp index 94a7918c9b8f3..76f71fc84a256 100644 --- a/third_party/move/move-compiler-v2/tests/checking/variants/variants_ok.exp +++ b/third_party/move/move-compiler-v2/tests/checking/variants/variants_ok.exp @@ -32,7 +32,7 @@ module 0x815::m { other: u32, } } - private fun t1(self: m::Color): bool { + private fun t1(self: 0x815::m::Color): bool { match (self) { m::Color::RGB{ red, green, blue } => { Gt(Add(Add(red, green), blue), 0) @@ -46,7 +46,7 @@ module 0x815::m { } } - private fun t1_address_qualified(self: m::Color): bool { + private fun t1_address_qualified(self: 0x815::m::Color): bool { match (self) { m::Color::RGB{ red, green, blue } => { Gt(Add(Add(red, green), blue), 0) @@ -60,7 +60,7 @@ module 0x815::m { } } - private fun t1_field_named(self: m::Color): bool { + private fun t1_field_named(self: 0x815::m::Color): bool { match (self) { m::Color::RGB{ red: r, green: g, blue } => { Gt(Add(Add(r, g), blue), 0) @@ -74,7 +74,7 @@ module 0x815::m { } } - private fun t1_module_qualified(self: m::Color): bool { + private fun t1_module_qualified(self: 0x815::m::Color): bool { match (self) { m::Color::RGB{ red, green, blue } => { Gt(Add(Add(red, green), blue), 0) @@ -88,7 +88,7 @@ module 0x815::m { } } - private fun t1_uses_block(self: m::Color): bool { + private fun t1_uses_block(self: 0x815::m::Color): bool { match (self) { m::Color::RGB{ red, green, blue } => { Gt(Add(Add(red, green), blue), 0) @@ -102,7 +102,7 @@ module 0x815::m { } } - private fun t1_uses_block_no_comma(self: m::Color): bool { + private fun t1_uses_block_no_comma(self: 0x815::m::Color): bool { match (self) { m::Color::RGB{ red, green, blue } => { Gt(Add(Add(red, green), blue), 0) @@ -116,41 +116,41 @@ module 0x815::m { } } - private fun t2(self: m::Color): bool { + private fun t2(self: 0x815::m::Color): bool { match (self) { m::Color::RGB{ red, green, blue } => { Gt(Add(Add(red, green), blue), 0) } - _: m::Color => { + _: Color => { true } } } - private fun t3(self: m::Color): bool { + private fun t3(self: 0x815::m::Color): bool { match (Borrow(Immutable)(self)) { m::Color::RGB{ red, green, blue } => { Gt(Add(Add(Deref(red), Deref(green)), Deref(blue)), 0) } - _: &m::Color => { + _: &Color => { true } } } - private fun t4(self: m::Color): m::Color { + private fun t4(self: 0x815::m::Color): 0x815::m::Color { match (Borrow(Mutable)(self)) { m::Color::RGB{ red, green: _, blue: _ } => { red = 2 } - _: &mut m::Color => { + _: &mut Color => { Tuple() } } ; self } - private fun t5_freeze(self: m::Color): u64 { + private fun t5_freeze(self: 0x815::m::Color): u64 { { let x: u64 = 1; { @@ -161,7 +161,7 @@ module 0x815::m { m::Color::Blue => { Freeze(false)(Borrow(Mutable)(x)) } - _: &mut m::Color => { + _: &mut Color => { Freeze(false)(Borrow(Mutable)(x)) } } @@ -170,24 +170,24 @@ module 0x815::m { } } } - private fun t6_construct(self: m::Color): m::Color { + private fun t6_construct(self: 0x815::m::Color): 0x815::m::Color { match (self) { m::Color::RGB{ red, green, blue } => { pack m::Color::RGB(Add(red, 1), Sub(green, 1), blue) } - _: m::Color => { + _: Color => { self } } } - private fun t7_let_unpack(self: m::Color): u64 { + private fun t7_let_unpack(self: 0x815::m::Color): u64 { { let m::Color::RGB{ red, green, blue } = self; Add(Add(red, green), blue) } } - private fun t8_unqualified_variant(self: m::Color): bool { + private fun t8_unqualified_variant(self: 0x815::m::Color): bool { match (self) { m::Color::RGB{ red, green, blue } => { And(Neq(red, green), Neq(green, blue)) @@ -201,10 +201,139 @@ module 0x815::m { } } - private fun t9_common_field(self: m::CommonFields): u64 { - select_variants m::CommonFields.Foo.x|m::CommonFields.Bar.x(self) + private fun t9_common_field(self: 0x815::m::CommonFields): u64 { + select_variants m::CommonFields.Foo.x|m::CommonFields.Bar.x(self) } - private fun t9_common_field_ref(self: &m::CommonFields): &u64 { - Borrow(Immutable)(select_variants m::CommonFields.Foo.x|m::CommonFields.Bar.x<&m::CommonFields>(self)) + private fun t9_common_field_ref(self: &0x815::m::CommonFields): &u64 { + Borrow(Immutable)(select_variants m::CommonFields.Foo.x|m::CommonFields.Bar.x<&CommonFields>(self)) } } // end 0x815::m + +// -- Sourcified model before bytecode pipeline +module 0x815::m { + use 0x815::m; + enum Color { + RGB { + red: u64, + green: u64, + blue: u64, + } + Red, + Blue, + } + enum ColorUsesBlockNoComma { + RGB { + red: u64, + green: u64, + blue: u64, + } + Red, + Blue, + } + enum CommonFields { + Foo { + x: u64, + y: u8, + } + Bar { + x: u64, + z: u32, + } + Baz { + other: u32, + } + } + fun t1(self: Color): bool { + match (self) { + Color::RGB{red: red,green: green,blue: blue} => red + green + blue > 0, + Color::Red{} => true, + Color::Blue{} => false, + } + } + fun t1_address_qualified(self: Color): bool { + match (self) { + Color::RGB{red: red,green: green,blue: blue} => red + green + blue > 0, + Color::Red{} => true, + Color::Blue{} => false, + } + } + fun t1_field_named(self: Color): bool { + match (self) { + Color::RGB{red: r,green: g,blue: blue} => r + g + blue > 0, + Color::Red{} => true, + Color::Blue{} => false, + } + } + fun t1_module_qualified(self: Color): bool { + match (self) { + Color::RGB{red: red,green: green,blue: blue} => red + green + blue > 0, + Color::Red{} => true, + Color::Blue{} => false, + } + } + fun t1_uses_block(self: Color): bool { + match (self) { + Color::RGB{red: red,green: green,blue: blue} => red + green + blue > 0, + Color::Red{} => true, + Color::Blue{} => false, + } + } + fun t1_uses_block_no_comma(self: Color): bool { + match (self) { + Color::RGB{red: red,green: green,blue: blue} => red + green + blue > 0, + Color::Red{} => true, + Color::Blue{} => false, + } + } + fun t2(self: Color): bool { + match (self) { + Color::RGB{red: red,green: green,blue: blue} => red + green + blue > 0, + _ => true, + } + } + fun t3(self: Color): bool { + match (&self) { + Color::RGB{red: red,green: green,blue: blue} => *red + *green + *blue > 0, + _ => true, + } + } + fun t4(self: Color): Color { + match (&mut self) { + Color::RGB{red: red,green: _,blue: _} => *red = 2, + _ => (), + }; + self + } + fun t5_freeze(self: Color): u64 { + let x = 1; + let r = match (&mut self) { + Color::Red{} => &x, + Color::Blue{} => /*freeze*/&mut x, + _ => /*freeze*/&mut x, + }; + *r + } + fun t6_construct(self: Color): Color { + match (self) { + Color::RGB{red: red,green: green,blue: blue} => Color::RGB{red: red + 1,green: green - 1,blue: blue}, + _ => self, + } + } + fun t7_let_unpack(self: Color): u64 { + let Color::RGB{red: red,green: green,blue: blue} = self; + red + green + blue + } + fun t8_unqualified_variant(self: Color): bool { + match (self) { + Color::RGB{red: red,green: green,blue: blue} => red != green && green != blue, + Color::Red{} => true, + Color::Blue{} => false, + } + } + fun t9_common_field(self: CommonFields): u64 { + self.Foo.x + } + fun t9_common_field_ref(self: &CommonFields): &u64 { + &self.Foo.x + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/variants/variants_test_no_parenthesis_ok.exp b/third_party/move/move-compiler-v2/tests/checking/variants/variants_test_no_parenthesis_ok.exp index 2662bcbd649a7..ba51ed291cd60 100644 --- a/third_party/move/move-compiler-v2/tests/checking/variants/variants_test_no_parenthesis_ok.exp +++ b/third_party/move/move-compiler-v2/tests/checking/variants/variants_test_no_parenthesis_ok.exp @@ -17,19 +17,55 @@ module 0x815::m { 0: u64, } } - private fun test(c: m::Color): bool { + private fun test(c: 0x815::m::Color): bool { test_variants m::Color::Red|RGB(c) } - private fun test_fully_qualified(c: m::Color): bool { + private fun test_fully_qualified(c: 0x815::m::Color): bool { test_variants m::Color::Red(c) } - private fun test_generic(x: &m::Generic<#0>): bool { + private fun test_generic(x: &0x815::m::Generic<#0>): bool { test_variants m::Generic::Foo(x) } - private fun test_generic_qualified(x: &m::Generic<#0>): bool { + private fun test_generic_qualified(x: &0x815::m::Generic<#0>): bool { test_variants m::Generic::Foo(x) } - private fun test_qualified(c: m::Color): bool { + private fun test_qualified(c: 0x815::m::Color): bool { test_variants m::Color::Red|RGB(c) } } // end 0x815::m + +// -- Sourcified model before bytecode pipeline +module 0x815::m { + enum Color { + RGB { + red: u64, + green: u64, + blue: u64, + } + Red, + Blue, + } + enum Generic { + Foo { + 0: T, + } + Bar { + 0: u64, + } + } + fun test(c: Color): bool { + c is Red | RGB + } + fun test_fully_qualified(c: Color): bool { + c is Red + } + fun test_generic(x: &Generic): bool { + x is Foo + } + fun test_generic_qualified(x: &Generic): bool { + x is Foo + } + fun test_qualified(c: Color): bool { + c is Red | RGB + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/variants/variants_test_ok.exp b/third_party/move/move-compiler-v2/tests/checking/variants/variants_test_ok.exp index 2662bcbd649a7..ba51ed291cd60 100644 --- a/third_party/move/move-compiler-v2/tests/checking/variants/variants_test_ok.exp +++ b/third_party/move/move-compiler-v2/tests/checking/variants/variants_test_ok.exp @@ -17,19 +17,55 @@ module 0x815::m { 0: u64, } } - private fun test(c: m::Color): bool { + private fun test(c: 0x815::m::Color): bool { test_variants m::Color::Red|RGB(c) } - private fun test_fully_qualified(c: m::Color): bool { + private fun test_fully_qualified(c: 0x815::m::Color): bool { test_variants m::Color::Red(c) } - private fun test_generic(x: &m::Generic<#0>): bool { + private fun test_generic(x: &0x815::m::Generic<#0>): bool { test_variants m::Generic::Foo(x) } - private fun test_generic_qualified(x: &m::Generic<#0>): bool { + private fun test_generic_qualified(x: &0x815::m::Generic<#0>): bool { test_variants m::Generic::Foo(x) } - private fun test_qualified(c: m::Color): bool { + private fun test_qualified(c: 0x815::m::Color): bool { test_variants m::Color::Red|RGB(c) } } // end 0x815::m + +// -- Sourcified model before bytecode pipeline +module 0x815::m { + enum Color { + RGB { + red: u64, + green: u64, + blue: u64, + } + Red, + Blue, + } + enum Generic { + Foo { + 0: T, + } + Bar { + 0: u64, + } + } + fun test(c: Color): bool { + c is Red | RGB + } + fun test_fully_qualified(c: Color): bool { + c is Red + } + fun test_generic(x: &Generic): bool { + x is Foo + } + fun test_generic_qualified(x: &Generic): bool { + x is Foo + } + fun test_qualified(c: Color): bool { + c is Red | RGB + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/variants/variants_test_parse_ok2.exp b/third_party/move/move-compiler-v2/tests/checking/variants/variants_test_parse_ok2.exp index 0db60293cf7d3..ed7a8321e9ecc 100644 --- a/third_party/move/move-compiler-v2/tests/checking/variants/variants_test_parse_ok2.exp +++ b/third_party/move/move-compiler-v2/tests/checking/variants/variants_test_parse_ok2.exp @@ -9,7 +9,23 @@ module 0x815::m { Red, Blue, } - private fun test_red_or_rgb(c: m::Color): bool { + private fun test_red_or_rgb(c: 0x815::m::Color): bool { test_variants m::Color::Red(c) } } // end 0x815::m + +// -- Sourcified model before bytecode pipeline +module 0x815::m { + enum Color { + RGB { + red: u64, + green: u64, + blue: u64, + } + Red, + Blue, + } + fun test_red_or_rgb(c: Color): bool { + c is Red + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/visibility-checker/direct_visibility.exp b/third_party/move/move-compiler-v2/tests/checking/visibility-checker/direct_visibility.exp index 90e9da4323862..01606d3099264 100644 --- a/third_party/move/move-compiler-v2/tests/checking/visibility-checker/direct_visibility.exp +++ b/third_party/move/move-compiler-v2/tests/checking/visibility-checker/direct_visibility.exp @@ -20,3 +20,24 @@ module 0x815::c { Tuple() } } // end 0x815::c + +// -- Sourcified model before bytecode pipeline +module 0x815::b { + friend 0x815::c; + friend fun f() { + } +} +module 0x815::a { + friend 0x815::c; + friend fun f() { + } + friend fun g() { + } +} +module 0x815::c { + public fun f() { + 0x815::a::f(); + 0x815::a::g(); + 0x815::b::f(); + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/visibility-checker/module_call_visibility_friend.exp b/third_party/move/move-compiler-v2/tests/checking/visibility-checker/module_call_visibility_friend.exp index f3424d16dd504..46adaacca8b01 100644 --- a/third_party/move/move-compiler-v2/tests/checking/visibility-checker/module_call_visibility_friend.exp +++ b/third_party/move/move-compiler-v2/tests/checking/visibility-checker/module_call_visibility_friend.exp @@ -49,3 +49,51 @@ module 0x2::M { M::f_friend() } } // end 0x2::M + +// -- Sourcified model before bytecode pipeline +module 0x2::Y { + friend 0x2::M; + friend fun f_friend() { + } +} +module 0x2::X { + public fun f_public() { + } +} +module 0x2::M { + use 0x2::Y; + use 0x2::X; + friend fun f_friend() { + } + public fun f_public() { + } + friend fun f_friend_call_friend() { + Y::f_friend() + } + friend fun f_friend_call_public() { + X::f_public() + } + friend fun f_friend_call_self_friend() { + f_friend() + } + friend fun f_friend_call_self_private() { + f_private() + } + friend fun f_friend_call_self_public() { + f_public() + } + fun f_private() { + } + fun f_private_call_friend() { + Y::f_friend() + } + fun f_private_call_self_friend() { + f_friend() + } + public fun f_public_call_friend() { + Y::f_friend() + } + public fun f_public_call_self_friend() { + f_friend() + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/visibility-checker/parser_package_keyword.exp b/third_party/move/move-compiler-v2/tests/checking/visibility-checker/parser_package_keyword.exp index 89a30d8357d83..d40b04a4fe2dd 100644 --- a/third_party/move/move-compiler-v2/tests/checking/visibility-checker/parser_package_keyword.exp +++ b/third_party/move/move-compiler-v2/tests/checking/visibility-checker/parser_package_keyword.exp @@ -7,3 +7,11 @@ module 0x42::package { } } } // end 0x42::package + +// -- Sourcified model before bytecode pipeline +module 0x42::package { + friend fun package(package: u8): u8 { + let package = package + 1u8; + package + } +} diff --git a/third_party/move/move-compiler-v2/tests/control-flow-simplification/jump-label.on.exp b/third_party/move/move-compiler-v2/tests/control-flow-simplification/jump-label.on.exp index 450d583197d37..5ad35eeb9ecae 100644 --- a/third_party/move/move-compiler-v2/tests/control-flow-simplification/jump-label.on.exp +++ b/third_party/move/move-compiler-v2/tests/control-flow-simplification/jump-label.on.exp @@ -3,20 +3,20 @@ [variant baseline] fun test::test<#0>($t0: vector): #0 { var $t1: #0 - var $t2: string::String + var $t2: 0x1::string::String var $t3: bool - var $t4: string::String - var $t5: string::String + var $t4: 0x1::string::String + var $t5: 0x1::string::String var $t6: vector var $t7: bool var $t8: bool - var $t9: string::String - var $t10: string::String + var $t9: 0x1::string::String + var $t10: 0x1::string::String var $t11: vector var $t12: bool var $t13: bool - var $t14: string::String - var $t15: string::String + var $t14: 0x1::string::String + var $t15: 0x1::string::String var $t16: vector var $t17: bool var $t18: u64 @@ -75,8 +75,8 @@ fun test::baz<#0>($t0: vector): #0 { [variant baseline] -fun test::foo<#0>(): string::String { - var $t0: string::String [unused] +fun test::foo<#0>(): 0x1::string::String { + var $t0: 0x1::string::String [unused] var $t1: u64 0: $t1 := 0 1: abort($t1) diff --git a/third_party/move/move-compiler-v2/tests/copy-propagation/mut_refs_2.exp b/third_party/move/move-compiler-v2/tests/copy-propagation/mut_refs_2.exp index ef9bd20a5bed4..f5a73992e920b 100644 --- a/third_party/move/move-compiler-v2/tests/copy-propagation/mut_refs_2.exp +++ b/third_party/move/move-compiler-v2/tests/copy-propagation/mut_refs_2.exp @@ -1,30 +1,30 @@ ============ initial bytecode ================ [variant baseline] -fun m::test($t0: m::S): u64 { +fun m::test($t0: 0xc0ffee::m::S): u64 { var $t1: u64 - var $t2: m::S - var $t3: m::S + var $t2: 0xc0ffee::m::S + var $t3: 0xc0ffee::m::S var $t4: &mut u64 - var $t5: &mut m::S + var $t5: &mut 0xc0ffee::m::S var $t6: u64 - var $t7: &m::S + var $t7: &0xc0ffee::m::S var $t8: &u64 0: $t2 := infer($t0) 1: $t3 := infer($t2) 2: $t5 := borrow_local($t2) - 3: $t4 := borrow_field.a($t5) + 3: $t4 := borrow_field<0xc0ffee::m::S>.a($t5) 4: $t6 := 0 5: write_ref($t4, $t6) 6: $t7 := borrow_local($t3) - 7: $t8 := borrow_field.a($t7) + 7: $t8 := borrow_field<0xc0ffee::m::S>.a($t7) 8: $t1 := read_ref($t8) 9: return $t1 } Diagnostics: -error: local `p` of type `m::S` does not have the `copy` ability +error: local `p` of type `S` does not have the `copy` ability ┌─ tests/copy-propagation/mut_refs_2.move:10:17 │ 10 │ let q = p; @@ -32,13 +32,13 @@ error: local `p` of type `m::S` does not have the `copy` ability 11 │ let ref = &mut p.a; │ - used here -error: local `p` of type `m::S` does not have the `drop` ability +error: local `p` of type `S` does not have the `drop` ability ┌─ tests/copy-propagation/mut_refs_2.move:11:24 │ 11 │ let ref = &mut p.a; │ ^ still borrowed but will be implicitly dropped later since it is no longer used -error: local `q` of type `m::S` does not have the `drop` ability +error: local `q` of type `S` does not have the `drop` ability ┌─ tests/copy-propagation/mut_refs_2.move:13:9 │ 13 │ q.a diff --git a/third_party/move/move-compiler-v2/tests/copy-propagation/sequential_assign_struct.exp b/third_party/move/move-compiler-v2/tests/copy-propagation/sequential_assign_struct.exp index 4497f58bc7399..0b75ab964eac4 100644 --- a/third_party/move/move-compiler-v2/tests/copy-propagation/sequential_assign_struct.exp +++ b/third_party/move/move-compiler-v2/tests/copy-propagation/sequential_assign_struct.exp @@ -1,13 +1,13 @@ ============ initial bytecode ================ [variant baseline] -fun m::sequential($t0: m::Foo): m::Foo { - var $t1: m::Foo - var $t2: m::Foo - var $t3: m::Foo - var $t4: m::Foo - var $t5: m::Foo - var $t6: m::Foo +fun m::sequential($t0: 0xc0ffee::m::Foo): 0xc0ffee::m::Foo { + var $t1: 0xc0ffee::m::Foo + var $t2: 0xc0ffee::m::Foo + var $t3: 0xc0ffee::m::Foo + var $t4: 0xc0ffee::m::Foo + var $t5: 0xc0ffee::m::Foo + var $t6: 0xc0ffee::m::Foo 0: $t2 := infer($t0) 1: $t3 := infer($t2) 2: $t4 := infer($t3) @@ -20,13 +20,13 @@ fun m::sequential($t0: m::Foo): m::Foo { ============ after DeadStoreElimination: ================ [variant baseline] -fun m::sequential($t0: m::Foo): m::Foo { - var $t1: m::Foo - var $t2: m::Foo - var $t3: m::Foo - var $t4: m::Foo - var $t5: m::Foo - var $t6: m::Foo +fun m::sequential($t0: 0xc0ffee::m::Foo): 0xc0ffee::m::Foo { + var $t1: 0xc0ffee::m::Foo + var $t2: 0xc0ffee::m::Foo + var $t3: 0xc0ffee::m::Foo + var $t4: 0xc0ffee::m::Foo + var $t5: 0xc0ffee::m::Foo + var $t6: 0xc0ffee::m::Foo 0: $t2 := move($t0) 1: $t3 := move($t2) 2: $t4 := move($t3) diff --git a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/recursive_type_instantiation.exp b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/recursive_type_instantiation.exp index 2982749beb36a..fc66bb2fb5ef9 100644 --- a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/recursive_type_instantiation.exp +++ b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/recursive_type_instantiation.exp @@ -6,7 +6,7 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr 6 │ public fun simple_recursion() { │ ^^^^^^^^^^^^^^^^ │ - = `simple_recursion` calls `simple_recursion>` at tests/cyclic-instantiation-checker/recursive_type_instantiation.move:7 + = `simple_recursion` calls `simple_recursion>` at tests/cyclic-instantiation-checker/recursive_type_instantiation.move:7 error: cyclic type instantiation: a cycle of recursive calls causes a type to grow without bound ┌─ tests/cyclic-instantiation-checker/recursive_type_instantiation.move:10:9 @@ -15,7 +15,7 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr │ ^^^^^^^^^^^^^^^^^^^^^ │ = `two_level_recursion_0` calls `two_level_recursion_1` at tests/cyclic-instantiation-checker/recursive_type_instantiation.move:11 - = `two_level_recursion_1` calls `two_level_recursion_0>` at tests/cyclic-instantiation-checker/recursive_type_instantiation.move:15 + = `two_level_recursion_1` calls `two_level_recursion_0>` at tests/cyclic-instantiation-checker/recursive_type_instantiation.move:15 error: cyclic type instantiation: a cycle of recursive calls causes a type to grow without bound ┌─ tests/cyclic-instantiation-checker/recursive_type_instantiation.move:14:9 @@ -23,8 +23,8 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr 14 │ fun two_level_recursion_1() { │ ^^^^^^^^^^^^^^^^^^^^^ │ - = `two_level_recursion_1` calls `two_level_recursion_0>` at tests/cyclic-instantiation-checker/recursive_type_instantiation.move:15 - = `two_level_recursion_0>` calls `two_level_recursion_1>` at tests/cyclic-instantiation-checker/recursive_type_instantiation.move:11 + = `two_level_recursion_1` calls `two_level_recursion_0>` at tests/cyclic-instantiation-checker/recursive_type_instantiation.move:15 + = `two_level_recursion_0>` calls `two_level_recursion_1>` at tests/cyclic-instantiation-checker/recursive_type_instantiation.move:11 error: cyclic type instantiation: a cycle of recursive calls causes a type to grow without bound ┌─ tests/cyclic-instantiation-checker/recursive_type_instantiation.move:18:9 @@ -34,7 +34,7 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr │ = `three_level_recursion_0` calls `three_level_recursion_1` at tests/cyclic-instantiation-checker/recursive_type_instantiation.move:19 = `three_level_recursion_1` calls `three_level_recursion_2` at tests/cyclic-instantiation-checker/recursive_type_instantiation.move:23 - = `three_level_recursion_2` calls `three_level_recursion_0>` at tests/cyclic-instantiation-checker/recursive_type_instantiation.move:27 + = `three_level_recursion_2` calls `three_level_recursion_0>` at tests/cyclic-instantiation-checker/recursive_type_instantiation.move:27 error: cyclic type instantiation: a cycle of recursive calls causes a type to grow without bound ┌─ tests/cyclic-instantiation-checker/recursive_type_instantiation.move:22:9 @@ -43,8 +43,8 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr │ ^^^^^^^^^^^^^^^^^^^^^^^ │ = `three_level_recursion_1` calls `three_level_recursion_2` at tests/cyclic-instantiation-checker/recursive_type_instantiation.move:23 - = `three_level_recursion_2` calls `three_level_recursion_0>` at tests/cyclic-instantiation-checker/recursive_type_instantiation.move:27 - = `three_level_recursion_0>` calls `three_level_recursion_1>` at tests/cyclic-instantiation-checker/recursive_type_instantiation.move:19 + = `three_level_recursion_2` calls `three_level_recursion_0>` at tests/cyclic-instantiation-checker/recursive_type_instantiation.move:27 + = `three_level_recursion_0>` calls `three_level_recursion_1>` at tests/cyclic-instantiation-checker/recursive_type_instantiation.move:19 error: cyclic type instantiation: a cycle of recursive calls causes a type to grow without bound ┌─ tests/cyclic-instantiation-checker/recursive_type_instantiation.move:26:9 @@ -52,9 +52,9 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr 26 │ fun three_level_recursion_2() { │ ^^^^^^^^^^^^^^^^^^^^^^^ │ - = `three_level_recursion_2` calls `three_level_recursion_0>` at tests/cyclic-instantiation-checker/recursive_type_instantiation.move:27 - = `three_level_recursion_0>` calls `three_level_recursion_1>` at tests/cyclic-instantiation-checker/recursive_type_instantiation.move:19 - = `three_level_recursion_1>` calls `three_level_recursion_2>` at tests/cyclic-instantiation-checker/recursive_type_instantiation.move:23 + = `three_level_recursion_2` calls `three_level_recursion_0>` at tests/cyclic-instantiation-checker/recursive_type_instantiation.move:27 + = `three_level_recursion_0>` calls `three_level_recursion_1>` at tests/cyclic-instantiation-checker/recursive_type_instantiation.move:19 + = `three_level_recursion_1>` calls `three_level_recursion_2>` at tests/cyclic-instantiation-checker/recursive_type_instantiation.move:23 error: cyclic type instantiation: a cycle of recursive calls causes a type to grow without bound ┌─ tests/cyclic-instantiation-checker/recursive_type_instantiation.move:30:9 @@ -62,7 +62,7 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr 30 │ fun recurse_at_different_position() { │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ │ - = `recurse_at_different_position` calls `recurse_at_different_position>` at tests/cyclic-instantiation-checker/recursive_type_instantiation.move:31 + = `recurse_at_different_position` calls `recurse_at_different_position>` at tests/cyclic-instantiation-checker/recursive_type_instantiation.move:31 error: cyclic type instantiation: a cycle of recursive calls causes a type to grow without bound ┌─ tests/cyclic-instantiation-checker/recursive_type_instantiation.move:44:9 diff --git a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/complex_1.exp b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/complex_1.exp index 8ada1df6f41e8..1bb77ca0c249f 100644 --- a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/complex_1.exp +++ b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/complex_1.exp @@ -8,7 +8,7 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr │ = `c` calls `d` at tests/cyclic-instantiation-checker/v1-tests/complex_1.move:15 = `d` calls `b` at tests/cyclic-instantiation-checker/v1-tests/complex_1.move:20 - = `b` calls `c, bool>` at tests/cyclic-instantiation-checker/v1-tests/complex_1.move:10 + = `b` calls `c, bool>` at tests/cyclic-instantiation-checker/v1-tests/complex_1.move:10 error: cyclic type instantiation: a cycle of recursive calls causes a type to grow without bound ┌─ tests/cyclic-instantiation-checker/v1-tests/complex_1.move:26:9 @@ -17,7 +17,7 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr │ ^ │ = `f` calls `g` at tests/cyclic-instantiation-checker/v1-tests/complex_1.move:27 - = `g` calls `f>` at tests/cyclic-instantiation-checker/v1-tests/complex_1.move:31 + = `g` calls `f>` at tests/cyclic-instantiation-checker/v1-tests/complex_1.move:31 error: cyclic type instantiation: a cycle of recursive calls causes a type to grow without bound ┌─ tests/cyclic-instantiation-checker/v1-tests/complex_1.move:30:9 @@ -25,5 +25,5 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr 30 │ fun g() { │ ^ │ - = `g` calls `f>` at tests/cyclic-instantiation-checker/v1-tests/complex_1.move:31 - = `f>` calls `g>` at tests/cyclic-instantiation-checker/v1-tests/complex_1.move:27 + = `g` calls `f>` at tests/cyclic-instantiation-checker/v1-tests/complex_1.move:31 + = `f>` calls `g>` at tests/cyclic-instantiation-checker/v1-tests/complex_1.move:27 diff --git a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_just_type_params_ok.exp b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_just_type_params_ok.exp index 96b0d3038b3ec..331fad3cf4272 100644 --- a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_just_type_params_ok.exp +++ b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_just_type_params_ok.exp @@ -7,3 +7,13 @@ module 0x8675309::M { M::f() } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + fun f() { + g() + } + fun g() { + f() + } +} diff --git a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_non_generic_type_ok.exp b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_non_generic_type_ok.exp index 079ed8439d493..ee9f393b3f473 100644 --- a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_non_generic_type_ok.exp +++ b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_non_generic_type_ok.exp @@ -4,9 +4,22 @@ module 0x8675309::M { f: #0, } private fun f() { - M::g>() + M::g>() } private fun g() { M::f() } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct S { + f: T, + } + fun f() { + g>() + } + fun g() { + f() + } +} diff --git a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_just_type_params_shitfing_ok.exp b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_just_type_params_shitfing_ok.exp index f6b05b6205cce..d8a3df9022b92 100644 --- a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_just_type_params_shitfing_ok.exp +++ b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_just_type_params_shitfing_ok.exp @@ -10,3 +10,16 @@ module 0x8675309::M { M::f() } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + fun f() { + g() + } + fun g() { + h() + } + fun h() { + f() + } +} diff --git a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_non_generic_types_ok.exp b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_non_generic_types_ok.exp index 970a22f456bec..a4cbf1c179a07 100644 --- a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_non_generic_types_ok.exp +++ b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_non_generic_types_ok.exp @@ -7,8 +7,8 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr │ ^ │ = `f` calls `g` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_non_generic_types_ok.move:5 - = `g` calls `h>` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_non_generic_types_ok.move:9 - = `h>` calls `f>` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_non_generic_types_ok.move:14 + = `g` calls `h>` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_non_generic_types_ok.move:9 + = `h>` calls `f>` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_non_generic_types_ok.move:14 error: cyclic type instantiation: a cycle of recursive calls causes a type to grow without bound ┌─ tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_non_generic_types_ok.move:8:9 @@ -16,9 +16,9 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr 8 │ fun g() { │ ^ │ - = `g` calls `h>` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_non_generic_types_ok.move:9 - = `h>` calls `f>` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_non_generic_types_ok.move:14 - = `f>` calls `g, T1>` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_non_generic_types_ok.move:5 + = `g` calls `h>` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_non_generic_types_ok.move:9 + = `h>` calls `f>` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_non_generic_types_ok.move:14 + = `f>` calls `g, T1>` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_non_generic_types_ok.move:5 error: cyclic type instantiation: a cycle of recursive calls causes a type to grow without bound ┌─ tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_non_generic_types_ok.move:12:9 @@ -28,4 +28,4 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr │ = `h` calls `f` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_non_generic_types_ok.move:14 = `f` calls `g` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_non_generic_types_ok.move:5 - = `g` calls `h>` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_non_generic_types_ok.move:9 + = `g` calls `h>` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_non_generic_types_ok.move:9 diff --git a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_shifting.exp b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_shifting.exp index 4a656d29b6bec..db55cc263c7ba 100644 --- a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_shifting.exp +++ b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_shifting.exp @@ -7,8 +7,8 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr │ ^ │ = `f` calls `g` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_shifting.move:5 - = `g` calls `h>` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_shifting.move:9 - = `h>` calls `f>` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_shifting.move:13 + = `g` calls `h>` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_shifting.move:9 + = `h>` calls `f>` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_shifting.move:13 error: cyclic type instantiation: a cycle of recursive calls causes a type to grow without bound ┌─ tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_shifting.move:8:9 @@ -16,9 +16,9 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr 8 │ fun g() { │ ^ │ - = `g` calls `h>` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_shifting.move:9 - = `h>` calls `f>` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_shifting.move:13 - = `f>` calls `g, T1>` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_shifting.move:5 + = `g` calls `h>` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_shifting.move:9 + = `h>` calls `f>` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_shifting.move:13 + = `f>` calls `g, T1>` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_shifting.move:5 error: cyclic type instantiation: a cycle of recursive calls causes a type to grow without bound ┌─ tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_shifting.move:12:9 @@ -28,4 +28,4 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr │ = `h` calls `f` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_shifting.move:13 = `f` calls `g` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_shifting.move:5 - = `g` calls `h>` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_shifting.move:9 + = `g` calls `h>` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_three_args_type_con_shifting.move:9 diff --git a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_two_args_non_generic_type_and_type_param_ok.exp b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_two_args_non_generic_type_and_type_param_ok.exp index 2d82b3c7326e7..8fd13c702bc93 100644 --- a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_two_args_non_generic_type_and_type_param_ok.exp +++ b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_two_args_non_generic_type_and_type_param_ok.exp @@ -7,3 +7,13 @@ module 0x8675309::M { M::f() } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + fun f() { + g() + } + fun g() { + f() + } +} diff --git a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_two_args_swapping_just_type_params_ok.exp b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_two_args_swapping_just_type_params_ok.exp index 3033747e7d84a..0f757f0c9298b 100644 --- a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_two_args_swapping_just_type_params_ok.exp +++ b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_two_args_swapping_just_type_params_ok.exp @@ -9,3 +9,13 @@ module 0x8675309::M { Tuple() } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + fun f() { + g(); + } + fun g() { + f(); + } +} diff --git a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_two_args_swapping_type_con.exp b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_two_args_swapping_type_con.exp index 106f433858593..1066db9abfad9 100644 --- a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_two_args_swapping_type_con.exp +++ b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_two_args_swapping_type_con.exp @@ -7,7 +7,7 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr │ ^ │ = `f` calls `g` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_two_args_swapping_type_con.move:5 - = `g` calls `f, u64>` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_two_args_swapping_type_con.move:9 + = `g` calls `f, u64>` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_two_args_swapping_type_con.move:9 error: cyclic type instantiation: a cycle of recursive calls causes a type to grow without bound ┌─ tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_two_args_swapping_type_con.move:8:9 @@ -15,5 +15,5 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr 8 │ fun g() { │ ^ │ - = `g` calls `f, u64>` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_two_args_swapping_type_con.move:9 - = `f, u64>` calls `g, T1>` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_two_args_swapping_type_con.move:5 + = `g` calls `f, u64>` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_two_args_swapping_type_con.move:9 + = `f, u64>` calls `g, T1>` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_two_args_swapping_type_con.move:5 diff --git a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_type_con.exp b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_type_con.exp index 78f036b15c4b4..13dda3ae7a1ba 100644 --- a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_type_con.exp +++ b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_type_con.exp @@ -6,8 +6,8 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr 7 │ fun f() { │ ^ │ - = `f` calls `g>` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_type_con.move:8 - = `g>` calls `f>` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_type_con.move:12 + = `f` calls `g>` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_type_con.move:8 + = `g>` calls `f>` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_type_con.move:12 error: cyclic type instantiation: a cycle of recursive calls causes a type to grow without bound ┌─ tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_type_con.move:11:9 @@ -16,4 +16,4 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr │ ^ │ = `g` calls `f` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_type_con.move:12 - = `f` calls `g>` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_type_con.move:8 + = `f` calls `g>` at tests/cyclic-instantiation-checker/v1-tests/mutually_recursive_type_con.move:8 diff --git a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/nested_types_1.exp b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/nested_types_1.exp index d1798cea03482..4c7b9af8fd5e8 100644 --- a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/nested_types_1.exp +++ b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/nested_types_1.exp @@ -6,4 +6,4 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr 4 │ fun foo() { │ ^^^ │ - = `foo` calls `foo>>` at tests/cyclic-instantiation-checker/v1-tests/nested_types_1.move:5 + = `foo` calls `foo>>` at tests/cyclic-instantiation-checker/v1-tests/nested_types_1.move:5 diff --git a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/nested_types_2.exp b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/nested_types_2.exp index 53a1b6a0bfa1f..4b510f95aa137 100644 --- a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/nested_types_2.exp +++ b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/nested_types_2.exp @@ -6,4 +6,4 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr 5 │ fun foo() { │ ^^^ │ - = `foo` calls `foo>>>` at tests/cyclic-instantiation-checker/v1-tests/nested_types_2.move:6 + = `foo` calls `foo>>>` at tests/cyclic-instantiation-checker/v1-tests/nested_types_2.move:6 diff --git a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/recursive_infinite_type_terminates.exp b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/recursive_infinite_type_terminates.exp index 7fc325aa27a60..aa91ac66ecc19 100644 --- a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/recursive_infinite_type_terminates.exp +++ b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/recursive_infinite_type_terminates.exp @@ -6,4 +6,4 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr 9 │ fun f(n: u64, x: T): T { │ ^ │ - = `f` calls `f>` at tests/cyclic-instantiation-checker/v1-tests/recursive_infinite_type_terminates.move:11 + = `f` calls `f>` at tests/cyclic-instantiation-checker/v1-tests/recursive_infinite_type_terminates.move:11 diff --git a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/recursive_one_arg_just_type_params_ok.exp b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/recursive_one_arg_just_type_params_ok.exp index 3e04246fb2bb0..146f11afd9e7c 100644 --- a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/recursive_one_arg_just_type_params_ok.exp +++ b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/recursive_one_arg_just_type_params_ok.exp @@ -4,3 +4,10 @@ module 0x8675309::M { M::f(x) } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + public fun f(x: T) { + f(x) + } +} diff --git a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/recursive_one_arg_non_generic_type_ok.exp b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/recursive_one_arg_non_generic_type_ok.exp index f0921c5777493..cc5ac27ef18fa 100644 --- a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/recursive_one_arg_non_generic_type_ok.exp +++ b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/recursive_one_arg_non_generic_type_ok.exp @@ -4,3 +4,10 @@ module 0x8675309::M { M::f() } } // end 0x8675309::M + +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + fun f() { + f() + } +} diff --git a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/recursive_one_arg_type_con.exp b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/recursive_one_arg_type_con.exp index 189a74b48d385..e9041a1b05430 100644 --- a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/recursive_one_arg_type_con.exp +++ b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/recursive_one_arg_type_con.exp @@ -6,4 +6,4 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr 6 │ fun f(x: T) { │ ^ │ - = `f` calls `f>` at tests/cyclic-instantiation-checker/v1-tests/recursive_one_arg_type_con.move:7 + = `f` calls `f>` at tests/cyclic-instantiation-checker/v1-tests/recursive_one_arg_type_con.move:7 diff --git a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/recursive_two_args_swapping_type_con.exp b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/recursive_two_args_swapping_type_con.exp index e652867004204..4892af9de9b66 100644 --- a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/recursive_two_args_swapping_type_con.exp +++ b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/recursive_two_args_swapping_type_con.exp @@ -6,4 +6,4 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr 7 │ fun f(a: T1, x: T2) { │ ^ │ - = `f` calls `f, T1>` at tests/cyclic-instantiation-checker/v1-tests/recursive_two_args_swapping_type_con.move:8 + = `f` calls `f, T1>` at tests/cyclic-instantiation-checker/v1-tests/recursive_two_args_swapping_type_con.move:8 diff --git a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/two_loops.exp b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/two_loops.exp index 37fe8076ba422..ca960a47c8c83 100644 --- a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/two_loops.exp +++ b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-tests/two_loops.exp @@ -6,7 +6,7 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr 7 │ fun f() { │ ^ │ - = `f` calls `f>` at tests/cyclic-instantiation-checker/v1-tests/two_loops.move:8 + = `f` calls `f>` at tests/cyclic-instantiation-checker/v1-tests/two_loops.move:8 error: cyclic type instantiation: a cycle of recursive calls causes a type to grow without bound ┌─ tests/cyclic-instantiation-checker/v1-tests/two_loops.move:11:9 @@ -14,4 +14,4 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr 11 │ fun g() { │ ^ │ - = `g` calls `g>` at tests/cyclic-instantiation-checker/v1-tests/two_loops.move:12 + = `g` calls `g>` at tests/cyclic-instantiation-checker/v1-tests/two_loops.move:12 diff --git a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.exp b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.exp index 69f2b94f77c68..b5a0ebd9a7cd4 100644 --- a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.exp +++ b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.exp @@ -6,7 +6,7 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr 6 │ public fun t() { │ ^ │ - = `t` calls `t>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:7 + = `t` calls `t>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:7 error: cyclic type instantiation: a cycle of recursive calls causes a type to grow without bound ┌─ tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:10:16 @@ -14,8 +14,8 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr 10 │ public fun x() { │ ^ │ - = `x` calls `y>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:11 - = `y>` calls `x>>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:14 + = `x` calls `y>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:11 + = `y>` calls `x>>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:14 error: cyclic type instantiation: a cycle of recursive calls causes a type to grow without bound ┌─ tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:13:16 @@ -23,8 +23,8 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr 13 │ public fun y() { │ ^ │ - = `y` calls `x>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:14 - = `x>` calls `y>>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:11 + = `y` calls `x>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:14 + = `x>` calls `y>>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:11 error: cyclic type instantiation: a cycle of recursive calls causes a type to grow without bound ┌─ tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:17:16 @@ -34,7 +34,7 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr │ = `a` calls `b` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:18 = `b` calls `c` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:21 - = `c` calls `a>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:24 + = `c` calls `a>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:24 error: cyclic type instantiation: a cycle of recursive calls causes a type to grow without bound ┌─ tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:20:16 @@ -43,8 +43,8 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr │ ^ │ = `b` calls `c` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:21 - = `c` calls `a>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:24 - = `a>` calls `b>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:18 + = `c` calls `a>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:24 + = `a>` calls `b>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:18 error: cyclic type instantiation: a cycle of recursive calls causes a type to grow without bound ┌─ tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:23:16 @@ -52,9 +52,9 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr 23 │ public fun c() { │ ^ │ - = `c` calls `a>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:24 - = `a>` calls `b>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:18 - = `b>` calls `c>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:21 + = `c` calls `a>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:24 + = `a>` calls `b>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:18 + = `b>` calls `c>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:21 error: cyclic type instantiation: a cycle of recursive calls causes a type to grow without bound ┌─ tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:37:16 @@ -62,7 +62,7 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr 37 │ public fun z() { │ ^ │ - = `z` calls `z>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:38 + = `z` calls `z>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:38 error: cyclic type instantiation: a cycle of recursive calls causes a type to grow without bound ┌─ tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:41:16 @@ -72,8 +72,8 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr │ = `a` calls `b` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:42 = `b` calls `c` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:45 - = `c` calls `d>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:48 - = `d>` calls `a>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:51 + = `c` calls `d>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:48 + = `d>` calls `a>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:51 error: cyclic type instantiation: a cycle of recursive calls causes a type to grow without bound ┌─ tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:44:16 @@ -82,9 +82,9 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr │ ^ │ = `b` calls `c` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:45 - = `c` calls `d>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:48 - = `d>` calls `a>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:51 - = `a>` calls `b>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:42 + = `c` calls `d>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:48 + = `d>` calls `a>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:51 + = `a>` calls `b>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:42 error: cyclic type instantiation: a cycle of recursive calls causes a type to grow without bound ┌─ tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:47:16 @@ -92,10 +92,10 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr 47 │ public fun c() { │ ^ │ - = `c` calls `d>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:48 - = `d>` calls `a>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:51 - = `a>` calls `b>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:42 - = `b>` calls `c>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:45 + = `c` calls `d>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:48 + = `d>` calls `a>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:51 + = `a>` calls `b>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:42 + = `b>` calls `c>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:45 error: cyclic type instantiation: a cycle of recursive calls causes a type to grow without bound ┌─ tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:50:16 @@ -106,7 +106,7 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr = `d` calls `a` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:51 = `a` calls `b` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:42 = `b` calls `c` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:45 - = `c` calls `d>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:48 + = `c` calls `d>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:48 error: cyclic type instantiation: a cycle of recursive calls causes a type to grow without bound ┌─ tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:58:16 @@ -115,8 +115,8 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr │ ^^ │ = `tl` calls `tr` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:59 - = `tr` calls `bl>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:62 - = `bl>` calls `tl>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:69 + = `tr` calls `bl>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:62 + = `bl>` calls `tl>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:69 error: cyclic type instantiation: a cycle of recursive calls causes a type to grow without bound ┌─ tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:61:16 @@ -124,9 +124,9 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr 61 │ public fun tr() { │ ^^ │ - = `tr` calls `bl>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:62 - = `bl>` calls `tl>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:69 - = `tl>` calls `tr>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:59 + = `tr` calls `bl>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:62 + = `bl>` calls `tl>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:69 + = `tl>` calls `tr>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:59 error: cyclic type instantiation: a cycle of recursive calls causes a type to grow without bound ┌─ tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:68:16 @@ -136,4 +136,4 @@ error: cyclic type instantiation: a cycle of recursive calls causes a type to gr │ = `bl` calls `tl` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:69 = `tl` calls `tr` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:59 - = `tr` calls `bl>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:62 + = `tr` calls `bl>` at tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_invalid.move:62 diff --git a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_valid.exp b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_valid.exp index 01e7a4ee24a6a..d986f83593d1a 100644 --- a/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_valid.exp +++ b/third_party/move/move-compiler-v2/tests/cyclic-instantiation-checker/v1-typing/infinite_instantiations_valid.exp @@ -12,10 +12,10 @@ module 0x42::M { M::t1() } public fun x() { - M::y>() + M::y>() } public fun y() { - M::z>() + M::z>() } public fun z() { M::z() @@ -27,3 +27,33 @@ module 0x42::N { M::t0>() } } // end 0x42::N + +// -- Sourcified model before bytecode pipeline +module 0x42::M { + struct Box { + f: T, + } + public fun t0() { + t1(); + t0() + } + public fun t1() { + t0(); + t1() + } + public fun x() { + y>() + } + public fun y() { + z>() + } + public fun z() { + z() + } +} +module 0x42::N { + use 0x42::M; + public fun t() { + M::t0>() + } +} diff --git a/third_party/move/move-compiler-v2/tests/folding/constant_folding_addresses.exp b/third_party/move/move-compiler-v2/tests/folding/constant_folding_addresses.exp index 42c1f4eb0702c..1fdc7289870ba 100644 --- a/third_party/move/move-compiler-v2/tests/folding/constant_folding_addresses.exp +++ b/third_party/move/move-compiler-v2/tests/folding/constant_folding_addresses.exp @@ -8,5 +8,15 @@ module 0x8675309::M { } } // end 0x8675309::M +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + fun const_addr(): address { + 0x1234 + } + fun const_addr_let(): address { + 0x1234 + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/folding/constant_values.exp b/third_party/move/move-compiler-v2/tests/folding/constant_values.exp index 5ff1d119edddf..9a90765e9018a 100644 --- a/third_party/move/move-compiler-v2/tests/folding/constant_values.exp +++ b/third_party/move/move-compiler-v2/tests/folding/constant_values.exp @@ -20,5 +20,27 @@ module 0x8675309::M { } } // end 0x8675309::M +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + fun int128(): u128 { + 4u128 + } + fun int16(): u16 { + 123u16 + } + fun int256(): u256 { + 4u256 + } + fun int32(): u32 { + 137u32 + } + fun int64(): u64 { + 5 + } + fun int8(): u8 { + 1u8 + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/folding/empty_tvectors.exp b/third_party/move/move-compiler-v2/tests/folding/empty_tvectors.exp index 66bf0e6e4f6ad..51166063aa526 100644 --- a/third_party/move/move-compiler-v2/tests/folding/empty_tvectors.exp +++ b/third_party/move/move-compiler-v2/tests/folding/empty_tvectors.exp @@ -5,8 +5,8 @@ module 0x42::m { use std::vector; public entry fun init() { { - let _: vector = { - let result: vector = Vector(); + let _: vector<0x1::string::String> = { + let result: vector<0x1::string::String> = Vector<0x1::string::String>(); { let (v: vector>): (vector>) = Tuple([]); vector::reverse>(Borrow(Mutable)(v)); @@ -16,7 +16,7 @@ module 0x42::m { let e: vector = vector::pop_back>(Borrow(Mutable)(v)); { let (elem: vector): (vector) = Tuple(e); - vector::push_back(Borrow(Mutable)(result), { + vector::push_back<0x1::string::String>(Borrow(Mutable)(result), { let (key: vector): (vector) = Tuple(elem); string::utf8(key) }) @@ -64,5 +64,47 @@ module 0x42::m { } } // end 0x42::m +// -- Sourcified model before bytecode pipeline +module 0x42::m { + public entry fun init() { + let _ = { + let result = vector[]; + { + let (v) = (vector[]); + 0x1::vector::reverse>(&mut v); + while (!0x1::vector::is_empty>(&v)) { + let e = 0x1::vector::pop_back>(&mut v); + { + let (elem) = (e); + 0x1::vector::push_back<0x1::string::String>(&mut result, { + let (key) = (elem); + 0x1::string::utf8(key) + }) + }; + }; + }; + result + }; + let _ = { + let result = vector[]; + { + let (v) = (vector[]); + 0x1::vector::reverse(&mut v); + while (!0x1::vector::is_empty(&v)) { + let e = 0x1::vector::pop_back(&mut v); + { + let (elem) = (e); + 0x1::vector::push_back>(&mut result, { + let (v) = (elem); + 0x1::bcs::to_bytes(&v) + }) + }; + }; + }; + result + }; + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/folding/empty_vectors.exp b/third_party/move/move-compiler-v2/tests/folding/empty_vectors.exp index 2f4734fb55c28..3402cc93608e2 100644 --- a/third_party/move/move-compiler-v2/tests/folding/empty_vectors.exp +++ b/third_party/move/move-compiler-v2/tests/folding/empty_vectors.exp @@ -65,5 +65,48 @@ module 0x42::m { } } // end 0x42::m +// -- Sourcified model before bytecode pipeline +module 0x42::m { + public entry fun init() { + let _x = { + let result = vector[]; + { + let (v) = (vector[]); + 0x1::vector::reverse>(&mut v); + while (!0x1::vector::is_empty>(&v)) { + let e = 0x1::vector::pop_back>(&mut v); + { + let (elem) = (e); + 0x1::vector::push_back(&mut result, { + let (key) = (elem); + let t = key; + 0x1::vector::length(&t) + 2 + }) + }; + }; + }; + result + }; + let _y = { + let result = vector[]; + { + let (v) = (vector[]); + 0x1::vector::reverse(&mut v); + while (!0x1::vector::is_empty(&v)) { + let e = 0x1::vector::pop_back(&mut v); + { + let (elem) = (e); + 0x1::vector::push_back(&mut result, { + let (v) = (elem); + v + 3 + }) + }; + }; + }; + result + }; + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/folding/empty_vectors2.exp b/third_party/move/move-compiler-v2/tests/folding/empty_vectors2.exp index ba0862f8e2ead..6c622215906da 100644 --- a/third_party/move/move-compiler-v2/tests/folding/empty_vectors2.exp +++ b/third_party/move/move-compiler-v2/tests/folding/empty_vectors2.exp @@ -71,5 +71,50 @@ module 0x42::m { } } // end 0x42::m +// -- Sourcified model before bytecode pipeline +module 0x42::m { + public entry fun init() { + let _x = { + let (v) = (*0x1::vector::borrow>>(&vector[vector[]], 0)); + let result = vector[]; + { + let (v) = (v); + 0x1::vector::reverse>(&mut v); + while (!0x1::vector::is_empty>(&v)) { + let e = 0x1::vector::pop_back>(&mut v); + { + let (elem) = (e); + 0x1::vector::push_back(&mut result, { + let (key) = (elem); + let t = key; + 0x1::vector::length(&t) + 2 + }) + }; + }; + }; + result + }; + let _y = { + let (v) = (*0x1::vector::borrow>(&vector[vector[]], 0)); + let result = vector[]; + { + let (v) = (v); + 0x1::vector::reverse(&mut v); + while (!0x1::vector::is_empty(&v)) { + let e = 0x1::vector::pop_back(&mut v); + { + let (elem) = (e); + 0x1::vector::push_back(&mut result, { + let (v) = (elem); + v + 3 + }) + }; + }; + }; + result + }; + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/folding/non_constant_empty_vec.exp b/third_party/move/move-compiler-v2/tests/folding/non_constant_empty_vec.exp index 2a78724f1fe13..bbd2c0938bbce 100644 --- a/third_party/move/move-compiler-v2/tests/folding/non_constant_empty_vec.exp +++ b/third_party/move/move-compiler-v2/tests/folding/non_constant_empty_vec.exp @@ -15,13 +15,37 @@ module 0x42::M { public fun empty_signer_vec_vec(): vector> { Vector>() } - public fun empty_struct_vec(): vector { - Vector() + public fun empty_struct_vec(): vector<0x42::M::S> { + Vector() } - public fun empty_struct_vec_vec(): vector> { - Vector>() + public fun empty_struct_vec_vec(): vector> { + Vector>() } } // end 0x42::M +// -- Sourcified model before bytecode pipeline +module 0x42::M { + struct S { + } + public fun empty_generic_vec(): vector { + vector[] + } + public fun empty_generic_vec_vec(): vector> { + vector[] + } + public fun empty_signer_vec(): vector { + vector[] + } + public fun empty_signer_vec_vec(): vector> { + vector[] + } + public fun empty_struct_vec(): vector { + vector[] + } + public fun empty_struct_vec_vec(): vector> { + vector[] + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/folding/nonempty_tvectors.exp b/third_party/move/move-compiler-v2/tests/folding/nonempty_tvectors.exp index 7bf7030c145e4..f8822d3a0a187 100644 --- a/third_party/move/move-compiler-v2/tests/folding/nonempty_tvectors.exp +++ b/third_party/move/move-compiler-v2/tests/folding/nonempty_tvectors.exp @@ -5,8 +5,8 @@ module 0x42::m { use std::vector; public entry fun init() { { - let _: vector = { - let result: vector = Vector(); + let _: vector<0x1::string::String> = { + let result: vector<0x1::string::String> = Vector<0x1::string::String>(); { let (v: vector>): (vector>) = Tuple([Vector([Number(3)])]); vector::reverse>(Borrow(Mutable)(v)); @@ -16,7 +16,7 @@ module 0x42::m { let e: vector = vector::pop_back>(Borrow(Mutable)(v)); { let (elem: vector): (vector) = Tuple(e); - vector::push_back(Borrow(Mutable)(result), { + vector::push_back<0x1::string::String>(Borrow(Mutable)(result), { let (key: vector): (vector) = Tuple(elem); string::utf8(key) }) @@ -64,5 +64,47 @@ module 0x42::m { } } // end 0x42::m +// -- Sourcified model before bytecode pipeline +module 0x42::m { + public entry fun init() { + let _ = { + let result = vector[]; + { + let (v) = (vector[vector[3u8]]); + 0x1::vector::reverse>(&mut v); + while (!0x1::vector::is_empty>(&v)) { + let e = 0x1::vector::pop_back>(&mut v); + { + let (elem) = (e); + 0x1::vector::push_back<0x1::string::String>(&mut result, { + let (key) = (elem); + 0x1::string::utf8(key) + }) + }; + }; + }; + result + }; + let _ = { + let result = vector[]; + { + let (v) = (vector[3]); + 0x1::vector::reverse(&mut v); + while (!0x1::vector::is_empty(&v)) { + let e = 0x1::vector::pop_back(&mut v); + { + let (elem) = (e); + 0x1::vector::push_back>(&mut result, { + let (v) = (elem); + 0x1::bcs::to_bytes(&v) + }) + }; + }; + }; + result + }; + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/folding/nonempty_vectors.exp b/third_party/move/move-compiler-v2/tests/folding/nonempty_vectors.exp index 396a5f522928b..9c4bc6ee25968 100644 --- a/third_party/move/move-compiler-v2/tests/folding/nonempty_vectors.exp +++ b/third_party/move/move-compiler-v2/tests/folding/nonempty_vectors.exp @@ -65,5 +65,48 @@ module 0x42::m { } } // end 0x42::m +// -- Sourcified model before bytecode pipeline +module 0x42::m { + public entry fun init() { + let _x = { + let result = vector[]; + { + let (v) = (vector[vector[1u8]]); + 0x1::vector::reverse>(&mut v); + while (!0x1::vector::is_empty>(&v)) { + let e = 0x1::vector::pop_back>(&mut v); + { + let (elem) = (e); + 0x1::vector::push_back(&mut result, { + let (key) = (elem); + let t = key; + 0x1::vector::length(&t) + 2 + }) + }; + }; + }; + result + }; + let _y = { + let result = vector[]; + { + let (v) = (vector[3]); + 0x1::vector::reverse(&mut v); + while (!0x1::vector::is_empty(&v)) { + let e = 0x1::vector::pop_back(&mut v); + { + let (elem) = (e); + 0x1::vector::push_back(&mut result, { + let (v) = (elem); + v + 3 + }) + }; + }; + }; + result + }; + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/lambda-lifting/pattern.exp b/third_party/move/move-compiler-v2/tests/lambda-lifting/pattern.exp index c61dde92a484d..d4b2a8af34dae 100644 --- a/third_party/move/move-compiler-v2/tests/lambda-lifting/pattern.exp +++ b/third_party/move/move-compiler-v2/tests/lambda-lifting/pattern.exp @@ -3,11 +3,11 @@ module 0xcafe::m { struct S { x: #0, } - private fun consume(s: m::S<#0>,x: #0,f: |(m::S<#0>, #0)|#0): #0 { + private fun consume(s: 0xcafe::m::S<#0>,x: #0,f: |(0xcafe::m::S<#0>, #0)|#0): #0 { (f)(s, x) } - private fun pattern(s: m::S,x: u64): u64 { - m::consume(s, x, |(m::S{ x }, _y: u64): (m::S, u64)| { + private fun pattern(s: 0xcafe::m::S,x: u64): u64 { + m::consume(s, x, |(m::S{ x }, _y: u64): (S, u64)| { let y: u64 = x; Add(x, y) }) @@ -20,13 +20,13 @@ module 0xcafe::m { struct S { x: #0, } - private fun consume(s: m::S<#0>,x: #0,f: |(m::S<#0>, #0)|#0): #0 { + private fun consume(s: 0xcafe::m::S<#0>,x: #0,f: |(0xcafe::m::S<#0>, #0)|#0): #0 { (f)(s, x) } - private fun pattern(s: m::S,x: u64): u64 { + private fun pattern(s: 0xcafe::m::S,x: u64): u64 { m::consume(s, x, closure m::pattern$lambda$1()) } - private fun pattern$lambda$1(param$0: m::S,_y: u64): u64 { + private fun pattern$lambda$1(param$0: 0xcafe::m::S,_y: u64): u64 { { let m::S{ x } = param$0; { diff --git a/third_party/move/move-compiler-v2/tests/live-var/mut_ref.exp b/third_party/move/move-compiler-v2/tests/live-var/mut_ref.exp index 9e5ec15c0ef21..b2dabe6d743a4 100644 --- a/third_party/move/move-compiler-v2/tests/live-var/mut_ref.exp +++ b/third_party/move/move-compiler-v2/tests/live-var/mut_ref.exp @@ -2,11 +2,11 @@ [variant baseline] fun m::f1_ok() { - var $t0: m::R + var $t0: 0x42::m::R var $t1: u64 - var $t2: &mut m::R + var $t2: &mut 0x42::m::R 0: $t1 := 0 - 1: $t0 := pack m::R($t1) + 1: $t0 := pack 0x42::m::R($t1) 2: $t2 := borrow_local($t0) 3: m::some($t2) 4: m::some($t2) @@ -16,12 +16,12 @@ fun m::f1_ok() { [variant baseline] fun m::f1a_ok() { - var $t0: m::R + var $t0: 0x42::m::R var $t1: u64 - var $t2: &mut m::R - var $t3: m::R + var $t2: &mut 0x42::m::R + var $t3: 0x42::m::R 0: $t1 := 0 - 1: $t0 := pack m::R($t1) + 1: $t0 := pack 0x42::m::R($t1) 2: $t2 := borrow_local($t0) 3: $t3 := read_ref($t2) 4: m::some($t2) @@ -32,12 +32,12 @@ fun m::f1a_ok() { [variant baseline] fun m::f1b_ok() { - var $t0: m::R + var $t0: 0x42::m::R var $t1: u64 - var $t2: &mut m::R - var $t3: m::R + var $t2: &mut 0x42::m::R + var $t3: 0x42::m::R 0: $t1 := 0 - 1: $t0 := pack m::R($t1) + 1: $t0 := pack 0x42::m::R($t1) 2: $t2 := borrow_local($t0) 3: m::some($t2) 4: $t3 := read_ref($t2) @@ -48,11 +48,11 @@ fun m::f1b_ok() { [variant baseline] fun m::f2_fail() { - var $t0: m::R + var $t0: 0x42::m::R var $t1: u64 - var $t2: &mut m::R + var $t2: &mut 0x42::m::R 0: $t1 := 0 - 1: $t0 := pack m::R($t1) + 1: $t0 := pack 0x42::m::R($t1) 2: $t2 := borrow_local($t0) 3: m::some2($t2, $t2) 4: return () @@ -61,12 +61,12 @@ fun m::f2_fail() { [variant baseline] fun m::f3_ok() { - var $t0: m::R + var $t0: 0x42::m::R var $t1: u64 - var $t2: &mut m::R - var $t3: &mut m::R + var $t2: &mut 0x42::m::R + var $t3: &mut 0x42::m::R 0: $t1 := 0 - 1: $t0 := pack m::R($t1) + 1: $t0 := pack 0x42::m::R($t1) 2: $t2 := borrow_local($t0) 3: m::some($t2) 4: $t3 := borrow_local($t0) @@ -78,12 +78,12 @@ fun m::f3_ok() { [variant baseline] fun m::f4_ok() { - var $t0: m::R + var $t0: 0x42::m::R var $t1: u64 - var $t2: &mut m::R - var $t3: &mut m::R + var $t2: &mut 0x42::m::R + var $t3: &mut 0x42::m::R 0: $t1 := 0 - 1: $t0 := pack m::R($t1) + 1: $t0 := pack 0x42::m::R($t1) 2: $t2 := borrow_local($t0) 3: $t3 := m::id($t2) 4: $t2 := infer($t3) @@ -94,12 +94,12 @@ fun m::f4_ok() { [variant baseline] fun m::f5_fail($t0: bool) { - var $t1: m::R + var $t1: 0x42::m::R var $t2: u64 - var $t3: &mut m::R - var $t4: &mut m::R + var $t3: &mut 0x42::m::R + var $t4: &mut 0x42::m::R 0: $t2 := 0 - 1: $t1 := pack m::R($t2) + 1: $t1 := pack 0x42::m::R($t2) 2: $t3 := borrow_local($t1) 3: $t4 := infer($t3) 4: if ($t0) goto 5 else goto 9 @@ -116,21 +116,21 @@ fun m::f5_fail($t0: bool) { [variant baseline] -fun m::id($t0: &mut m::R): &mut m::R { - var $t1: &mut m::R +fun m::id($t0: &mut 0x42::m::R): &mut 0x42::m::R { + var $t1: &mut 0x42::m::R 0: $t1 := infer($t0) 1: return $t1 } [variant baseline] -fun m::some($t0: &mut m::R) { +fun m::some($t0: &mut 0x42::m::R) { 0: return () } [variant baseline] -fun m::some2($t0: &mut m::R, $t1: &mut m::R) { +fun m::some2($t0: &mut 0x42::m::R, $t1: &mut 0x42::m::R) { 0: return () } @@ -138,13 +138,13 @@ fun m::some2($t0: &mut m::R, $t1: &mut m::R) { [variant baseline] fun m::f1_ok() { - var $t0: m::R + var $t0: 0x42::m::R var $t1: u64 - var $t2: &mut m::R + var $t2: &mut 0x42::m::R # live vars: 0: $t1 := 0 # live vars: $t1 - 1: $t0 := pack m::R($t1) + 1: $t0 := pack 0x42::m::R($t1) # live vars: $t0 2: $t2 := borrow_local($t0) # live vars: $t2 @@ -158,14 +158,14 @@ fun m::f1_ok() { [variant baseline] fun m::f1a_ok() { - var $t0: m::R + var $t0: 0x42::m::R var $t1: u64 - var $t2: &mut m::R - var $t3: m::R + var $t2: &mut 0x42::m::R + var $t3: 0x42::m::R # live vars: 0: $t1 := 0 # live vars: $t1 - 1: $t0 := pack m::R($t1) + 1: $t0 := pack 0x42::m::R($t1) # live vars: $t0 2: $t2 := borrow_local($t0) # live vars: $t2 @@ -181,14 +181,14 @@ fun m::f1a_ok() { [variant baseline] fun m::f1b_ok() { - var $t0: m::R + var $t0: 0x42::m::R var $t1: u64 - var $t2: &mut m::R - var $t3: m::R + var $t2: &mut 0x42::m::R + var $t3: 0x42::m::R # live vars: 0: $t1 := 0 # live vars: $t1 - 1: $t0 := pack m::R($t1) + 1: $t0 := pack 0x42::m::R($t1) # live vars: $t0 2: $t2 := borrow_local($t0) # live vars: $t2 @@ -204,13 +204,13 @@ fun m::f1b_ok() { [variant baseline] fun m::f2_fail() { - var $t0: m::R + var $t0: 0x42::m::R var $t1: u64 - var $t2: &mut m::R + var $t2: &mut 0x42::m::R # live vars: 0: $t1 := 0 # live vars: $t1 - 1: $t0 := pack m::R($t1) + 1: $t0 := pack 0x42::m::R($t1) # live vars: $t0 2: $t2 := borrow_local($t0) # live vars: $t2 @@ -222,14 +222,14 @@ fun m::f2_fail() { [variant baseline] fun m::f3_ok() { - var $t0: m::R + var $t0: 0x42::m::R var $t1: u64 - var $t2: &mut m::R - var $t3: &mut m::R + var $t2: &mut 0x42::m::R + var $t3: &mut 0x42::m::R # live vars: 0: $t1 := 0 # live vars: $t1 - 1: $t0 := pack m::R($t1) + 1: $t0 := pack 0x42::m::R($t1) # live vars: $t0 2: $t2 := borrow_local($t0) # live vars: $t0, $t2 @@ -247,14 +247,14 @@ fun m::f3_ok() { [variant baseline] fun m::f4_ok() { - var $t0: m::R + var $t0: 0x42::m::R var $t1: u64 - var $t2: &mut m::R - var $t3: &mut m::R + var $t2: &mut 0x42::m::R + var $t3: &mut 0x42::m::R # live vars: 0: $t1 := 0 # live vars: $t1 - 1: $t0 := pack m::R($t1) + 1: $t0 := pack 0x42::m::R($t1) # live vars: $t0 2: $t2 := borrow_local($t0) # live vars: $t2 @@ -270,14 +270,14 @@ fun m::f4_ok() { [variant baseline] fun m::f5_fail($t0: bool) { - var $t1: m::R + var $t1: 0x42::m::R var $t2: u64 - var $t3: &mut m::R - var $t4: &mut m::R + var $t3: &mut 0x42::m::R + var $t4: &mut 0x42::m::R # live vars: $t0 0: $t2 := 0 # live vars: $t0, $t2 - 1: $t1 := pack m::R($t2) + 1: $t1 := pack 0x42::m::R($t2) # live vars: $t0, $t1 2: $t3 := borrow_local($t1) # live vars: $t0, $t3 @@ -306,8 +306,8 @@ fun m::f5_fail($t0: bool) { [variant baseline] -fun m::id($t0: &mut m::R): &mut m::R { - var $t1: &mut m::R +fun m::id($t0: &mut 0x42::m::R): &mut 0x42::m::R { + var $t1: &mut 0x42::m::R # live vars: $t0 0: $t1 := infer($t0) # live vars: $t1 @@ -316,14 +316,14 @@ fun m::id($t0: &mut m::R): &mut m::R { [variant baseline] -fun m::some($t0: &mut m::R) { +fun m::some($t0: &mut 0x42::m::R) { # live vars: $t0 0: return () } [variant baseline] -fun m::some2($t0: &mut m::R, $t1: &mut m::R) { +fun m::some2($t0: &mut 0x42::m::R, $t1: &mut 0x42::m::R) { # live vars: $t0, $t1 0: return () } diff --git a/third_party/move/move-compiler-v2/tests/more-v1/liveness/mut_ref2.exp b/third_party/move/move-compiler-v2/tests/more-v1/liveness/mut_ref2.exp index 9d2cce8b6b8c3..5549335eb8a0c 100644 --- a/third_party/move/move-compiler-v2/tests/more-v1/liveness/mut_ref2.exp +++ b/third_party/move/move-compiler-v2/tests/more-v1/liveness/mut_ref2.exp @@ -1,54 +1,54 @@ Diagnostics: -error: local `r` of type `m::R` does not have the `drop` ability +error: local `r` of type `R` does not have the `drop` ability ┌─ tests/more-v1/liveness/mut_ref2.move:15:17 │ 15 │ let x = &mut r; │ ^^^^^^ still borrowed but will be implicitly dropped later since it is no longer used -error: local `r` of type `m::R` does not have the `drop` ability +error: local `r` of type `R` does not have the `drop` ability ┌─ tests/more-v1/liveness/mut_ref2.move:23:17 │ 23 │ let x = &mut r; │ ^^^^^^ still borrowed but will be implicitly dropped later since it is no longer used -error: local `x` of type `m::R` does not have the `copy` ability +error: local `x` of type `R` does not have the `copy` ability ┌─ tests/more-v1/liveness/mut_ref2.move:24:9 │ 24 │ *x; // Expected ok because x is only read; ability analysis will check whether read is ok │ ^^ reference content copied here -error: value of type `m::R` does not have the `drop` ability +error: value of type `R` does not have the `drop` ability ┌─ tests/more-v1/liveness/mut_ref2.move:24:9 │ 24 │ *x; // Expected ok because x is only read; ability analysis will check whether read is ok │ ^^ implicitly dropped here since it is no longer used -error: local `r` of type `m::R` does not have the `drop` ability +error: local `r` of type `R` does not have the `drop` ability ┌─ tests/more-v1/liveness/mut_ref2.move:31:17 │ 31 │ let x = &mut r; │ ^^^^^^ still borrowed but will be implicitly dropped later since it is no longer used -error: local `x` of type `m::R` does not have the `copy` ability +error: local `x` of type `R` does not have the `copy` ability ┌─ tests/more-v1/liveness/mut_ref2.move:33:9 │ 33 │ *x; // Same as f1aok │ ^^ reference content copied here -error: value of type `m::R` does not have the `drop` ability +error: value of type `R` does not have the `drop` ability ┌─ tests/more-v1/liveness/mut_ref2.move:33:9 │ 33 │ *x; // Same as f1aok │ ^^ implicitly dropped here since it is no longer used -error: local `r` of type `m::R` does not have the `drop` ability +error: local `r` of type `R` does not have the `drop` ability ┌─ tests/more-v1/liveness/mut_ref2.move:42:13 │ 42 │ x = &mut r; │ ^^^^^^ still borrowed but will be implicitly dropped later since it is no longer used -error: local `r` of type `m::R` does not have the `drop` ability +error: local `r` of type `R` does not have the `drop` ability ┌─ tests/more-v1/liveness/mut_ref2.move:48:17 │ 48 │ let x = &mut r; diff --git a/third_party/move/move-compiler-v2/tests/more-v1/locals/assign_partial_resource.exp b/third_party/move/move-compiler-v2/tests/more-v1/locals/assign_partial_resource.exp index be7644dd18716..17f1975f56719 100644 --- a/third_party/move/move-compiler-v2/tests/more-v1/locals/assign_partial_resource.exp +++ b/third_party/move/move-compiler-v2/tests/more-v1/locals/assign_partial_resource.exp @@ -26,19 +26,19 @@ warning: Unused assignment to `r`. Consider removing or prefixing with an unders Diagnostics: -error: local `r` of type `M::R` does not have the `drop` ability +error: local `r` of type `R` does not have the `drop` ability ┌─ tests/more-v1/locals/assign_partial_resource.move:6:21 │ 6 │ if (cond) { r = R{}; }; │ ^^^^^^^ implicitly dropped here since it is no longer used -error: local `r` of type `M::R` does not have the `drop` ability +error: local `r` of type `R` does not have the `drop` ability ┌─ tests/more-v1/locals/assign_partial_resource.move:13:29 │ 13 │ if (cond) {} else { r = R{}; }; │ ^^^^^^^ implicitly dropped here since it is no longer used -error: local `r` of type `M::R` does not have the `drop` ability +error: local `r` of type `R` does not have the `drop` ability ┌─ tests/more-v1/locals/assign_partial_resource.move:20:24 │ 20 │ while (cond) { r = R{} }; diff --git a/third_party/move/move-compiler-v2/tests/more-v1/locals/assign_resource.exp b/third_party/move/move-compiler-v2/tests/more-v1/locals/assign_resource.exp index b99889c927077..6c7b79d54a2ce 100644 --- a/third_party/move/move-compiler-v2/tests/more-v1/locals/assign_resource.exp +++ b/third_party/move/move-compiler-v2/tests/more-v1/locals/assign_resource.exp @@ -14,25 +14,25 @@ warning: Unused assignment to `r`. Consider removing or prefixing with an unders Diagnostics: -error: local `r` of type `M::R` does not have the `drop` ability +error: local `r` of type `R` does not have the `drop` ability ┌─ tests/more-v1/locals/assign_resource.move:5:17 │ 5 │ let r = R{}; │ ^^^ implicitly dropped here since it is no longer used -error: local `r` of type `M::R` does not have the `drop` ability +error: local `r` of type `R` does not have the `drop` ability ┌─ tests/more-v1/locals/assign_resource.move:12:19 │ 12 │ if (cond) { r = R{}; }; │ ^^^^^^^^^^^^ implicitly dropped here since it is no longer used -error: local `r` of type `M::R` does not have the `drop` ability +error: local `r` of type `R` does not have the `drop` ability ┌─ tests/more-v1/locals/assign_resource.move:18:27 │ 18 │ if (cond) {} else { r = R{}; }; │ ^^^^^^^^^^^^ implicitly dropped here since it is no longer used -error: local `r` of type `M::R` does not have the `drop` ability +error: local `r` of type `R` does not have the `drop` ability ┌─ tests/more-v1/locals/assign_resource.move:24:24 │ 24 │ while (cond) { r = R{} }; diff --git a/third_party/move/move-compiler-v2/tests/more-v1/locals/unused_resource.exp b/third_party/move/move-compiler-v2/tests/more-v1/locals/unused_resource.exp index c26fec6cde656..a6c368f98dfca 100644 --- a/third_party/move/move-compiler-v2/tests/more-v1/locals/unused_resource.exp +++ b/third_party/move/move-compiler-v2/tests/more-v1/locals/unused_resource.exp @@ -46,43 +46,43 @@ warning: Unused assignment to `r`. Consider removing or prefixing with an unders Diagnostics: -error: local `r` of type `M::R` does not have the `drop` ability +error: local `r` of type `R` does not have the `drop` ability ┌─ tests/more-v1/locals/unused_resource.move:5:17 │ 5 │ let r = R{}; │ ^^^ implicitly dropped here since it is no longer used -error: local `_r` of type `M::R` does not have the `drop` ability +error: local `_r` of type `R` does not have the `drop` ability ┌─ tests/more-v1/locals/unused_resource.move:10:18 │ 10 │ let _r = R{}; │ ^^^ implicitly dropped here since it is no longer used -error: local `r` of type `M::R` does not have the `drop` ability +error: local `r` of type `R` does not have the `drop` ability ┌─ tests/more-v1/locals/unused_resource.move:15:21 │ 15 │ if (cond) { r = R{}; }; │ ^^^^^^^ implicitly dropped here since it is no longer used -error: local `r` of type `M::R` does not have the `drop` ability +error: local `r` of type `R` does not have the `drop` ability ┌─ tests/more-v1/locals/unused_resource.move:20:29 │ 20 │ if (cond) {} else { r = R{}; }; │ ^^^^^^^ implicitly dropped here since it is no longer used -error: local `r` of type `M::R` does not have the `drop` ability +error: local `r` of type `R` does not have the `drop` ability ┌─ tests/more-v1/locals/unused_resource.move:25:24 │ 25 │ while (cond) { r = R{} }; │ ^^^^^^^ implicitly dropped here since it is no longer used -error: value of type `M::R` does not have the `drop` ability +error: value of type `R` does not have the `drop` ability ┌─ tests/more-v1/locals/unused_resource.move:33:17 │ 33 │ let _ = &R{}; │ ^^^^ still borrowed but will be implicitly dropped later since it is no longer used -error: local `_x` of type `M::R` does not have the `drop` ability +error: local `_x` of type `R` does not have the `drop` ability ┌─ tests/more-v1/locals/unused_resource.move:36:22 │ 36 │ fun t7(_x: R) { diff --git a/third_party/move/move-compiler-v2/tests/more-v1/locals/unused_resource_explicit_return.exp b/third_party/move/move-compiler-v2/tests/more-v1/locals/unused_resource_explicit_return.exp index e6c1bf612b336..48ea71a1d6fcc 100644 --- a/third_party/move/move-compiler-v2/tests/more-v1/locals/unused_resource_explicit_return.exp +++ b/third_party/move/move-compiler-v2/tests/more-v1/locals/unused_resource_explicit_return.exp @@ -40,43 +40,43 @@ warning: Unused assignment to `x`. Consider removing or prefixing with an unders Diagnostics: -error: local `r` of type `M::R` does not have the `drop` ability +error: local `r` of type `R` does not have the `drop` ability ┌─ tests/more-v1/locals/unused_resource_explicit_return.move:5:17 │ 5 │ let r = R{}; │ ^^^ implicitly dropped here since it is no longer used -error: local `r` of type `M::R` does not have the `drop` ability +error: local `r` of type `R` does not have the `drop` ability ┌─ tests/more-v1/locals/unused_resource_explicit_return.move:11:21 │ 11 │ if (cond) { return () }; │ ^^^^^^^^^ implicitly dropped here since it is no longer used -error: local `r` of type `M::R` does not have the `drop` ability +error: local `r` of type `R` does not have the `drop` ability ┌─ tests/more-v1/locals/unused_resource_explicit_return.move:17:29 │ 17 │ if (cond) {} else { return () }; │ ^^^^^^^^^ implicitly dropped here since it is no longer used -error: local `r` of type `M::R` does not have the `drop` ability +error: local `r` of type `R` does not have the `drop` ability ┌─ tests/more-v1/locals/unused_resource_explicit_return.move:23:24 │ 23 │ while (cond) { return () }; │ ^^^^^^^^^ implicitly dropped here since it is no longer used -error: local `r` of type `M::R` does not have the `drop` ability +error: local `r` of type `R` does not have the `drop` ability ┌─ tests/more-v1/locals/unused_resource_explicit_return.move:28:17 │ 28 │ let r = R{}; │ ^^^ implicitly dropped here since it is no longer used -error: value of type `M::R` does not have the `drop` ability +error: value of type `R` does not have the `drop` ability ┌─ tests/more-v1/locals/unused_resource_explicit_return.move:33:17 │ 33 │ let x = &R{}; │ ^^^^ implicitly dropped here since it is no longer used -error: local `_x` of type `M::R` does not have the `drop` ability +error: local `_x` of type `R` does not have the `drop` ability ┌─ tests/more-v1/locals/unused_resource_explicit_return.move:38:9 │ 38 │ return () diff --git a/third_party/move/move-compiler-v2/tests/no-simplifier/constant_folding_ristretto.exp b/third_party/move/move-compiler-v2/tests/no-simplifier/constant_folding_ristretto.exp index b6a72eeed3745..8a40a0cf6ddc3 100644 --- a/third_party/move/move-compiler-v2/tests/no-simplifier/constant_folding_ristretto.exp +++ b/third_party/move/move-compiler-v2/tests/no-simplifier/constant_folding_ristretto.exp @@ -16,5 +16,14 @@ module 0xcafe::Ristretto { } } // end 0xcafe::Ristretto +// -- Sourcified model before bytecode pipeline +module 0xcafe::Ristretto { + public fun test() { + let non_canonical_highbit = vector[0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 128u8]; + let non_canonical_highbit_hex = vector[0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 128u8]; + if (non_canonical_highbit == non_canonical_highbit_hex) () else abort 1; + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/no-simplifier/moved_var_not_simplified.exp b/third_party/move/move-compiler-v2/tests/no-simplifier/moved_var_not_simplified.exp index 6c96a94dd70d5..0ed31e88c7ef1 100644 --- a/third_party/move/move-compiler-v2/tests/no-simplifier/moved_var_not_simplified.exp +++ b/third_party/move/move-compiler-v2/tests/no-simplifier/moved_var_not_simplified.exp @@ -11,6 +11,15 @@ module 0xc0ffee::m { } } // end 0xc0ffee::m +// -- Sourcified model before bytecode pipeline +module 0xc0ffee::m { + public fun test(): u8 { + let x = 40u8; + let y = move x; + x + y + } +} + Diagnostics: error: cannot move local `x` since it is still in use diff --git a/third_party/move/move-compiler-v2/tests/no-simplifier/moved_var_not_simplified2.exp b/third_party/move/move-compiler-v2/tests/no-simplifier/moved_var_not_simplified2.exp index ee86deb4ac415..73e1150d1e95c 100644 --- a/third_party/move/move-compiler-v2/tests/no-simplifier/moved_var_not_simplified2.exp +++ b/third_party/move/move-compiler-v2/tests/no-simplifier/moved_var_not_simplified2.exp @@ -14,6 +14,16 @@ module 0xc0ffee::m { } } // end 0xc0ffee::m +// -- Sourcified model before bytecode pipeline +module 0xc0ffee::m { + public fun test(): u8 { + let x = 40u8; + let y = move x; + let _z = x; + y + } +} + Diagnostics: error: cannot move local `x` since it is still in use diff --git a/third_party/move/move-compiler-v2/tests/op-equal/eval_order.exp b/third_party/move/move-compiler-v2/tests/op-equal/eval_order.exp index af73f4aa09c89..8d0574ecb6ed7 100644 --- a/third_party/move/move-compiler-v2/tests/op-equal/eval_order.exp +++ b/third_party/move/move-compiler-v2/tests/op-equal/eval_order.exp @@ -63,6 +63,70 @@ module 0xc0ffee::m { } } // end 0xc0ffee::m +// -- Sourcified model before bytecode pipeline +module 0xc0ffee::m { + fun mod1(r: &mut u64) { + { + let $t1 = r; + *$t1 = *$t1 + 2 + }; + } + fun mod2(r: &mut u64): u64 { + { + let $t1 = r; + *$t1 = *$t1 + 2 + }; + *r + } + public fun test0(): u64 { + let v = 1; + { + let $t = { + { + let $t = { + v = v + 2; + v + }; + v = v + $t + }; + v + }; + v = v + $t + }; + v + } + public fun test1(): u64 { + let v = 1; + { + let $t = { + v = v + 2; + v + }; + v = v + $t + }; + v + } + public fun test2(): u64 { + let v = 1; + { + let $t = { + mod1(&mut v); + v + }; + v = v + $t + }; + v + } + public fun test3(): u64 { + let v = 1; + { + let $t = mod2(&mut v); + v = v + $t + }; + v + } +} + ============ initial bytecode ================ [variant baseline] diff --git a/third_party/move/move-compiler-v2/tests/op-equal/invalid1.exp b/third_party/move/move-compiler-v2/tests/op-equal/invalid1.exp index c4d6ef7d6de9f..e615879b5173c 100644 --- a/third_party/move/move-compiler-v2/tests/op-equal/invalid1.exp +++ b/third_party/move/move-compiler-v2/tests/op-equal/invalid1.exp @@ -17,6 +17,20 @@ module 0x42::test { } } // end 0x42::test +// -- Sourcified model before bytecode pipeline +module 0x42::test { + fun test() { + let x = 42; + let p = &mut x; + x = x + 1; + { + let $t1 = p; + *$t1 = *$t1 + 1 + }; + x; + } +} + ============ initial bytecode ================ [variant baseline] diff --git a/third_party/move/move-compiler-v2/tests/op-equal/invalid6.exp b/third_party/move/move-compiler-v2/tests/op-equal/invalid6.exp index b0f19991064b6..01616fe6ce2a2 100644 --- a/third_party/move/move-compiler-v2/tests/op-equal/invalid6.exp +++ b/third_party/move/move-compiler-v2/tests/op-equal/invalid6.exp @@ -13,6 +13,19 @@ module 0x42::test { } } // end 0x42::test +// -- Sourcified model before bytecode pipeline +module 0x42::test { + fun inc_new(x: &u256) { + { + let $t1 = x; + *$t1 = *$t1 + 1u256 + }; + } + fun inc_old(x: &u256) { + *x = *x + 1u256; + } +} + Diagnostics: error: expected `&mut` but found `&u256` diff --git a/third_party/move/move-compiler-v2/tests/op-equal/valid0.exp b/third_party/move/move-compiler-v2/tests/op-equal/valid0.exp index f8abe9f33a24b..6a9969545b227 100644 --- a/third_party/move/move-compiler-v2/tests/op-equal/valid0.exp +++ b/third_party/move/move-compiler-v2/tests/op-equal/valid0.exp @@ -14,38 +14,38 @@ module 0x42::test { x: u256 = Add(x, 1); x } - private fun coin_inc_new_1(self: &mut test::Coin) { + private fun coin_inc_new_1(self: &mut 0x42::test::Coin) { { - let $t1: &mut u256 = Borrow(Mutable)(select test::Coin.0<&mut test::Coin>(self)); + let $t1: &mut u256 = Borrow(Mutable)(select test::Coin.0<&mut Coin>(self)); $t1 = Add(Deref($t1), 1) }; Tuple() } - private fun coin_inc_new_2(self: &mut test::Coin) { + private fun coin_inc_new_2(self: &mut 0x42::test::Coin) { { - let p: &mut u256 = Borrow(Mutable)(select test::Coin.0<&mut test::Coin>(self)); + let p: &mut u256 = Borrow(Mutable)(select test::Coin.0<&mut Coin>(self)); p = Add(Deref(p), 1); Tuple() } } - private fun coin_inc_old_1(self: &mut test::Coin) { - select test::Coin.0<&mut test::Coin>(self) = Add(select test::Coin.0<&mut test::Coin>(self), 1); + private fun coin_inc_old_1(self: &mut 0x42::test::Coin) { + select test::Coin.0<&mut Coin>(self) = Add(select test::Coin.0<&mut Coin>(self), 1); Tuple() } - private fun coin_inc_old_2(self: &mut test::Coin) { + private fun coin_inc_old_2(self: &mut 0x42::test::Coin) { { - let p: &mut u256 = Borrow(Mutable)(select test::Coin.0<&mut test::Coin>(self)); + let p: &mut u256 = Borrow(Mutable)(select test::Coin.0<&mut Coin>(self)); p = Add(Deref(p), 1); Tuple() } } private fun inc_coin_at(addr: address) - acquires test::Coin(*) + acquires 0x42::test::Coin(*) { { - let coin: &mut test::Coin = BorrowGlobal(Mutable)(addr); + let coin: &mut Coin = BorrowGlobal(Mutable)(addr); { - let $t1: &mut u256 = Borrow(Mutable)(select test::Coin.0<&mut test::Coin>(coin)); + let $t1: &mut u256 = Borrow(Mutable)(select test::Coin.0<&mut Coin>(coin)); $t1 = Add(Deref($t1), 1) }; Tuple() @@ -62,15 +62,15 @@ module 0x42::test { x = Add(Deref(x), 1); Tuple() } - private fun inc_vec_coin_new(x: vector,index: u64) { + private fun inc_vec_coin_new(x: vector<0x42::test::Coin>,index: u64) { { - let $t1: &mut u256 = Borrow(Mutable)(select test::Coin.0(vector::borrow_mut(Borrow(Mutable)(x), index))); + let $t1: &mut u256 = Borrow(Mutable)(select test::Coin.0(vector::borrow_mut(Borrow(Mutable)(x), index))); $t1 = Add(Deref($t1), 1) }; Tuple() } - private fun inc_vec_coin_old(x: vector,index: u64) { - select test::Coin.0(vector::borrow_mut(Borrow(Mutable)(x), index)) = Add(select test::Coin.0(vector::borrow(Borrow(Immutable)(x), index)), 1); + private fun inc_vec_coin_old(x: vector<0x42::test::Coin>,index: u64) { + select test::Coin.0(vector::borrow_mut(Borrow(Mutable)(x), index)) = Add(select test::Coin.0(vector::borrow(Borrow(Immutable)(x), index)), 1); Tuple() } private fun inc_vec_new(x: &mut vector,index: u64) { @@ -84,30 +84,119 @@ module 0x42::test { vector::borrow_mut(Borrow(Mutable)(x), index) = Add(Deref(vector::borrow(Borrow(Immutable)(x), index)), 1); Tuple() } - private fun inc_vec_wrapped_coin_new(x: vector>,index: u64) { + private fun inc_vec_wrapped_coin_new(x: vector<0x42::test::Wrapper<0x42::test::Coin>>,index: u64) { { - let $t1: &mut u256 = Borrow(Mutable)(select test::Coin.0(select test::Wrapper.0>(vector::borrow_mut>(Borrow(Mutable)(x), index)))); + let $t1: &mut u256 = Borrow(Mutable)(select test::Coin.0(select test::Wrapper.0>(vector::borrow_mut>(Borrow(Mutable)(x), index)))); $t1 = Add(Deref($t1), 1) }; Tuple() } - private fun inc_vec_wrapped_coin_old(x: vector>,index: u64) { - select test::Coin.0(select test::Wrapper.0>(vector::borrow_mut>(Borrow(Mutable)(x), index))) = Add(select test::Coin.0(select test::Wrapper.0>(vector::borrow>(Borrow(Immutable)(x), index))), 1); + private fun inc_vec_wrapped_coin_old(x: vector<0x42::test::Wrapper<0x42::test::Coin>>,index: u64) { + select test::Coin.0(select test::Wrapper.0>(vector::borrow_mut>(Borrow(Mutable)(x), index))) = Add(select test::Coin.0(select test::Wrapper.0>(vector::borrow>(Borrow(Immutable)(x), index))), 1); Tuple() } - private fun inc_wrapped_coin_new(x: &mut test::Wrapper) { + private fun inc_wrapped_coin_new(x: &mut 0x42::test::Wrapper<0x42::test::Coin>) { { - let $t1: &mut u256 = Borrow(Mutable)(select test::Coin.0(select test::Wrapper.0<&mut test::Wrapper>(x))); + let $t1: &mut u256 = Borrow(Mutable)(select test::Coin.0(select test::Wrapper.0<&mut Wrapper>(x))); $t1 = Add(Deref($t1), 1) }; Tuple() } - private fun inc_wrapped_coin_old(x: &mut test::Wrapper) { - select test::Coin.0(select test::Wrapper.0<&mut test::Wrapper>(x)) = Add(select test::Coin.0(select test::Wrapper.0<&mut test::Wrapper>(x)), 1); + private fun inc_wrapped_coin_old(x: &mut 0x42::test::Wrapper<0x42::test::Coin>) { + select test::Coin.0(select test::Wrapper.0<&mut Wrapper>(x)) = Add(select test::Coin.0(select test::Wrapper.0<&mut Wrapper>(x)), 1); Tuple() } } // end 0x42::test +// -- Sourcified model before bytecode pipeline +module 0x42::test { + struct Coin has drop, key { + 0: u256, + } + struct Wrapper has drop, key { + 0: T, + } + fun add1_new(x: u256): u256 { + x = x + 1u256; + x + } + fun add1_old(x: u256): u256 { + x = x + 1u256; + x + } + fun coin_inc_new_1(self: &mut Coin) { + { + let $t1 = &mut self.0; + *$t1 = *$t1 + 1u256 + }; + } + fun coin_inc_new_2(self: &mut Coin) { + let p = &mut self.0; + *p = *p + 1u256; + } + fun coin_inc_old_1(self: &mut Coin) { + self.0 = self.0 + 1u256; + } + fun coin_inc_old_2(self: &mut Coin) { + let p = &mut self.0; + *p = *p + 1u256; + } + fun inc_coin_at(addr: address) + acquires Coin + { + let coin = borrow_global_mut(addr); + { + let $t1 = &mut coin.0; + *$t1 = *$t1 + 1u256 + }; + } + fun inc_new(x: &mut u256) { + { + let $t1 = x; + *$t1 = *$t1 + 1u256 + }; + } + fun inc_old(x: &mut u256) { + *x = *x + 1u256; + } + fun inc_vec_coin_new(x: vector, index: u64) { + { + let $t1 = &mut 0x1::vector::borrow_mut(&mut x, index).0; + *$t1 = *$t1 + 1u256 + }; + } + fun inc_vec_coin_old(x: vector, index: u64) { + 0x1::vector::borrow_mut(&mut x, index).0 = 0x1::vector::borrow(&x, index).0 + 1u256; + } + fun inc_vec_new(x: &mut vector, index: u64) { + { + let $t1 = 0x1::vector::borrow_mut(x, index); + *$t1 = *$t1 + 1u256 + }; + } + fun inc_vec_old(x: vector, index: u64) { + *0x1::vector::borrow_mut(&mut x, index) = *0x1::vector::borrow(&x, index) + 1u256; + } + fun inc_vec_wrapped_coin_new(x: vector>, index: u64) { + { + let $t1 = &mut 0x1::vector::borrow_mut>(&mut x, index).0.0; + *$t1 = *$t1 + 1u256 + }; + } + fun inc_vec_wrapped_coin_old(x: vector>, index: u64) { + 0x1::vector::borrow_mut>(&mut x, index).0.0 = 0x1::vector::borrow>(&x, index).0.0 + 1u256; + } + fun inc_wrapped_coin_new(x: &mut Wrapper) { + { + let $t1 = &mut x.0.0; + *$t1 = *$t1 + 1u256 + }; + } + fun inc_wrapped_coin_old(x: &mut Wrapper) { + x.0.0 = x.0.0 + 1u256; + } +} + ============ initial bytecode ================ [variant baseline] @@ -137,12 +226,12 @@ fun test::add1_old($t0: u256): u256 { [variant baseline] -fun test::coin_inc_new_1($t0: &mut test::Coin) { +fun test::coin_inc_new_1($t0: &mut 0x42::test::Coin) { var $t1: &mut u256 var $t2: u256 var $t3: u256 var $t4: u256 - 0: $t1 := borrow_field.0($t0) + 0: $t1 := borrow_field<0x42::test::Coin>.0($t0) 1: $t3 := read_ref($t1) 2: $t4 := 1 3: $t2 := +($t3, $t4) @@ -152,12 +241,12 @@ fun test::coin_inc_new_1($t0: &mut test::Coin) { [variant baseline] -fun test::coin_inc_new_2($t0: &mut test::Coin) { +fun test::coin_inc_new_2($t0: &mut 0x42::test::Coin) { var $t1: &mut u256 var $t2: u256 var $t3: u256 var $t4: u256 - 0: $t1 := borrow_field.0($t0) + 0: $t1 := borrow_field<0x42::test::Coin>.0($t0) 1: $t3 := read_ref($t1) 2: $t4 := 1 3: $t2 := +($t3, $t4) @@ -167,29 +256,29 @@ fun test::coin_inc_new_2($t0: &mut test::Coin) { [variant baseline] -fun test::coin_inc_old_1($t0: &mut test::Coin) { +fun test::coin_inc_old_1($t0: &mut 0x42::test::Coin) { var $t1: u256 var $t2: u256 var $t3: &u256 var $t4: u256 var $t5: &mut u256 - 0: $t3 := borrow_field.0($t0) + 0: $t3 := borrow_field<0x42::test::Coin>.0($t0) 1: $t2 := read_ref($t3) 2: $t4 := 1 3: $t1 := +($t2, $t4) - 4: $t5 := borrow_field.0($t0) + 4: $t5 := borrow_field<0x42::test::Coin>.0($t0) 5: write_ref($t5, $t1) 6: return () } [variant baseline] -fun test::coin_inc_old_2($t0: &mut test::Coin) { +fun test::coin_inc_old_2($t0: &mut 0x42::test::Coin) { var $t1: &mut u256 var $t2: u256 var $t3: u256 var $t4: u256 - 0: $t1 := borrow_field.0($t0) + 0: $t1 := borrow_field<0x42::test::Coin>.0($t0) 1: $t3 := read_ref($t1) 2: $t4 := 1 3: $t2 := +($t3, $t4) @@ -200,13 +289,13 @@ fun test::coin_inc_old_2($t0: &mut test::Coin) { [variant baseline] fun test::inc_coin_at($t0: address) { - var $t1: &mut test::Coin + var $t1: &mut 0x42::test::Coin var $t2: &mut u256 var $t3: u256 var $t4: u256 var $t5: u256 - 0: $t1 := borrow_global($t0) - 1: $t2 := borrow_field.0($t1) + 0: $t1 := borrow_global<0x42::test::Coin>($t0) + 1: $t2 := borrow_field<0x42::test::Coin>.0($t1) 2: $t4 := read_ref($t2) 3: $t5 := 1 4: $t3 := +($t4, $t5) @@ -244,16 +333,16 @@ fun test::inc_old($t0: &mut u256) { [variant baseline] -fun test::inc_vec_coin_new($t0: vector, $t1: u64) { +fun test::inc_vec_coin_new($t0: vector<0x42::test::Coin>, $t1: u64) { var $t2: &mut u256 - var $t3: &mut test::Coin - var $t4: &mut vector + var $t3: &mut 0x42::test::Coin + var $t4: &mut vector<0x42::test::Coin> var $t5: u256 var $t6: u256 var $t7: u256 0: $t4 := borrow_local($t0) - 1: $t3 := vector::borrow_mut($t4, $t1) - 2: $t2 := borrow_field.0($t3) + 1: $t3 := vector::borrow_mut<0x42::test::Coin>($t4, $t1) + 2: $t2 := borrow_field<0x42::test::Coin>.0($t3) 3: $t6 := read_ref($t2) 4: $t7 := 1 5: $t5 := +($t6, $t7) @@ -263,25 +352,25 @@ fun test::inc_vec_coin_new($t0: vector, $t1: u64) { [variant baseline] -fun test::inc_vec_coin_old($t0: vector, $t1: u64) { +fun test::inc_vec_coin_old($t0: vector<0x42::test::Coin>, $t1: u64) { var $t2: u256 var $t3: u256 - var $t4: &test::Coin - var $t5: &vector + var $t4: &0x42::test::Coin + var $t5: &vector<0x42::test::Coin> var $t6: &u256 var $t7: u256 var $t8: &mut u256 - var $t9: &mut test::Coin - var $t10: &mut vector + var $t9: &mut 0x42::test::Coin + var $t10: &mut vector<0x42::test::Coin> 0: $t5 := borrow_local($t0) - 1: $t4 := vector::borrow($t5, $t1) - 2: $t6 := borrow_field.0($t4) + 1: $t4 := vector::borrow<0x42::test::Coin>($t5, $t1) + 2: $t6 := borrow_field<0x42::test::Coin>.0($t4) 3: $t3 := read_ref($t6) 4: $t7 := 1 5: $t2 := +($t3, $t7) 6: $t10 := borrow_local($t0) - 7: $t9 := vector::borrow_mut($t10, $t1) - 8: $t8 := borrow_field.0($t9) + 7: $t9 := vector::borrow_mut<0x42::test::Coin>($t10, $t1) + 8: $t8 := borrow_field<0x42::test::Coin>.0($t9) 9: write_ref($t8, $t2) 10: return () } @@ -324,18 +413,18 @@ fun test::inc_vec_old($t0: vector, $t1: u64) { [variant baseline] -fun test::inc_vec_wrapped_coin_new($t0: vector>, $t1: u64) { +fun test::inc_vec_wrapped_coin_new($t0: vector<0x42::test::Wrapper<0x42::test::Coin>>, $t1: u64) { var $t2: &mut u256 - var $t3: &mut test::Coin - var $t4: &mut test::Wrapper - var $t5: &mut vector> + var $t3: &mut 0x42::test::Coin + var $t4: &mut 0x42::test::Wrapper<0x42::test::Coin> + var $t5: &mut vector<0x42::test::Wrapper<0x42::test::Coin>> var $t6: u256 var $t7: u256 var $t8: u256 0: $t5 := borrow_local($t0) - 1: $t4 := vector::borrow_mut>($t5, $t1) - 2: $t3 := borrow_field>.0($t4) - 3: $t2 := borrow_field.0($t3) + 1: $t4 := vector::borrow_mut<0x42::test::Wrapper<0x42::test::Coin>>($t5, $t1) + 2: $t3 := borrow_field<0x42::test::Wrapper<0x42::test::Coin>>.0($t4) + 3: $t2 := borrow_field<0x42::test::Coin>.0($t3) 4: $t7 := read_ref($t2) 5: $t8 := 1 6: $t6 := +($t7, $t8) @@ -345,43 +434,43 @@ fun test::inc_vec_wrapped_coin_new($t0: vector>, $t1: [variant baseline] -fun test::inc_vec_wrapped_coin_old($t0: vector>, $t1: u64) { +fun test::inc_vec_wrapped_coin_old($t0: vector<0x42::test::Wrapper<0x42::test::Coin>>, $t1: u64) { var $t2: u256 var $t3: u256 - var $t4: &test::Coin - var $t5: &test::Wrapper - var $t6: &vector> + var $t4: &0x42::test::Coin + var $t5: &0x42::test::Wrapper<0x42::test::Coin> + var $t6: &vector<0x42::test::Wrapper<0x42::test::Coin>> var $t7: &u256 var $t8: u256 var $t9: &mut u256 - var $t10: &mut test::Coin - var $t11: &mut test::Wrapper - var $t12: &mut vector> + var $t10: &mut 0x42::test::Coin + var $t11: &mut 0x42::test::Wrapper<0x42::test::Coin> + var $t12: &mut vector<0x42::test::Wrapper<0x42::test::Coin>> 0: $t6 := borrow_local($t0) - 1: $t5 := vector::borrow>($t6, $t1) - 2: $t4 := borrow_field>.0($t5) - 3: $t7 := borrow_field.0($t4) + 1: $t5 := vector::borrow<0x42::test::Wrapper<0x42::test::Coin>>($t6, $t1) + 2: $t4 := borrow_field<0x42::test::Wrapper<0x42::test::Coin>>.0($t5) + 3: $t7 := borrow_field<0x42::test::Coin>.0($t4) 4: $t3 := read_ref($t7) 5: $t8 := 1 6: $t2 := +($t3, $t8) 7: $t12 := borrow_local($t0) - 8: $t11 := vector::borrow_mut>($t12, $t1) - 9: $t10 := borrow_field>.0($t11) - 10: $t9 := borrow_field.0($t10) + 8: $t11 := vector::borrow_mut<0x42::test::Wrapper<0x42::test::Coin>>($t12, $t1) + 9: $t10 := borrow_field<0x42::test::Wrapper<0x42::test::Coin>>.0($t11) + 10: $t9 := borrow_field<0x42::test::Coin>.0($t10) 11: write_ref($t9, $t2) 12: return () } [variant baseline] -fun test::inc_wrapped_coin_new($t0: &mut test::Wrapper) { +fun test::inc_wrapped_coin_new($t0: &mut 0x42::test::Wrapper<0x42::test::Coin>) { var $t1: &mut u256 - var $t2: &mut test::Coin + var $t2: &mut 0x42::test::Coin var $t3: u256 var $t4: u256 var $t5: u256 - 0: $t2 := borrow_field>.0($t0) - 1: $t1 := borrow_field.0($t2) + 0: $t2 := borrow_field<0x42::test::Wrapper<0x42::test::Coin>>.0($t0) + 1: $t1 := borrow_field<0x42::test::Coin>.0($t2) 2: $t4 := read_ref($t1) 3: $t5 := 1 4: $t3 := +($t4, $t5) @@ -391,21 +480,21 @@ fun test::inc_wrapped_coin_new($t0: &mut test::Wrapper) { [variant baseline] -fun test::inc_wrapped_coin_old($t0: &mut test::Wrapper) { +fun test::inc_wrapped_coin_old($t0: &mut 0x42::test::Wrapper<0x42::test::Coin>) { var $t1: u256 var $t2: u256 - var $t3: &test::Coin + var $t3: &0x42::test::Coin var $t4: &u256 var $t5: u256 var $t6: &mut u256 - var $t7: &mut test::Coin - 0: $t3 := borrow_field>.0($t0) - 1: $t4 := borrow_field.0($t3) + var $t7: &mut 0x42::test::Coin + 0: $t3 := borrow_field<0x42::test::Wrapper<0x42::test::Coin>>.0($t0) + 1: $t4 := borrow_field<0x42::test::Coin>.0($t3) 2: $t2 := read_ref($t4) 3: $t5 := 1 4: $t1 := +($t2, $t5) - 5: $t7 := borrow_field>.0($t0) - 6: $t6 := borrow_field.0($t7) + 5: $t7 := borrow_field<0x42::test::Wrapper<0x42::test::Coin>>.0($t0) + 6: $t6 := borrow_field<0x42::test::Coin>.0($t7) 7: write_ref($t6, $t1) 8: return () } @@ -445,13 +534,13 @@ fun test::add1_old($t0: u256): u256 { [variant baseline] -fun test::coin_inc_new_1($t0: &mut test::Coin) { +fun test::coin_inc_new_1($t0: &mut 0x42::test::Coin) { var $t1: &mut u256 var $t2: u256 [unused] var $t3: u256 var $t4: u256 # live vars: $t0 - 0: $t1 := borrow_field.0($t0) + 0: $t1 := borrow_field<0x42::test::Coin>.0($t0) # live vars: $t1 1: $t3 := read_ref($t1) # live vars: $t1, $t3 @@ -466,13 +555,13 @@ fun test::coin_inc_new_1($t0: &mut test::Coin) { [variant baseline] -fun test::coin_inc_new_2($t0: &mut test::Coin) { +fun test::coin_inc_new_2($t0: &mut 0x42::test::Coin) { var $t1: &mut u256 var $t2: u256 [unused] var $t3: u256 var $t4: u256 # live vars: $t0 - 0: $t1 := borrow_field.0($t0) + 0: $t1 := borrow_field<0x42::test::Coin>.0($t0) # live vars: $t1 1: $t3 := read_ref($t1) # live vars: $t1, $t3 @@ -487,14 +576,14 @@ fun test::coin_inc_new_2($t0: &mut test::Coin) { [variant baseline] -fun test::coin_inc_old_1($t0: &mut test::Coin) { +fun test::coin_inc_old_1($t0: &mut 0x42::test::Coin) { var $t1: u256 [unused] var $t2: u256 var $t3: &u256 var $t4: u256 var $t5: &mut u256 # live vars: $t0 - 0: $t3 := borrow_field.0($t0) + 0: $t3 := borrow_field<0x42::test::Coin>.0($t0) # live vars: $t0, $t3 1: $t2 := read_ref($t3) # live vars: $t0, $t2 @@ -502,7 +591,7 @@ fun test::coin_inc_old_1($t0: &mut test::Coin) { # live vars: $t0, $t2, $t4 3: $t2 := +($t2, $t4) # live vars: $t0, $t2 - 4: $t5 := borrow_field.0($t0) + 4: $t5 := borrow_field<0x42::test::Coin>.0($t0) # live vars: $t2, $t5 5: write_ref($t5, $t2) # live vars: @@ -511,13 +600,13 @@ fun test::coin_inc_old_1($t0: &mut test::Coin) { [variant baseline] -fun test::coin_inc_old_2($t0: &mut test::Coin) { +fun test::coin_inc_old_2($t0: &mut 0x42::test::Coin) { var $t1: &mut u256 var $t2: u256 [unused] var $t3: u256 var $t4: u256 # live vars: $t0 - 0: $t1 := borrow_field.0($t0) + 0: $t1 := borrow_field<0x42::test::Coin>.0($t0) # live vars: $t1 1: $t3 := read_ref($t1) # live vars: $t1, $t3 @@ -533,15 +622,15 @@ fun test::coin_inc_old_2($t0: &mut test::Coin) { [variant baseline] fun test::inc_coin_at($t0: address) { - var $t1: &mut test::Coin + var $t1: &mut 0x42::test::Coin var $t2: &mut u256 var $t3: u256 [unused] var $t4: u256 var $t5: u256 # live vars: $t0 - 0: $t1 := borrow_global($t0) + 0: $t1 := borrow_global<0x42::test::Coin>($t0) # live vars: $t1 - 1: $t2 := borrow_field.0($t1) + 1: $t2 := borrow_field<0x42::test::Coin>.0($t1) # live vars: $t2 2: $t4 := read_ref($t2) # live vars: $t2, $t4 @@ -593,19 +682,19 @@ fun test::inc_old($t0: &mut u256) { [variant baseline] -fun test::inc_vec_coin_new($t0: vector, $t1: u64) { +fun test::inc_vec_coin_new($t0: vector<0x42::test::Coin>, $t1: u64) { var $t2: &mut u256 - var $t3: &mut test::Coin - var $t4: &mut vector + var $t3: &mut 0x42::test::Coin + var $t4: &mut vector<0x42::test::Coin> var $t5: u256 [unused] var $t6: u256 var $t7: u256 # live vars: $t0, $t1 0: $t4 := borrow_local($t0) # live vars: $t1, $t4 - 1: $t3 := vector::borrow_mut($t4, $t1) + 1: $t3 := vector::borrow_mut<0x42::test::Coin>($t4, $t1) # live vars: $t3 - 2: $t2 := borrow_field.0($t3) + 2: $t2 := borrow_field<0x42::test::Coin>.0($t3) # live vars: $t2 3: $t6 := read_ref($t2) # live vars: $t2, $t6 @@ -620,22 +709,22 @@ fun test::inc_vec_coin_new($t0: vector, $t1: u64) { [variant baseline] -fun test::inc_vec_coin_old($t0: vector, $t1: u64) { +fun test::inc_vec_coin_old($t0: vector<0x42::test::Coin>, $t1: u64) { var $t2: u256 [unused] var $t3: u256 - var $t4: &test::Coin - var $t5: &vector + var $t4: &0x42::test::Coin + var $t5: &vector<0x42::test::Coin> var $t6: &u256 var $t7: u256 var $t8: &mut u256 - var $t9: &mut test::Coin - var $t10: &mut vector + var $t9: &mut 0x42::test::Coin + var $t10: &mut vector<0x42::test::Coin> # live vars: $t0, $t1 0: $t5 := borrow_local($t0) # live vars: $t0, $t1, $t5 - 1: $t4 := vector::borrow($t5, $t1) + 1: $t4 := vector::borrow<0x42::test::Coin>($t5, $t1) # live vars: $t0, $t1, $t4 - 2: $t6 := borrow_field.0($t4) + 2: $t6 := borrow_field<0x42::test::Coin>.0($t4) # live vars: $t0, $t1, $t6 3: $t3 := read_ref($t6) # live vars: $t0, $t1, $t3 @@ -645,9 +734,9 @@ fun test::inc_vec_coin_old($t0: vector, $t1: u64) { # live vars: $t0, $t1, $t3 6: $t10 := borrow_local($t0) # live vars: $t1, $t3, $t10 - 7: $t9 := vector::borrow_mut($t10, $t1) + 7: $t9 := vector::borrow_mut<0x42::test::Coin>($t10, $t1) # live vars: $t3, $t9 - 8: $t8 := borrow_field.0($t9) + 8: $t8 := borrow_field<0x42::test::Coin>.0($t9) # live vars: $t3, $t8 9: write_ref($t8, $t3) # live vars: @@ -707,22 +796,22 @@ fun test::inc_vec_old($t0: vector, $t1: u64) { [variant baseline] -fun test::inc_vec_wrapped_coin_new($t0: vector>, $t1: u64) { +fun test::inc_vec_wrapped_coin_new($t0: vector<0x42::test::Wrapper<0x42::test::Coin>>, $t1: u64) { var $t2: &mut u256 - var $t3: &mut test::Coin - var $t4: &mut test::Wrapper - var $t5: &mut vector> + var $t3: &mut 0x42::test::Coin + var $t4: &mut 0x42::test::Wrapper<0x42::test::Coin> + var $t5: &mut vector<0x42::test::Wrapper<0x42::test::Coin>> var $t6: u256 [unused] var $t7: u256 var $t8: u256 # live vars: $t0, $t1 0: $t5 := borrow_local($t0) # live vars: $t1, $t5 - 1: $t4 := vector::borrow_mut>($t5, $t1) + 1: $t4 := vector::borrow_mut<0x42::test::Wrapper<0x42::test::Coin>>($t5, $t1) # live vars: $t4 - 2: $t3 := borrow_field>.0($t4) + 2: $t3 := borrow_field<0x42::test::Wrapper<0x42::test::Coin>>.0($t4) # live vars: $t3 - 3: $t2 := borrow_field.0($t3) + 3: $t2 := borrow_field<0x42::test::Coin>.0($t3) # live vars: $t2 4: $t7 := read_ref($t2) # live vars: $t2, $t7 @@ -737,26 +826,26 @@ fun test::inc_vec_wrapped_coin_new($t0: vector>, $t1: [variant baseline] -fun test::inc_vec_wrapped_coin_old($t0: vector>, $t1: u64) { +fun test::inc_vec_wrapped_coin_old($t0: vector<0x42::test::Wrapper<0x42::test::Coin>>, $t1: u64) { var $t2: u256 [unused] var $t3: u256 - var $t4: &test::Coin - var $t5: &test::Wrapper - var $t6: &vector> + var $t4: &0x42::test::Coin + var $t5: &0x42::test::Wrapper<0x42::test::Coin> + var $t6: &vector<0x42::test::Wrapper<0x42::test::Coin>> var $t7: &u256 var $t8: u256 var $t9: &mut u256 - var $t10: &mut test::Coin - var $t11: &mut test::Wrapper - var $t12: &mut vector> + var $t10: &mut 0x42::test::Coin + var $t11: &mut 0x42::test::Wrapper<0x42::test::Coin> + var $t12: &mut vector<0x42::test::Wrapper<0x42::test::Coin>> # live vars: $t0, $t1 0: $t6 := borrow_local($t0) # live vars: $t0, $t1, $t6 - 1: $t5 := vector::borrow>($t6, $t1) + 1: $t5 := vector::borrow<0x42::test::Wrapper<0x42::test::Coin>>($t6, $t1) # live vars: $t0, $t1, $t5 - 2: $t4 := borrow_field>.0($t5) + 2: $t4 := borrow_field<0x42::test::Wrapper<0x42::test::Coin>>.0($t5) # live vars: $t0, $t1, $t4 - 3: $t7 := borrow_field.0($t4) + 3: $t7 := borrow_field<0x42::test::Coin>.0($t4) # live vars: $t0, $t1, $t7 4: $t3 := read_ref($t7) # live vars: $t0, $t1, $t3 @@ -766,11 +855,11 @@ fun test::inc_vec_wrapped_coin_old($t0: vector>, $t1: # live vars: $t0, $t1, $t3 7: $t12 := borrow_local($t0) # live vars: $t1, $t3, $t12 - 8: $t11 := vector::borrow_mut>($t12, $t1) + 8: $t11 := vector::borrow_mut<0x42::test::Wrapper<0x42::test::Coin>>($t12, $t1) # live vars: $t3, $t11 - 9: $t10 := borrow_field>.0($t11) + 9: $t10 := borrow_field<0x42::test::Wrapper<0x42::test::Coin>>.0($t11) # live vars: $t3, $t10 - 10: $t9 := borrow_field.0($t10) + 10: $t9 := borrow_field<0x42::test::Coin>.0($t10) # live vars: $t3, $t9 11: write_ref($t9, $t3) # live vars: @@ -779,16 +868,16 @@ fun test::inc_vec_wrapped_coin_old($t0: vector>, $t1: [variant baseline] -fun test::inc_wrapped_coin_new($t0: &mut test::Wrapper) { +fun test::inc_wrapped_coin_new($t0: &mut 0x42::test::Wrapper<0x42::test::Coin>) { var $t1: &mut u256 - var $t2: &mut test::Coin + var $t2: &mut 0x42::test::Coin var $t3: u256 [unused] var $t4: u256 var $t5: u256 # live vars: $t0 - 0: $t2 := borrow_field>.0($t0) + 0: $t2 := borrow_field<0x42::test::Wrapper<0x42::test::Coin>>.0($t0) # live vars: $t2 - 1: $t1 := borrow_field.0($t2) + 1: $t1 := borrow_field<0x42::test::Coin>.0($t2) # live vars: $t1 2: $t4 := read_ref($t1) # live vars: $t1, $t4 @@ -803,18 +892,18 @@ fun test::inc_wrapped_coin_new($t0: &mut test::Wrapper) { [variant baseline] -fun test::inc_wrapped_coin_old($t0: &mut test::Wrapper) { +fun test::inc_wrapped_coin_old($t0: &mut 0x42::test::Wrapper<0x42::test::Coin>) { var $t1: u256 [unused] var $t2: u256 - var $t3: &test::Coin + var $t3: &0x42::test::Coin var $t4: &u256 var $t5: u256 var $t6: &mut u256 - var $t7: &mut test::Coin + var $t7: &mut 0x42::test::Coin # live vars: $t0 - 0: $t3 := borrow_field>.0($t0) + 0: $t3 := borrow_field<0x42::test::Wrapper<0x42::test::Coin>>.0($t0) # live vars: $t0, $t3 - 1: $t4 := borrow_field.0($t3) + 1: $t4 := borrow_field<0x42::test::Coin>.0($t3) # live vars: $t0, $t4 2: $t2 := read_ref($t4) # live vars: $t0, $t2 @@ -822,9 +911,9 @@ fun test::inc_wrapped_coin_old($t0: &mut test::Wrapper) { # live vars: $t0, $t2, $t5 4: $t2 := +($t2, $t5) # live vars: $t0, $t2 - 5: $t7 := borrow_field>.0($t0) + 5: $t7 := borrow_field<0x42::test::Wrapper<0x42::test::Coin>>.0($t0) # live vars: $t2, $t7 - 6: $t6 := borrow_field.0($t7) + 6: $t6 := borrow_field<0x42::test::Coin>.0($t7) # live vars: $t2, $t6 7: write_ref($t6, $t2) # live vars: diff --git a/third_party/move/move-compiler-v2/tests/op-equal/valid1.exp b/third_party/move/move-compiler-v2/tests/op-equal/valid1.exp index e6a3ff288eab3..1a98595706b80 100644 --- a/third_party/move/move-compiler-v2/tests/op-equal/valid1.exp +++ b/third_party/move/move-compiler-v2/tests/op-equal/valid1.exp @@ -6,9 +6,9 @@ module 0x42::test { struct Wrapper { 0: #0, } - private fun bitand_vec_coin_new(x: vector,index: u64) { + private fun bitand_vec_coin_new(x: vector<0x42::test::Coin>,index: u64) { { - let $t1: &mut u256 = Borrow(Mutable)(select test::Coin.0(vector::borrow_mut(Borrow(Mutable)(x), index))); + let $t1: &mut u256 = Borrow(Mutable)(select test::Coin.0(vector::borrow_mut(Borrow(Mutable)(x), index))); $t1 = BitAnd(Deref($t1), 42) }; Tuple() @@ -20,41 +20,41 @@ module 0x42::test { }; Tuple() } - private fun coin_double(self: &mut test::Coin) { + private fun coin_double(self: &mut 0x42::test::Coin) { { - let $t1: &mut u256 = Borrow(Mutable)(select test::Coin.0<&mut test::Coin>(self)); + let $t1: &mut u256 = Borrow(Mutable)(select test::Coin.0<&mut Coin>(self)); $t1 = Mul(Deref($t1), 2) }; Tuple() } - private fun coin_mod_2(self: &mut test::Coin) { + private fun coin_mod_2(self: &mut 0x42::test::Coin) { { - let $t1: &mut u256 = Borrow(Mutable)(select test::Coin.0<&mut test::Coin>(self)); + let $t1: &mut u256 = Borrow(Mutable)(select test::Coin.0<&mut Coin>(self)); $t1 = Mod(Deref($t1), 2) }; Tuple() } - private fun half_wrapped_coin_new(x: &mut test::Wrapper) { + private fun half_wrapped_coin_new(x: &mut 0x42::test::Wrapper<0x42::test::Coin>) { { - let $t1: &mut u256 = Borrow(Mutable)(select test::Coin.0(select test::Wrapper.0<&mut test::Wrapper>(x))); + let $t1: &mut u256 = Borrow(Mutable)(select test::Coin.0(select test::Wrapper.0<&mut Wrapper>(x))); $t1 = Div(Deref($t1), 2) }; Tuple() } - private fun shl_vec_wrapped_coin_old(x: vector>,index: u64) { + private fun shl_vec_wrapped_coin_old(x: vector<0x42::test::Wrapper<0x42::test::Coin>>,index: u64) { { - let $t1: &mut u256 = Borrow(Mutable)(select test::Coin.0(select test::Wrapper.0>(vector::borrow_mut>(Borrow(Mutable)(x), index)))); + let $t1: &mut u256 = Borrow(Mutable)(select test::Coin.0(select test::Wrapper.0>(vector::borrow_mut>(Borrow(Mutable)(x), index)))); $t1 = Shl(Deref($t1), 1) }; Tuple() } private fun shr_coin_at(addr: address) - acquires test::Coin(*) + acquires 0x42::test::Coin(*) { { - let coin: &mut test::Coin = BorrowGlobal(Mutable)(addr); + let coin: &mut Coin = BorrowGlobal(Mutable)(addr); { - let $t1: &mut u256 = Borrow(Mutable)(select test::Coin.0<&mut test::Coin>(coin)); + let $t1: &mut u256 = Borrow(Mutable)(select test::Coin.0<&mut Coin>(coin)); $t1 = Shr(Deref($t1), 1) }; Tuple() @@ -67,28 +67,95 @@ module 0x42::test { }; Tuple() } - private fun xor_vec_wrapped_coin_new(x: vector>,index: u64) { + private fun xor_vec_wrapped_coin_new(x: vector<0x42::test::Wrapper<0x42::test::Coin>>,index: u64) { { - let $t1: &mut u256 = Borrow(Mutable)(select test::Coin.0(select test::Wrapper.0>(vector::borrow_mut>(Borrow(Mutable)(x), index)))); + let $t1: &mut u256 = Borrow(Mutable)(select test::Coin.0(select test::Wrapper.0>(vector::borrow_mut>(Borrow(Mutable)(x), index)))); $t1 = Xor(Deref($t1), 1) }; Tuple() } } // end 0x42::test +// -- Sourcified model before bytecode pipeline +module 0x42::test { + struct Coin has drop, key { + 0: u256, + } + struct Wrapper has drop, key { + 0: T, + } + fun bitand_vec_coin_new(x: vector, index: u64) { + { + let $t1 = &mut 0x1::vector::borrow_mut(&mut x, index).0; + *$t1 = *$t1 & 42u256 + }; + } + fun bitor_vec_new(x: &mut vector, index: u64) { + { + let $t1 = 0x1::vector::borrow_mut(x, index); + *$t1 = *$t1 | 42u256 + }; + } + fun coin_double(self: &mut Coin) { + { + let $t1 = &mut self.0; + *$t1 = *$t1 * 2u256 + }; + } + fun coin_mod_2(self: &mut Coin) { + { + let $t1 = &mut self.0; + *$t1 = *$t1 % 2u256 + }; + } + fun half_wrapped_coin_new(x: &mut Wrapper) { + { + let $t1 = &mut x.0.0; + *$t1 = *$t1 / 2u256 + }; + } + fun shl_vec_wrapped_coin_old(x: vector>, index: u64) { + { + let $t1 = &mut 0x1::vector::borrow_mut>(&mut x, index).0.0; + *$t1 = *$t1 << 1u8 + }; + } + fun shr_coin_at(addr: address) + acquires Coin + { + let coin = borrow_global_mut(addr); + { + let $t1 = &mut coin.0; + *$t1 = *$t1 >> 1u8 + }; + } + fun sub1(x: &mut u256) { + { + let $t1 = x; + *$t1 = *$t1 - 1u256 + }; + } + fun xor_vec_wrapped_coin_new(x: vector>, index: u64) { + { + let $t1 = &mut 0x1::vector::borrow_mut>(&mut x, index).0.0; + *$t1 = *$t1 ^ 1u256 + }; + } +} + ============ initial bytecode ================ [variant baseline] -fun test::bitand_vec_coin_new($t0: vector, $t1: u64) { +fun test::bitand_vec_coin_new($t0: vector<0x42::test::Coin>, $t1: u64) { var $t2: &mut u256 - var $t3: &mut test::Coin - var $t4: &mut vector + var $t3: &mut 0x42::test::Coin + var $t4: &mut vector<0x42::test::Coin> var $t5: u256 var $t6: u256 var $t7: u256 0: $t4 := borrow_local($t0) - 1: $t3 := vector::borrow_mut($t4, $t1) - 2: $t2 := borrow_field.0($t3) + 1: $t3 := vector::borrow_mut<0x42::test::Coin>($t4, $t1) + 2: $t2 := borrow_field<0x42::test::Coin>.0($t3) 3: $t6 := read_ref($t2) 4: $t7 := 42 5: $t5 := &($t6, $t7) @@ -113,12 +180,12 @@ fun test::bitor_vec_new($t0: &mut vector, $t1: u64) { [variant baseline] -fun test::coin_double($t0: &mut test::Coin) { +fun test::coin_double($t0: &mut 0x42::test::Coin) { var $t1: &mut u256 var $t2: u256 var $t3: u256 var $t4: u256 - 0: $t1 := borrow_field.0($t0) + 0: $t1 := borrow_field<0x42::test::Coin>.0($t0) 1: $t3 := read_ref($t1) 2: $t4 := 2 3: $t2 := *($t3, $t4) @@ -128,12 +195,12 @@ fun test::coin_double($t0: &mut test::Coin) { [variant baseline] -fun test::coin_mod_2($t0: &mut test::Coin) { +fun test::coin_mod_2($t0: &mut 0x42::test::Coin) { var $t1: &mut u256 var $t2: u256 var $t3: u256 var $t4: u256 - 0: $t1 := borrow_field.0($t0) + 0: $t1 := borrow_field<0x42::test::Coin>.0($t0) 1: $t3 := read_ref($t1) 2: $t4 := 2 3: $t2 := %($t3, $t4) @@ -143,14 +210,14 @@ fun test::coin_mod_2($t0: &mut test::Coin) { [variant baseline] -fun test::half_wrapped_coin_new($t0: &mut test::Wrapper) { +fun test::half_wrapped_coin_new($t0: &mut 0x42::test::Wrapper<0x42::test::Coin>) { var $t1: &mut u256 - var $t2: &mut test::Coin + var $t2: &mut 0x42::test::Coin var $t3: u256 var $t4: u256 var $t5: u256 - 0: $t2 := borrow_field>.0($t0) - 1: $t1 := borrow_field.0($t2) + 0: $t2 := borrow_field<0x42::test::Wrapper<0x42::test::Coin>>.0($t0) + 1: $t1 := borrow_field<0x42::test::Coin>.0($t2) 2: $t4 := read_ref($t1) 3: $t5 := 2 4: $t3 := /($t4, $t5) @@ -160,18 +227,18 @@ fun test::half_wrapped_coin_new($t0: &mut test::Wrapper) { [variant baseline] -fun test::shl_vec_wrapped_coin_old($t0: vector>, $t1: u64) { +fun test::shl_vec_wrapped_coin_old($t0: vector<0x42::test::Wrapper<0x42::test::Coin>>, $t1: u64) { var $t2: &mut u256 - var $t3: &mut test::Coin - var $t4: &mut test::Wrapper - var $t5: &mut vector> + var $t3: &mut 0x42::test::Coin + var $t4: &mut 0x42::test::Wrapper<0x42::test::Coin> + var $t5: &mut vector<0x42::test::Wrapper<0x42::test::Coin>> var $t6: u256 var $t7: u256 var $t8: u8 0: $t5 := borrow_local($t0) - 1: $t4 := vector::borrow_mut>($t5, $t1) - 2: $t3 := borrow_field>.0($t4) - 3: $t2 := borrow_field.0($t3) + 1: $t4 := vector::borrow_mut<0x42::test::Wrapper<0x42::test::Coin>>($t5, $t1) + 2: $t3 := borrow_field<0x42::test::Wrapper<0x42::test::Coin>>.0($t4) + 3: $t2 := borrow_field<0x42::test::Coin>.0($t3) 4: $t7 := read_ref($t2) 5: $t8 := 1 6: $t6 := <<($t7, $t8) @@ -182,13 +249,13 @@ fun test::shl_vec_wrapped_coin_old($t0: vector>, $t1: [variant baseline] fun test::shr_coin_at($t0: address) { - var $t1: &mut test::Coin + var $t1: &mut 0x42::test::Coin var $t2: &mut u256 var $t3: u256 var $t4: u256 var $t5: u8 - 0: $t1 := borrow_global($t0) - 1: $t2 := borrow_field.0($t1) + 0: $t1 := borrow_global<0x42::test::Coin>($t0) + 1: $t2 := borrow_field<0x42::test::Coin>.0($t1) 2: $t4 := read_ref($t2) 3: $t5 := 1 4: $t3 := >>($t4, $t5) @@ -213,18 +280,18 @@ fun test::sub1($t0: &mut u256) { [variant baseline] -fun test::xor_vec_wrapped_coin_new($t0: vector>, $t1: u64) { +fun test::xor_vec_wrapped_coin_new($t0: vector<0x42::test::Wrapper<0x42::test::Coin>>, $t1: u64) { var $t2: &mut u256 - var $t3: &mut test::Coin - var $t4: &mut test::Wrapper - var $t5: &mut vector> + var $t3: &mut 0x42::test::Coin + var $t4: &mut 0x42::test::Wrapper<0x42::test::Coin> + var $t5: &mut vector<0x42::test::Wrapper<0x42::test::Coin>> var $t6: u256 var $t7: u256 var $t8: u256 0: $t5 := borrow_local($t0) - 1: $t4 := vector::borrow_mut>($t5, $t1) - 2: $t3 := borrow_field>.0($t4) - 3: $t2 := borrow_field.0($t3) + 1: $t4 := vector::borrow_mut<0x42::test::Wrapper<0x42::test::Coin>>($t5, $t1) + 2: $t3 := borrow_field<0x42::test::Wrapper<0x42::test::Coin>>.0($t4) + 3: $t2 := borrow_field<0x42::test::Coin>.0($t3) 4: $t7 := read_ref($t2) 5: $t8 := 1 6: $t6 := ^($t7, $t8) @@ -235,19 +302,19 @@ fun test::xor_vec_wrapped_coin_new($t0: vector>, $t1: ============ after LiveVarAnalysisProcessor: ================ [variant baseline] -fun test::bitand_vec_coin_new($t0: vector, $t1: u64) { +fun test::bitand_vec_coin_new($t0: vector<0x42::test::Coin>, $t1: u64) { var $t2: &mut u256 - var $t3: &mut test::Coin - var $t4: &mut vector + var $t3: &mut 0x42::test::Coin + var $t4: &mut vector<0x42::test::Coin> var $t5: u256 [unused] var $t6: u256 var $t7: u256 # live vars: $t0, $t1 0: $t4 := borrow_local($t0) # live vars: $t1, $t4 - 1: $t3 := vector::borrow_mut($t4, $t1) + 1: $t3 := vector::borrow_mut<0x42::test::Coin>($t4, $t1) # live vars: $t3 - 2: $t2 := borrow_field.0($t3) + 2: $t2 := borrow_field<0x42::test::Coin>.0($t3) # live vars: $t2 3: $t6 := read_ref($t2) # live vars: $t2, $t6 @@ -283,13 +350,13 @@ fun test::bitor_vec_new($t0: &mut vector, $t1: u64) { [variant baseline] -fun test::coin_double($t0: &mut test::Coin) { +fun test::coin_double($t0: &mut 0x42::test::Coin) { var $t1: &mut u256 var $t2: u256 [unused] var $t3: u256 var $t4: u256 # live vars: $t0 - 0: $t1 := borrow_field.0($t0) + 0: $t1 := borrow_field<0x42::test::Coin>.0($t0) # live vars: $t1 1: $t3 := read_ref($t1) # live vars: $t1, $t3 @@ -304,13 +371,13 @@ fun test::coin_double($t0: &mut test::Coin) { [variant baseline] -fun test::coin_mod_2($t0: &mut test::Coin) { +fun test::coin_mod_2($t0: &mut 0x42::test::Coin) { var $t1: &mut u256 var $t2: u256 [unused] var $t3: u256 var $t4: u256 # live vars: $t0 - 0: $t1 := borrow_field.0($t0) + 0: $t1 := borrow_field<0x42::test::Coin>.0($t0) # live vars: $t1 1: $t3 := read_ref($t1) # live vars: $t1, $t3 @@ -325,16 +392,16 @@ fun test::coin_mod_2($t0: &mut test::Coin) { [variant baseline] -fun test::half_wrapped_coin_new($t0: &mut test::Wrapper) { +fun test::half_wrapped_coin_new($t0: &mut 0x42::test::Wrapper<0x42::test::Coin>) { var $t1: &mut u256 - var $t2: &mut test::Coin + var $t2: &mut 0x42::test::Coin var $t3: u256 [unused] var $t4: u256 var $t5: u256 # live vars: $t0 - 0: $t2 := borrow_field>.0($t0) + 0: $t2 := borrow_field<0x42::test::Wrapper<0x42::test::Coin>>.0($t0) # live vars: $t2 - 1: $t1 := borrow_field.0($t2) + 1: $t1 := borrow_field<0x42::test::Coin>.0($t2) # live vars: $t1 2: $t4 := read_ref($t1) # live vars: $t1, $t4 @@ -349,22 +416,22 @@ fun test::half_wrapped_coin_new($t0: &mut test::Wrapper) { [variant baseline] -fun test::shl_vec_wrapped_coin_old($t0: vector>, $t1: u64) { +fun test::shl_vec_wrapped_coin_old($t0: vector<0x42::test::Wrapper<0x42::test::Coin>>, $t1: u64) { var $t2: &mut u256 - var $t3: &mut test::Coin - var $t4: &mut test::Wrapper - var $t5: &mut vector> + var $t3: &mut 0x42::test::Coin + var $t4: &mut 0x42::test::Wrapper<0x42::test::Coin> + var $t5: &mut vector<0x42::test::Wrapper<0x42::test::Coin>> var $t6: u256 [unused] var $t7: u256 var $t8: u8 # live vars: $t0, $t1 0: $t5 := borrow_local($t0) # live vars: $t1, $t5 - 1: $t4 := vector::borrow_mut>($t5, $t1) + 1: $t4 := vector::borrow_mut<0x42::test::Wrapper<0x42::test::Coin>>($t5, $t1) # live vars: $t4 - 2: $t3 := borrow_field>.0($t4) + 2: $t3 := borrow_field<0x42::test::Wrapper<0x42::test::Coin>>.0($t4) # live vars: $t3 - 3: $t2 := borrow_field.0($t3) + 3: $t2 := borrow_field<0x42::test::Coin>.0($t3) # live vars: $t2 4: $t7 := read_ref($t2) # live vars: $t2, $t7 @@ -380,15 +447,15 @@ fun test::shl_vec_wrapped_coin_old($t0: vector>, $t1: [variant baseline] fun test::shr_coin_at($t0: address) { - var $t1: &mut test::Coin + var $t1: &mut 0x42::test::Coin var $t2: &mut u256 var $t3: u256 [unused] var $t4: u256 var $t5: u8 # live vars: $t0 - 0: $t1 := borrow_global($t0) + 0: $t1 := borrow_global<0x42::test::Coin>($t0) # live vars: $t1 - 1: $t2 := borrow_field.0($t1) + 1: $t2 := borrow_field<0x42::test::Coin>.0($t1) # live vars: $t2 2: $t4 := read_ref($t2) # live vars: $t2, $t4 @@ -422,22 +489,22 @@ fun test::sub1($t0: &mut u256) { [variant baseline] -fun test::xor_vec_wrapped_coin_new($t0: vector>, $t1: u64) { +fun test::xor_vec_wrapped_coin_new($t0: vector<0x42::test::Wrapper<0x42::test::Coin>>, $t1: u64) { var $t2: &mut u256 - var $t3: &mut test::Coin - var $t4: &mut test::Wrapper - var $t5: &mut vector> + var $t3: &mut 0x42::test::Coin + var $t4: &mut 0x42::test::Wrapper<0x42::test::Coin> + var $t5: &mut vector<0x42::test::Wrapper<0x42::test::Coin>> var $t6: u256 [unused] var $t7: u256 var $t8: u256 # live vars: $t0, $t1 0: $t5 := borrow_local($t0) # live vars: $t1, $t5 - 1: $t4 := vector::borrow_mut>($t5, $t1) + 1: $t4 := vector::borrow_mut<0x42::test::Wrapper<0x42::test::Coin>>($t5, $t1) # live vars: $t4 - 2: $t3 := borrow_field>.0($t4) + 2: $t3 := borrow_field<0x42::test::Wrapper<0x42::test::Coin>>.0($t4) # live vars: $t3 - 3: $t2 := borrow_field.0($t3) + 3: $t2 := borrow_field<0x42::test::Coin>.0($t3) # live vars: $t2 4: $t7 := read_ref($t2) # live vars: $t2, $t7 diff --git a/third_party/move/move-compiler-v2/tests/op-equal/valid2.exp b/third_party/move/move-compiler-v2/tests/op-equal/valid2.exp index 772a9507ed263..0ae6d16638878 100644 --- a/third_party/move/move-compiler-v2/tests/op-equal/valid2.exp +++ b/third_party/move/move-compiler-v2/tests/op-equal/valid2.exp @@ -3,38 +3,61 @@ module 0xc0ffee::m { struct S { x: u64, } - private fun foo(self: &mut m::S): u64 { + private fun foo(self: &mut 0xc0ffee::m::S): u64 { { - let $t1: &mut u64 = Borrow(Mutable)(select m::S.x<&mut m::S>(self)); + let $t1: &mut u64 = Borrow(Mutable)(select m::S.x<&mut S>(self)); $t1 = Add(Deref($t1), 1) }; 1 } public fun test(): u64 { { - let s: m::S = pack m::S(0); + let s: S = pack m::S(0); { let $t2: u64 = m::foo(Borrow(Mutable)(s)); { - let $t1: &mut u64 = Borrow(Mutable)(select m::S.x(s)); + let $t1: &mut u64 = Borrow(Mutable)(select m::S.x(s)); $t1 = Add(Deref($t1), $t2) } }; - select m::S.x(s) + select m::S.x(s) } } } // end 0xc0ffee::m +// -- Sourcified model before bytecode pipeline +module 0xc0ffee::m { + struct S has drop { + x: u64, + } + fun foo(self: &mut S): u64 { + { + let $t1 = &mut self.x; + *$t1 = *$t1 + 1 + }; + 1 + } + public fun test(): u64 { + let s = S{x: 0}; + { + let $t2 = foo(&mut s); + let $t1 = &mut s.x; + *$t1 = *$t1 + $t2 + }; + s.x + } +} + ============ initial bytecode ================ [variant baseline] -fun m::foo($t0: &mut m::S): u64 { +fun m::foo($t0: &mut 0xc0ffee::m::S): u64 { var $t1: u64 var $t2: &mut u64 var $t3: u64 var $t4: u64 var $t5: u64 - 0: $t2 := borrow_field.x($t0) + 0: $t2 := borrow_field<0xc0ffee::m::S>.x($t0) 1: $t4 := read_ref($t2) 2: $t5 := 1 3: $t3 := +($t4, $t5) @@ -47,27 +70,27 @@ fun m::foo($t0: &mut m::S): u64 { [variant baseline] public fun m::test(): u64 { var $t0: u64 - var $t1: m::S + var $t1: 0xc0ffee::m::S var $t2: u64 var $t3: u64 - var $t4: &mut m::S + var $t4: &mut 0xc0ffee::m::S var $t5: &mut u64 - var $t6: &mut m::S + var $t6: &mut 0xc0ffee::m::S var $t7: u64 var $t8: u64 - var $t9: &m::S + var $t9: &0xc0ffee::m::S var $t10: &u64 0: $t2 := 0 - 1: $t1 := pack m::S($t2) + 1: $t1 := pack 0xc0ffee::m::S($t2) 2: $t4 := borrow_local($t1) 3: $t3 := m::foo($t4) 4: $t6 := borrow_local($t1) - 5: $t5 := borrow_field.x($t6) + 5: $t5 := borrow_field<0xc0ffee::m::S>.x($t6) 6: $t8 := read_ref($t5) 7: $t7 := +($t8, $t3) 8: write_ref($t5, $t7) 9: $t9 := borrow_local($t1) - 10: $t10 := borrow_field.x($t9) + 10: $t10 := borrow_field<0xc0ffee::m::S>.x($t9) 11: $t0 := read_ref($t10) 12: return $t0 } @@ -75,14 +98,14 @@ public fun m::test(): u64 { ============ after LiveVarAnalysisProcessor: ================ [variant baseline] -fun m::foo($t0: &mut m::S): u64 { +fun m::foo($t0: &mut 0xc0ffee::m::S): u64 { var $t1: u64 [unused] var $t2: &mut u64 var $t3: u64 [unused] var $t4: u64 var $t5: u64 # live vars: $t0 - 0: $t2 := borrow_field.x($t0) + 0: $t2 := borrow_field<0xc0ffee::m::S>.x($t0) # live vars: $t2 1: $t4 := read_ref($t2) # live vars: $t2, $t4 @@ -101,20 +124,20 @@ fun m::foo($t0: &mut m::S): u64 { [variant baseline] public fun m::test(): u64 { var $t0: u64 [unused] - var $t1: m::S + var $t1: 0xc0ffee::m::S var $t2: u64 var $t3: u64 [unused] - var $t4: &mut m::S + var $t4: &mut 0xc0ffee::m::S var $t5: &mut u64 - var $t6: &mut m::S [unused] + var $t6: &mut 0xc0ffee::m::S [unused] var $t7: u64 [unused] var $t8: u64 - var $t9: &m::S + var $t9: &0xc0ffee::m::S var $t10: &u64 # live vars: 0: $t2 := 0 # live vars: $t2 - 1: $t1 := pack m::S($t2) + 1: $t1 := pack 0xc0ffee::m::S($t2) # live vars: $t1 2: $t4 := borrow_local($t1) # live vars: $t1, $t4 @@ -122,7 +145,7 @@ public fun m::test(): u64 { # live vars: $t1, $t2 4: $t4 := borrow_local($t1) # live vars: $t1, $t2, $t4 - 5: $t5 := borrow_field.x($t4) + 5: $t5 := borrow_field<0xc0ffee::m::S>.x($t4) # live vars: $t1, $t2, $t5 6: $t8 := read_ref($t5) # live vars: $t1, $t2, $t5, $t8 @@ -132,7 +155,7 @@ public fun m::test(): u64 { # live vars: $t1 9: $t9 := borrow_local($t1) # live vars: $t9 - 10: $t10 := borrow_field.x($t9) + 10: $t10 := borrow_field<0xc0ffee::m::S>.x($t9) # live vars: $t10 11: $t2 := read_ref($t10) # live vars: $t2 diff --git a/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/return_with_borrowed_loc_resource_invalid.exp b/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/return_with_borrowed_loc_resource_invalid.exp index 64d4f1e8ca18c..2845d31a0fb6f 100644 --- a/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/return_with_borrowed_loc_resource_invalid.exp +++ b/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/return_with_borrowed_loc_resource_invalid.exp @@ -1,6 +1,6 @@ Diagnostics: -error: local `s` of type `M::X` does not have the `drop` ability +error: local `s` of type `X` does not have the `drop` ability ┌─ tests/reference-safety/v1-borrow-tests/return_with_borrowed_loc_resource_invalid.move:6:18 │ 6 │ let u = &s.u; diff --git a/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/return_with_borrowed_loc_resource_invalid.no-opt.exp b/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/return_with_borrowed_loc_resource_invalid.no-opt.exp index 64d4f1e8ca18c..2845d31a0fb6f 100644 --- a/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/return_with_borrowed_loc_resource_invalid.no-opt.exp +++ b/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/return_with_borrowed_loc_resource_invalid.no-opt.exp @@ -1,6 +1,6 @@ Diagnostics: -error: local `s` of type `M::X` does not have the `drop` ability +error: local `s` of type `X` does not have the `drop` ability ┌─ tests/reference-safety/v1-borrow-tests/return_with_borrowed_loc_resource_invalid.move:6:18 │ 6 │ let u = &s.u; diff --git a/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/return_with_borrowed_loc_resource_invalid.old.exp b/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/return_with_borrowed_loc_resource_invalid.old.exp index 64d4f1e8ca18c..2845d31a0fb6f 100644 --- a/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/return_with_borrowed_loc_resource_invalid.old.exp +++ b/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/return_with_borrowed_loc_resource_invalid.old.exp @@ -1,6 +1,6 @@ Diagnostics: -error: local `s` of type `M::X` does not have the `drop` ability +error: local `s` of type `X` does not have the `drop` ability ┌─ tests/reference-safety/v1-borrow-tests/return_with_borrowed_loc_resource_invalid.move:6:18 │ 6 │ let u = &s.u; diff --git a/third_party/move/move-compiler-v2/tests/simplifier-elimination/always_false_branch.exp b/third_party/move/move-compiler-v2/tests/simplifier-elimination/always_false_branch.exp index 1b0ab31f62f3e..51f43c5de7f9b 100644 --- a/third_party/move/move-compiler-v2/tests/simplifier-elimination/always_false_branch.exp +++ b/third_party/move/move-compiler-v2/tests/simplifier-elimination/always_false_branch.exp @@ -14,5 +14,17 @@ module 0xc0ffee::m { } } // end 0xc0ffee::m +// -- Sourcified model before bytecode pipeline +module 0xc0ffee::m { + fun test(): u64 { + if (false) { + let i = 0; + i = i + 1; + return i + }; + 0 + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/simplifier-elimination/assign_unpack_references.exp b/third_party/move/move-compiler-v2/tests/simplifier-elimination/assign_unpack_references.exp index 338b267835624..ecbeecf5320d2 100644 --- a/third_party/move/move-compiler-v2/tests/simplifier-elimination/assign_unpack_references.exp +++ b/third_party/move/move-compiler-v2/tests/simplifier-elimination/assign_unpack_references.exp @@ -1,8 +1,8 @@ // -- Model dump before bytecode pipeline module 0x8675309::M { struct R { - s1: M::S, - s2: M::S, + s1: 0x8675309::M::S, + s2: 0x8675309::M::S, } struct S { f: u64, @@ -11,12 +11,12 @@ module 0x8675309::M { { let f: u64; { - let s2: M::S; + let s2: S; M::R{ s1: M::S{ f }, s2 } = pack M::R(pack M::S(0), pack M::S(1)); f; s2; f: u64 = 0; - s2: M::S = pack M::S(0); + s2: S = pack M::S(0); f; s2; Tuple() @@ -27,12 +27,12 @@ module 0x8675309::M { { let f: &u64; { - let s2: &M::S; + let s2: &S; M::R{ s1: M::S{ f }, s2 } = Borrow(Immutable)(pack M::R(pack M::S(0), pack M::S(1))); f; s2; f: &u64 = Borrow(Immutable)(0); - s2: &M::S = Borrow(Immutable)(pack M::S(0)); + s2: &S = Borrow(Immutable)(pack M::S(0)); f; s2; Tuple() @@ -43,12 +43,12 @@ module 0x8675309::M { { let f: &mut u64; { - let s2: &mut M::S; + let s2: &mut S; M::R{ s1: M::S{ f }, s2 } = Borrow(Mutable)(pack M::R(pack M::S(0), pack M::S(1))); f; s2; f: &mut u64 = Borrow(Mutable)(0); - s2: &mut M::S = Borrow(Mutable)(pack M::S(0)); + s2: &mut S = Borrow(Mutable)(pack M::S(0)); f; s2; Tuple() @@ -57,15 +57,59 @@ module 0x8675309::M { } } // end 0x8675309::M +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R { + s1: S, + s2: S, + } + struct S has drop { + f: u64, + } + fun t0() { + let f; + let s2; + R{s1: S{f: f},s2: s2} = R{s1: S{f: 0},s2: S{f: 1}}; + f; + s2; + f = 0; + s2 = S{f: 0}; + f; + s2; + } + fun t1() { + let f; + let s2; + R{s1: S{f: f},s2: s2} = &R{s1: S{f: 0},s2: S{f: 1}}; + f; + s2; + f = &0; + s2 = &S{f: 0}; + f; + s2; + } + fun t2() { + let f; + let s2; + R{s1: S{f: f},s2: s2} = &mut R{s1: S{f: 0},s2: S{f: 1}}; + f; + s2; + f = &mut 0; + s2 = &mut S{f: 0}; + f; + s2; + } +} + Diagnostics: -error: value of type `M::R` does not have the `drop` ability +error: value of type `R` does not have the `drop` ability ┌─ tests/simplifier-elimination/assign_unpack_references.move:17:33 │ 17 │ R { s1: S { f }, s2 } = &R { s1: S{f: 0}, s2: S{f: 1} }; f; s2; │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ still borrowed but will be implicitly dropped later since it is no longer used -error: value of type `M::R` does not have the `drop` ability +error: value of type `R` does not have the `drop` ability ┌─ tests/simplifier-elimination/assign_unpack_references.move:27:33 │ 27 │ R { s1: S { f }, s2 } = &mut R { s1: S{f: 0}, s2: S{f: 1} }; f; s2; diff --git a/third_party/move/move-compiler-v2/tests/simplifier-elimination/binary_add.exp b/third_party/move/move-compiler-v2/tests/simplifier-elimination/binary_add.exp index 2cf7745cb0aa4..17be3e272d322 100644 --- a/third_party/move/move-compiler-v2/tests/simplifier-elimination/binary_add.exp +++ b/third_party/move/move-compiler-v2/tests/simplifier-elimination/binary_add.exp @@ -53,10 +53,10 @@ module 0x8675309::M { struct R { f: u64, } - private fun t0(x: u64,r: M::R) { + private fun t0(x: u64,r: 0x8675309::M::R) { Add(Copy(x), Move(x)); - Add(select M::R.f(r), select M::R.f(r)); - Add(Add(Add(1, select M::R.f(r)), select M::R.f(r)), 0); + Add(select M::R.f(r), select M::R.f(r)); + Add(Add(Add(1, select M::R.f(r)), select M::R.f(r)), 0); { let M::R{ f: _ } = r; Tuple() @@ -64,5 +64,18 @@ module 0x8675309::M { } } // end 0x8675309::M +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R { + f: u64, + } + fun t0(x: u64, r: R) { + (copy x) + (move x); + r.f + r.f; + 1 + r.f + r.f + 0; + let R{f: _} = r; + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/simplifier-elimination/bind_with_type_annot.exp b/third_party/move/move-compiler-v2/tests/simplifier-elimination/bind_with_type_annot.exp index 8568e22ecebc0..1f36cd2a23f36 100644 --- a/third_party/move/move-compiler-v2/tests/simplifier-elimination/bind_with_type_annot.exp +++ b/third_party/move/move-compiler-v2/tests/simplifier-elimination/bind_with_type_annot.exp @@ -31,12 +31,22 @@ module 0x8675309::M { } private fun t0() { { - let (x: u64, b: bool, M::R{ f }): (u64, bool, M::R) = Tuple(0, false, pack M::R(0)); + let (x: u64, b: bool, M::R{ f }): (u64, bool, R) = Tuple(0, false, pack M::R(0)); Tuple() } } } // end 0x8675309::M +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct R { + f: u64, + } + fun t0() { + let (x,b,R{f: f}) = (0, false, R{f: 0}); + } +} + Diagnostics: warning: Unused assignment to `f`. Consider removing or prefixing with an underscore: `_f` diff --git a/third_party/move/move-compiler-v2/tests/simplifier-elimination/constant_all_valid_types.exp b/third_party/move/move-compiler-v2/tests/simplifier-elimination/constant_all_valid_types.exp index a92a5c0f0eaca..ed3b1526f28c9 100644 --- a/third_party/move/move-compiler-v2/tests/simplifier-elimination/constant_all_valid_types.exp +++ b/third_party/move/move-compiler-v2/tests/simplifier-elimination/constant_all_valid_types.exp @@ -72,5 +72,34 @@ module _0 { } } // end _0 +// -- Sourcified model before bytecode pipeline +module 0x42::M { + fun t1(): u8 { + 0u8 + } + fun t2(): u64 { + 0 + } + fun t3(): u128 { + 0u128 + } + fun t4(): bool { + false + } + fun t5(): address { + 0x0 + } + fun t6(): vector { + vector[1u8, 35u8] + } + fun t7(): vector { + vector[97u8, 98u8, 99u8, 100u8] + } +} +script { + fun t() { + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/simplifier-elimination/double_nesting.exp b/third_party/move/move-compiler-v2/tests/simplifier-elimination/double_nesting.exp index 704e33333decc..013e348b7560a 100644 --- a/third_party/move/move-compiler-v2/tests/simplifier-elimination/double_nesting.exp +++ b/third_party/move/move-compiler-v2/tests/simplifier-elimination/double_nesting.exp @@ -22,5 +22,24 @@ module 0x42::test { } } // end 0x42::test +// -- Sourcified model before bytecode pipeline +module 0x42::mathtest2 { + public inline fun fun2(a: u64, b: u64, c: u64): u64 { + 7u128 * (a as u128) + 11u128 * (b as u128) + 13u128 * (c as u128) as u64 + } +} +module 0x42::mathtest { + public inline fun fun1(a: u64, b: u64, c: u64): u64 { + 2u128 * (a as u128) + 3u128 * (b as u128) + 5u128 * (c as u128) as u64 + } +} +module 0x42::test { + use 0x42::mathtest2; + use 0x42::mathtest; + fun test_nested_fun1() { + if (true) () else abort 0; + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/simplifier-elimination/else_assigns_if_doesnt.exp b/third_party/move/move-compiler-v2/tests/simplifier-elimination/else_assigns_if_doesnt.exp index 5341e02a3dceb..dc7f6f24d283d 100644 --- a/third_party/move/move-compiler-v2/tests/simplifier-elimination/else_assigns_if_doesnt.exp +++ b/third_party/move/move-compiler-v2/tests/simplifier-elimination/else_assigns_if_doesnt.exp @@ -24,6 +24,21 @@ module _0 { } } // end _0 +// -- Sourcified model before bytecode pipeline +script { + fun main() { + let x; + let y; + if (true) { + y = 0; + } else { + x = 42; + x; + }; + if (y == 0) () else abort 42; + } +} + Diagnostics: error: use of possibly unassigned local `y` diff --git a/third_party/move/move-compiler-v2/tests/simplifier-elimination/if_assigns_else_doesnt.exp b/third_party/move/move-compiler-v2/tests/simplifier-elimination/if_assigns_else_doesnt.exp index 60725545fcc86..5c7d031f7cbe2 100644 --- a/third_party/move/move-compiler-v2/tests/simplifier-elimination/if_assigns_else_doesnt.exp +++ b/third_party/move/move-compiler-v2/tests/simplifier-elimination/if_assigns_else_doesnt.exp @@ -24,6 +24,21 @@ module _0 { } } // end _0 +// -- Sourcified model before bytecode pipeline +script { + fun main() { + let x; + let y; + if (true) { + x = 42; + } else { + y = 0; + y; + }; + if (x == 42) () else abort 42; + } +} + Diagnostics: error: use of possibly unassigned local `x` diff --git a/third_party/move/move-compiler-v2/tests/simplifier-elimination/if_assigns_no_else.exp b/third_party/move/move-compiler-v2/tests/simplifier-elimination/if_assigns_no_else.exp index 73f3d514c0647..7d45092d77f72 100644 --- a/third_party/move/move-compiler-v2/tests/simplifier-elimination/if_assigns_no_else.exp +++ b/third_party/move/move-compiler-v2/tests/simplifier-elimination/if_assigns_no_else.exp @@ -25,5 +25,14 @@ module _0 { } } // end _0 +// -- Sourcified model before bytecode pipeline +script { + fun main() { + let x; + x = 42; + if (x == 42) () else abort 42; + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/simplifier-elimination/if_condition.exp b/third_party/move/move-compiler-v2/tests/simplifier-elimination/if_condition.exp index d78ee58957b72..564bc31ccabb0 100644 --- a/third_party/move/move-compiler-v2/tests/simplifier-elimination/if_condition.exp +++ b/third_party/move/move-compiler-v2/tests/simplifier-elimination/if_condition.exp @@ -54,5 +54,13 @@ module 0x8675309::M { } } // end 0x8675309::M +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + fun t0() { + } + fun t1() { + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/simplifier-elimination/moved_var_not_simplified.exp b/third_party/move/move-compiler-v2/tests/simplifier-elimination/moved_var_not_simplified.exp index 6541388dec1c1..5993472addce0 100644 --- a/third_party/move/move-compiler-v2/tests/simplifier-elimination/moved_var_not_simplified.exp +++ b/third_party/move/move-compiler-v2/tests/simplifier-elimination/moved_var_not_simplified.exp @@ -11,6 +11,15 @@ module 0xc0ffee::m { } } // end 0xc0ffee::m +// -- Sourcified model before bytecode pipeline +module 0xc0ffee::m { + public fun test(): u8 { + let x = 40u8; + let y = move x; + x + y + } +} + Diagnostics: error: cannot move local `x` since it is still in use diff --git a/third_party/move/move-compiler-v2/tests/simplifier-elimination/moved_var_not_simplified2.exp b/third_party/move/move-compiler-v2/tests/simplifier-elimination/moved_var_not_simplified2.exp index e464e08c45a5e..d68aa02f51c4c 100644 --- a/third_party/move/move-compiler-v2/tests/simplifier-elimination/moved_var_not_simplified2.exp +++ b/third_party/move/move-compiler-v2/tests/simplifier-elimination/moved_var_not_simplified2.exp @@ -14,6 +14,16 @@ module 0xc0ffee::m { } } // end 0xc0ffee::m +// -- Sourcified model before bytecode pipeline +module 0xc0ffee::m { + public fun test(): u8 { + let x = 40u8; + let y = move x; + let _z = x; + y + } +} + Diagnostics: error: cannot move local `x` since it is still in use diff --git a/third_party/move/move-compiler-v2/tests/simplifier-elimination/recursive_nesting.exp b/third_party/move/move-compiler-v2/tests/simplifier-elimination/recursive_nesting.exp index a7c00dc82c2a1..be3551312c2b4 100644 --- a/third_party/move/move-compiler-v2/tests/simplifier-elimination/recursive_nesting.exp +++ b/third_party/move/move-compiler-v2/tests/simplifier-elimination/recursive_nesting.exp @@ -39,5 +39,35 @@ module 0x42::test { } } // end 0x42::test +// -- Sourcified model before bytecode pipeline +module 0x42::mathtest { + public inline fun mul_div(a: u64, b: u64, c: u64): u64 { + (a as u128) * (b as u128) / (c as u128) as u64 + } +} +module 0x42::mathtest2 { + use 0x42::mathtest; + public inline fun mul_div2(a: u64, b: u64, c: u64): u64 { + let (a,b,c) = (b, a, c); + (a as u128) * (b as u128) / (c as u128) as u64 + } +} +module 0x42::mathtest3 { + use 0x42::mathtest2; + public inline fun mul_div3(a: u64, b: u64, c: u64): u64 { + let (a,b,c) = (b, a, c); + let (a,b,c) = (b, a, c); + (a as u128) * (b as u128) / (c as u128) as u64 + } +} +module 0x42::test { + use 0x42::mathtest; + use 0x42::mathtest2; + use 0x42::mathtest3; + fun test_nested_mul_div() { + if (true) () else abort 0; + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/simplifier-elimination/use_before_assign.exp b/third_party/move/move-compiler-v2/tests/simplifier-elimination/use_before_assign.exp index ac63e9d86f699..2cd3b3cdb5ccb 100644 --- a/third_party/move/move-compiler-v2/tests/simplifier-elimination/use_before_assign.exp +++ b/third_party/move/move-compiler-v2/tests/simplifier-elimination/use_before_assign.exp @@ -19,6 +19,14 @@ module _0 { } } // end _0 +// -- Sourcified model before bytecode pipeline +script { + fun main() { + let x; + let y = x; + } +} + Diagnostics: error: use of unassigned local `x` diff --git a/third_party/move/move-compiler-v2/tests/simplifier-elimination/use_before_assign_loop.exp b/third_party/move/move-compiler-v2/tests/simplifier-elimination/use_before_assign_loop.exp index 56337567699df..549cc95c615c2 100644 --- a/third_party/move/move-compiler-v2/tests/simplifier-elimination/use_before_assign_loop.exp +++ b/third_party/move/move-compiler-v2/tests/simplifier-elimination/use_before_assign_loop.exp @@ -64,6 +64,45 @@ module 0x8675309::M { } } // end 0x8675309::M +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + fun tborrow1() { + let x; + loop { + let y = &x; + _ = move y; + x = 0 + } + } + fun tborrow2(cond: bool) { + let x; + loop { + let y = &x; + _ = move y; + if (cond) x = 0; + break + }; + x; + } + fun tcopy(cond: bool) { + let x; + loop { + let y = x + 1; + if (cond) continue; + x = 0; + y; + } + } + fun tmove() { + let x; + loop { + let y = (move x) + 1; + x = 0; + y; + } + } +} + Diagnostics: error: use of possibly unassigned local `x` diff --git a/third_party/move/move-compiler-v2/tests/simplifier-elimination/use_before_assign_while.exp b/third_party/move/move-compiler-v2/tests/simplifier-elimination/use_before_assign_while.exp index 2152707901fdc..ee8a0531edccb 100644 --- a/third_party/move/move-compiler-v2/tests/simplifier-elimination/use_before_assign_while.exp +++ b/third_party/move/move-compiler-v2/tests/simplifier-elimination/use_before_assign_while.exp @@ -78,6 +78,44 @@ module 0x8675309::M { } } // end 0x8675309::M +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + fun tborrow1(cond: bool) { + let x; + while (cond) { + let y = &x; + _ = move y; + x = 0 + } + } + fun tborrow2(cond: bool) { + let x; + while (cond) { + let y = &x; + _ = move y; + if (cond) x = 0; + break + } + } + fun tcopy(cond: bool) { + let x; + while (cond) { + let y = (move x) + 1; + if (cond) continue; + x = 0; + y; + } + } + fun tmove(cond: bool) { + let x; + while (cond) { + let y = (move x) + 1; + x = 0; + y; + } + } +} + Diagnostics: error: use of possibly unassigned local `x` diff --git a/third_party/move/move-compiler-v2/tests/simplifier/bug_11112.exp b/third_party/move/move-compiler-v2/tests/simplifier/bug_11112.exp index 2d26e677fd493..fb79d81744afa 100644 --- a/third_party/move/move-compiler-v2/tests/simplifier/bug_11112.exp +++ b/third_party/move/move-compiler-v2/tests/simplifier/bug_11112.exp @@ -35,5 +35,26 @@ module 0xcafe::vectors { } } // end 0xcafe::vectors +// -- Sourcified model before bytecode pipeline +module 0xcafe::vectors { + fun test_for_each_mut() { + let v = vector[1, 2, 3]; + let s = 2; + { + let (v) = (&mut v); + let i = 0; + while (i < 0x1::vector::length(/*freeze*/v)) { + { + let (e) = (0x1::vector::borrow_mut(v, i)); + *e = s; + s = s + 1 + }; + i = i + 1 + } + }; + if (v == vector[2, 3, 4]) () else abort 0; + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/simplifier/conditional_borrow.exp b/third_party/move/move-compiler-v2/tests/simplifier/conditional_borrow.exp index fe3356ff35068..244c465398f02 100644 --- a/third_party/move/move-compiler-v2/tests/simplifier/conditional_borrow.exp +++ b/third_party/move/move-compiler-v2/tests/simplifier/conditional_borrow.exp @@ -47,39 +47,39 @@ module 0x8675::M { } } } - private fun test1b(r: M::S): u64 { + private fun test1b(r: 0x8675::M::S): u64 { { - let x: M::S = pack M::S(3); + let x: S = pack M::S(3); { - let tref: &mut M::S = Borrow(Mutable)(if Lt(select M::S.f(r), 4) { + let tref: &mut S = Borrow(Mutable)(if Lt(select M::S.f(r), 4) { r } else { x }); - select M::S.f(Deref(tref)) = 10; + select M::S.f(Deref(tref)) = 10; { - let y: M::S = r; + let y: S = r; { - let tref2: &mut M::S = Borrow(Mutable)(y); - select M::S.f(Deref(tref2)) = Add(select M::S.f(Deref(tref2)), 1); + let tref2: &mut S = Borrow(Mutable)(y); + select M::S.f(Deref(tref2)) = Add(select M::S.f(Deref(tref2)), 1); { - let z: M::S = y; + let z: S = y; { - let tref3: &mut u64 = Borrow(Mutable)(select M::S.f(z)); + let tref3: &mut u64 = Borrow(Mutable)(select M::S.f(z)); tref3 = Add(Deref(tref3), 1); { - let a: M::S = z; + let a: S = z; { - let tref4: &mut u64 = Borrow(Mutable)(select M::S.f(a)); + let tref4: &mut u64 = Borrow(Mutable)(select M::S.f(a)); tref4 = Add(Deref(tref4), 1); { - let tref5: &mut u64 = Borrow(Mutable)(select M::S.f(a)); + let tref5: &mut u64 = Borrow(Mutable)(select M::S.f(a)); tref5 = Add(Deref(tref5), 8); { let tref6: &mut u64 = Borrow(Mutable)(3; - select M::S.f(a)); + select M::S.f(a)); tref6 = Add(Deref(tref6), 16); - select M::S.f(a) + select M::S.f(a) } } } @@ -96,5 +96,61 @@ module 0x8675::M { } } // end 0x8675::M +// -- Sourcified model before bytecode pipeline +module 0x8675::M { + struct S has copy, drop { + f: u64, + } + public fun test(): u64 { + test1(7) + test1(2) + } + fun test1(r: u64): u64 { + let tref = &mut (if (r < 4) r else 3); + *tref = 10; + let y = r; + let tref2 = &mut y; + *tref2 = *tref2 + 1; + let z = y; + let tref3 = &mut (z + 0); + *tref3 = *tref3 + 2; + let a = z; + let tref4 = &mut a; + *tref4 = *tref4 + 4; + let tref5 = &mut a; + *tref5 = *tref5 + 8; + let tref6 = &mut { + 3; + a + }; + *tref6 = *tref6 + 16; + a + } + fun test1b(r: S): u64 { + let x = S{f: 3}; + let tref = &mut (if (r.f < 4) r else x); + (*tref).f = 10; + let y = r; + let tref2 = &mut y; + (*tref2).f = (*tref2).f + 1; + let z = y; + let tref3 = &mut z.f; + *tref3 = *tref3 + 1; + let a = z; + let tref4 = &mut a.f; + *tref4 = *tref4 + 1; + let tref5 = &mut a.f; + *tref5 = *tref5 + 8; + let tref6 = &mut { + 3; + a.f + }; + *tref6 = *tref6 + 16; + a.f + } + public fun testb(): u64 { + test1b(S{f: 7}) + test1b(S{f: 2}) + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/simplifier/constant_folding_addresses.exp b/third_party/move/move-compiler-v2/tests/simplifier/constant_folding_addresses.exp index 4d021dd51d00d..e8ce9561931f2 100644 --- a/third_party/move/move-compiler-v2/tests/simplifier/constant_folding_addresses.exp +++ b/third_party/move/move-compiler-v2/tests/simplifier/constant_folding_addresses.exp @@ -11,5 +11,12 @@ module 0xcafe::Addresses { } } // end 0xcafe::Addresses +// -- Sourcified model before bytecode pipeline +module 0xcafe::Addresses { + public fun test() { + if (0x1::vector::length
(&vector[0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234]) == 1845) () else abort 1; + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/simplifier/constant_folding_ristretto.exp b/third_party/move/move-compiler-v2/tests/simplifier/constant_folding_ristretto.exp index bf7ddb3eda7a4..dfe310b087e21 100644 --- a/third_party/move/move-compiler-v2/tests/simplifier/constant_folding_ristretto.exp +++ b/third_party/move/move-compiler-v2/tests/simplifier/constant_folding_ristretto.exp @@ -10,5 +10,12 @@ module 0xcafe::Ristretto { } } // end 0xcafe::Ristretto +// -- Sourcified model before bytecode pipeline +module 0xcafe::Ristretto { + public fun test() { + if (true) () else abort 1; + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/simplifier/deep_exp.exp b/third_party/move/move-compiler-v2/tests/simplifier/deep_exp.exp index 5651a5e32c294..9d4e0ede67812 100644 --- a/third_party/move/move-compiler-v2/tests/simplifier/deep_exp.exp +++ b/third_party/move/move-compiler-v2/tests/simplifier/deep_exp.exp @@ -2930,5 +2930,2549 @@ module 0x42::Test { } } // end 0x42::Test +// -- Sourcified model before bytecode pipeline +module 0x42::Test { + inline fun f1(x: u64): u64 { + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + } + inline fun f2(x: u64): u64 { + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + } + inline fun f3(x: u64): u64 { + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + } + inline fun f4(x: u64): u64 { + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = ({ + let (x) = (x); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + }); + x + 1 + } + inline fun f5(x: u64): u64 { + x + 1 + } + public fun test(): u64 { + 625 + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/simplifier/moved_var_not_simplified.exp b/third_party/move/move-compiler-v2/tests/simplifier/moved_var_not_simplified.exp index 4e64252a12e5a..bba70e2914393 100644 --- a/third_party/move/move-compiler-v2/tests/simplifier/moved_var_not_simplified.exp +++ b/third_party/move/move-compiler-v2/tests/simplifier/moved_var_not_simplified.exp @@ -11,6 +11,15 @@ module 0xc0ffee::m { } } // end 0xc0ffee::m +// -- Sourcified model before bytecode pipeline +module 0xc0ffee::m { + public fun test(): u8 { + let x = 40u8; + let y = move x; + x + y + } +} + Diagnostics: error: cannot move local `x` since it is still in use diff --git a/third_party/move/move-compiler-v2/tests/simplifier/moved_var_not_simplified2.exp b/third_party/move/move-compiler-v2/tests/simplifier/moved_var_not_simplified2.exp index 25ab7c17592e2..5e4a6305ef61b 100644 --- a/third_party/move/move-compiler-v2/tests/simplifier/moved_var_not_simplified2.exp +++ b/third_party/move/move-compiler-v2/tests/simplifier/moved_var_not_simplified2.exp @@ -14,6 +14,16 @@ module 0xc0ffee::m { } } // end 0xc0ffee::m +// -- Sourcified model before bytecode pipeline +module 0xc0ffee::m { + public fun test(): u8 { + let x = 40u8; + let y = move x; + let _z = x; + y + } +} + Diagnostics: error: cannot move local `x` since it is still in use diff --git a/third_party/move/move-compiler-v2/tests/simplifier/random.exp b/third_party/move/move-compiler-v2/tests/simplifier/random.exp index 89901686f6d2a..6e0e8a65c6213 100644 --- a/third_party/move/move-compiler-v2/tests/simplifier/random.exp +++ b/third_party/move/move-compiler-v2/tests/simplifier/random.exp @@ -143,6 +143,83 @@ module 0x8675::M { } } // end 0x8675::M +// -- Sourcified model before bytecode pipeline +module 0x8675::M { + struct S { + f: u64, + g: u64, + } + fun id(r: &T): &T { + r + } + fun id_mut(r: &mut T): &mut T { + r + } + inline fun iterloop(x: u64, y: &u64): u64 { + let r = x + 3; + while (x > 0) { + x = x - *y; + }; + r + x + } + fun t0() { + let v = 0; + let x = &mut v; + let y = &mut v; + *x; + *y; + if (v == 0) { + v = 3; + } else { + v = 2; + }; + let q = v; + let x = id_mut(&mut v); + let y = &mut v; + *x; + *y; + let x = &v; + let y = &mut v; + *y; + *x; + *y; + let x = &v; + let y = &v; + *x; + *y; + *x; + let x = id(&v); + let y = &v; + *x; + *y; + *x; + } + fun test1(r: u64): u64 { + let t = r; + let t2 = 0; + while (r > 0) { + let x = r; + r = r - 1; + t2 = t2 + x; + }; + let t3 = r + t + t2; + t3 + } + fun test1a(x: u64, r: &u64): u64 { + let t = *r; + let t3 = { + let (x,y) = (x, r); + let r = x + 3; + while (x > 0) { + x = x - *y; + }; + r + x + }; + let t2 = *r + t; + t2 + t3 + t + } +} + Diagnostics: warning: Unused assignment to `q`. Consider removing or prefixing with an underscore: `_q` diff --git a/third_party/move/move-compiler-v2/tests/simplifier/simplifier_test1.exp b/third_party/move/move-compiler-v2/tests/simplifier/simplifier_test1.exp index 17267d722a3a2..1b31a2726a83f 100644 --- a/third_party/move/move-compiler-v2/tests/simplifier/simplifier_test1.exp +++ b/third_party/move/move-compiler-v2/tests/simplifier/simplifier_test1.exp @@ -29,5 +29,23 @@ module 0x8675::M { } } // end 0x8675::M +// -- Sourcified model before bytecode pipeline +module 0x8675::M { + public fun test(): u64 { + test1(10) + } + fun test1(r: u64): u64 { + let t = r; + let t2 = 0; + while (r > 0) { + let x = r; + r = r - 1; + t2 = t2 + x; + }; + let t3 = r + t + t2; + t3 + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/simplifier/simplifier_test2.exp b/third_party/move/move-compiler-v2/tests/simplifier/simplifier_test2.exp index 761a7351a5fde..78ce707a0ac1e 100644 --- a/third_party/move/move-compiler-v2/tests/simplifier/simplifier_test2.exp +++ b/third_party/move/move-compiler-v2/tests/simplifier/simplifier_test2.exp @@ -53,5 +53,32 @@ module 0x8675::M { } } // end 0x8675::M +// -- Sourcified model before bytecode pipeline +module 0x8675::M { + public fun test(): u64 { + let (r) = (10); + let t = r; + let t2 = 0; + while (r > 0) { + let x = r; + r = r - 1; + t2 = t2 + x; + }; + let t3 = r + t + t2; + t3 + } + inline fun test1(r: u64): u64 { + let t = r; + let t2 = 0; + while (r > 0) { + let x = r; + r = r - 1; + t2 = t2 + x; + }; + let t3 = r + t + t2; + t3 + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/simplifier/simplifier_test3.exp b/third_party/move/move-compiler-v2/tests/simplifier/simplifier_test3.exp index be956d2fdd85f..8e06a6591f039 100644 --- a/third_party/move/move-compiler-v2/tests/simplifier/simplifier_test3.exp +++ b/third_party/move/move-compiler-v2/tests/simplifier/simplifier_test3.exp @@ -29,5 +29,24 @@ module 0x8675::M { } } // end 0x8675::M +// -- Sourcified model before bytecode pipeline +module 0x8675::M { + public fun test(): u64 { + test1(10) + } + fun test1(r: u64): u64 { + let t = r; + let t2 = 0; + while ({ + let x = r; + r = r - 1; + t2 = t2 + x; + r > 0 + }) (); + let t3 = r + t + t2; + t3 + } +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/simplifier/simplifier_test4.exp b/third_party/move/move-compiler-v2/tests/simplifier/simplifier_test4.exp index 66b1864dd5f27..47074f5a96c6a 100644 --- a/third_party/move/move-compiler-v2/tests/simplifier/simplifier_test4.exp +++ b/third_party/move/move-compiler-v2/tests/simplifier/simplifier_test4.exp @@ -6,20 +6,20 @@ module 0x8675309::M { private fun bar(_s: &mut u64,_u: u64) { Tuple() } - private fun foo(_s: &M::S,_u: u64) { + private fun foo(_s: &0x8675309::M::S,_u: u64) { Tuple() } - private fun t0(s: &mut M::S) { + private fun t0(s: &mut 0x8675309::M::S) { { let x: u64 = 0; { let f: &mut u64 = x: u64 = Add(x, 1); - Borrow(Mutable)(select M::S.f<&mut M::S>(x: u64 = Add(x, 1); + Borrow(Mutable)(select M::S.f<&mut S>(x: u64 = Add(x, 1); 1; s)); if true { x: u64 = Add(x, 1); - M::foo(Freeze(true)(s), x: u64 = Add(x, 1); + M::foo(Freeze(true)(s), x: u64 = Add(x, 1); f = 0; 1) } else { @@ -34,12 +34,51 @@ module 0x8675309::M { } } } - private fun t1(s: &mut M::S) { - M::bar(Borrow(Mutable)(select M::S.f<&mut M::S>(s)), select M::S.f<&mut M::S>(s) = 0; + private fun t1(s: &mut 0x8675309::M::S) { + M::bar(Borrow(Mutable)(select M::S.f<&mut S>(s)), select M::S.f<&mut S>(s) = 0; 1) } } // end 0x8675309::M +// -- Sourcified model before bytecode pipeline +module 0x8675309::M { + struct S { + f: u64, + } + fun bar(_s: &mut u64, _u: u64) { + } + fun foo(_s: &S, _u: u64) { + } + fun t0(s: &mut S) { + let x = 0; + let f = { + x = x + 1; + &mut { + x = x + 1; + 1; + s + }.f + }; + if (true) { + x = x + 1; + foo(/*freeze*/s, { + *{ + x = x + 1; + f + } = 0; + 1 + }) + } else x = x + 1; + if (x == 4) () else abort 0; + } + fun t1(s: &mut S) { + bar(&mut s.f, { + s.f = 0; + 1 + }) + } +} + Diagnostics: error: cannot freeze value which is still mutably borrowed diff --git a/third_party/move/move-compiler-v2/tests/testsuite.rs b/third_party/move/move-compiler-v2/tests/testsuite.rs index bbc988185007a..ba34279b86a38 100644 --- a/third_party/move/move-compiler-v2/tests/testsuite.rs +++ b/third_party/move/move-compiler-v2/tests/testsuite.rs @@ -11,7 +11,7 @@ use move_compiler_v2::{ logging, pipeline, plan_builder, run_bytecode_verifier, run_file_format_gen, Experiment, Options, }; -use move_model::{metadata::LanguageVersion, model::GlobalEnv}; +use move_model::{metadata::LanguageVersion, model::GlobalEnv, sourcifier::Sourcifier}; use move_prover_test_utils::{baseline_test, extract_test_directives}; use move_stackless_bytecode::function_target_pipeline::FunctionTargetPipeline; use once_cell::unsync::Lazy; @@ -799,6 +799,16 @@ fn run_test(path: &Path, config: TestConfig) -> datatest_stable::Result<()> { "// -- Model dump before bytecode pipeline\n{}\n", env.dump_env() )); + let sourcifier = Sourcifier::new(&env); + for module in env.get_modules() { + if module.is_primary_target() { + sourcifier.print_module(module.get_id()) + } + } + test_output.borrow_mut().push_str(&format!( + "// -- Sourcified model before bytecode pipeline\n{}\n", + sourcifier.result() + )); } } } diff --git a/third_party/move/move-compiler-v2/tests/uninit-use-checker/struct_use_before_assign.exp b/third_party/move/move-compiler-v2/tests/uninit-use-checker/struct_use_before_assign.exp index f343d5441ac03..a133044ef3459 100644 --- a/third_party/move/move-compiler-v2/tests/uninit-use-checker/struct_use_before_assign.exp +++ b/third_party/move/move-compiler-v2/tests/uninit-use-checker/struct_use_before_assign.exp @@ -53,15 +53,15 @@ warning: Unused local variable `q`. Consider removing or prefixing with an under [variant baseline] fun M::main() { var $t0: u64 - var $t1: M::R + var $t1: 0x876543::M::R var $t2: u64 var $t3: u64 var $t4: u64 var $t5: u64 var $t6: u64 0: $t2 := 3 - 1: $t1 := pack M::R($t2, $t0) - 2: ($t3, $t4) := unpack M::R($t1) + 1: $t1 := pack 0x876543::M::R($t2, $t0) + 2: ($t3, $t4) := unpack 0x876543::M::R($t1) 3: $t5 := infer($t4) 4: $t6 := infer($t3) 5: return () @@ -71,15 +71,15 @@ fun M::main() { [variant baseline] fun M::main2() { var $t0: u64 - var $t1: M::R + var $t1: 0x876543::M::R var $t2: u64 var $t3: u64 var $t4: u64 var $t5: u64 var $t6: u64 0: $t2 := 0 - 1: $t1 := pack M::R($t2, $t0) - 2: ($t3, $t4) := unpack M::R($t1) + 1: $t1 := pack 0x876543::M::R($t2, $t0) + 2: ($t3, $t4) := unpack 0x876543::M::R($t1) 3: $t5 := infer($t4) 4: $t6 := infer($t3) 5: return () @@ -88,12 +88,12 @@ fun M::main2() { [variant baseline] fun M::main3() { - var $t0: M::R + var $t0: 0x876543::M::R var $t1: u64 var $t2: u64 var $t3: u64 var $t4: u64 - 0: ($t1, $t2) := unpack M::R($t0) + 0: ($t1, $t2) := unpack 0x876543::M::R($t0) 1: $t3 := infer($t2) 2: $t4 := infer($t1) 3: return () @@ -148,7 +148,7 @@ error: use of unassigned local `x` [variant baseline] fun M::main() { var $t0: u64 - var $t1: M::R + var $t1: 0x876543::M::R var $t2: u64 var $t3: u64 var $t4: u64 @@ -157,9 +157,9 @@ fun M::main() { # before: { no: $t0, $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t0, $t1, $t3, $t4, $t5, $t6 } 0: $t2 := 3 # before: { no: $t0, $t1, $t3, $t4, $t5, $t6 }, after: { no: $t0, $t3, $t4, $t5, $t6 } - 1: $t1 := pack M::R($t2, $t0) + 1: $t1 := pack 0x876543::M::R($t2, $t0) # before: { no: $t0, $t3, $t4, $t5, $t6 }, after: { no: $t0, $t5, $t6 } - 2: ($t3, $t4) := unpack M::R($t1) + 2: ($t3, $t4) := unpack 0x876543::M::R($t1) # before: { no: $t0, $t5, $t6 }, after: { no: $t0, $t6 } 3: $t5 := infer($t4) # before: { no: $t0, $t6 }, after: { no: $t0 } @@ -172,7 +172,7 @@ fun M::main() { [variant baseline] fun M::main2() { var $t0: u64 - var $t1: M::R + var $t1: 0x876543::M::R var $t2: u64 var $t3: u64 var $t4: u64 @@ -181,9 +181,9 @@ fun M::main2() { # before: { no: $t0, $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t0, $t1, $t3, $t4, $t5, $t6 } 0: $t2 := 0 # before: { no: $t0, $t1, $t3, $t4, $t5, $t6 }, after: { no: $t0, $t3, $t4, $t5, $t6 } - 1: $t1 := pack M::R($t2, $t0) + 1: $t1 := pack 0x876543::M::R($t2, $t0) # before: { no: $t0, $t3, $t4, $t5, $t6 }, after: { no: $t0, $t5, $t6 } - 2: ($t3, $t4) := unpack M::R($t1) + 2: ($t3, $t4) := unpack 0x876543::M::R($t1) # before: { no: $t0, $t5, $t6 }, after: { no: $t0, $t6 } 3: $t5 := infer($t4) # before: { no: $t0, $t6 }, after: { no: $t0 } @@ -195,13 +195,13 @@ fun M::main2() { [variant baseline] fun M::main3() { - var $t0: M::R + var $t0: 0x876543::M::R var $t1: u64 var $t2: u64 var $t3: u64 var $t4: u64 # before: { no: $t0, $t1, $t2, $t3, $t4 }, after: { no: $t0, $t3, $t4 } - 0: ($t1, $t2) := unpack M::R($t0) + 0: ($t1, $t2) := unpack 0x876543::M::R($t0) # before: { no: $t0, $t3, $t4 }, after: { no: $t0, $t4 } 1: $t3 := infer($t2) # before: { no: $t0, $t4 }, after: { no: $t0 } diff --git a/third_party/move/move-compiler-v2/tests/uninit-use-checker/unused_reference.exp b/third_party/move/move-compiler-v2/tests/uninit-use-checker/unused_reference.exp index 1749474d122c6..0157525a3a232 100644 --- a/third_party/move/move-compiler-v2/tests/uninit-use-checker/unused_reference.exp +++ b/third_party/move/move-compiler-v2/tests/uninit-use-checker/unused_reference.exp @@ -2,8 +2,8 @@ [variant baseline] public fun Module0::function0() { - var $t0: &Module0::S - var $t1: Module0::S + var $t0: &0xcafe::Module0::S + var $t1: 0xcafe::Module0::S 0: $t1 := read_ref($t0) 1: return () } @@ -20,8 +20,8 @@ error: use of unassigned local `y` [variant baseline] public fun Module0::function0() { - var $t0: &Module0::S - var $t1: Module0::S + var $t0: &0xcafe::Module0::S + var $t1: 0xcafe::Module0::S # before: { no: $t0, $t1 }, after: { no: $t0 } 0: $t1 := read_ref($t0) # before: { no: $t0 }, after: { no: $t0 } diff --git a/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-locals/use_before_assign_simple.exp b/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-locals/use_before_assign_simple.exp index 89b580d92ae0c..46ecf613deaa7 100644 --- a/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-locals/use_before_assign_simple.exp +++ b/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-locals/use_before_assign_simple.exp @@ -5,8 +5,8 @@ fun M::tborrow() { var $t0: u64 var $t1: &u64 var $t2: &u64 - var $t3: M::S - var $t4: &M::S + var $t3: 0x8675309::M::S + var $t4: &0x8675309::M::S 0: $t1 := borrow_local($t0) 1: $t2 := infer($t1) 2: $t4 := borrow_local($t3) @@ -20,8 +20,8 @@ fun M::tcopy() { var $t1: u64 var $t2: u64 var $t3: u64 - var $t4: M::S - var $t5: M::S + var $t4: 0x8675309::M::S + var $t5: 0x8675309::M::S 0: $t2 := 1 1: $t1 := +($t0, $t2) 2: $t3 := infer($t1) @@ -37,8 +37,8 @@ fun M::tmove() { var $t2: u64 var $t3: u64 var $t4: u64 - var $t5: M::S - var $t6: M::S + var $t5: 0x8675309::M::S + var $t6: 0x8675309::M::S 0: $t2 := move($t0) 1: $t3 := 1 2: $t1 := +($t2, $t3) @@ -92,8 +92,8 @@ fun M::tborrow() { var $t0: u64 var $t1: &u64 var $t2: &u64 - var $t3: M::S - var $t4: &M::S + var $t3: 0x8675309::M::S + var $t4: &0x8675309::M::S # before: { no: $t0, $t1, $t2, $t3, $t4 }, after: { no: $t0, $t2, $t3, $t4 } 0: $t1 := borrow_local($t0) # before: { no: $t0, $t2, $t3, $t4 }, after: { no: $t0, $t3, $t4 } @@ -111,8 +111,8 @@ fun M::tcopy() { var $t1: u64 var $t2: u64 var $t3: u64 - var $t4: M::S - var $t5: M::S + var $t4: 0x8675309::M::S + var $t5: 0x8675309::M::S # before: { no: $t0, $t1, $t2, $t3, $t4, $t5 }, after: { no: $t0, $t1, $t3, $t4, $t5 } 0: $t2 := 1 # before: { no: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t0, $t3, $t4, $t5 } @@ -133,8 +133,8 @@ fun M::tmove() { var $t2: u64 var $t3: u64 var $t4: u64 - var $t5: M::S - var $t6: M::S + var $t5: 0x8675309::M::S + var $t6: 0x8675309::M::S # before: { no: $t0, $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t0, $t1, $t3, $t4, $t5, $t6 } 0: $t2 := move($t0) # before: { no: $t0, $t1, $t3, $t4, $t5, $t6 }, after: { no: $t0, $t1, $t4, $t5, $t6 } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_1.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_1.exp index 2f685d7e7352d..74ef544575ec3 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_1.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_1.exp @@ -7,7 +7,7 @@ fun m::consume($t0: u64) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -33,8 +33,8 @@ public fun m::test2($t0: u64) { [variant baseline] -public fun m::test3($t0: m::W) { - var $t1: m::W +public fun m::test3($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W 0: $t1 := infer($t0) 1: m::consume_($t0) 2: m::consume_($t1) @@ -43,8 +43,8 @@ public fun m::test3($t0: m::W) { [variant baseline] -public fun m::test4($t0: m::W) { - var $t1: m::W +public fun m::test4($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W 0: $t1 := infer($t0) 1: m::consume_($t1) 2: m::consume_($t0) @@ -60,7 +60,7 @@ fun m::consume($t0: u64) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -86,8 +86,8 @@ public fun m::test2($t0: u64) { [variant baseline] -public fun m::test3($t0: m::W) { - var $t1: m::W +public fun m::test3($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W 0: $t1 := copy($t0) 1: m::consume_($t0) 2: m::consume_($t1) @@ -96,8 +96,8 @@ public fun m::test3($t0: m::W) { [variant baseline] -public fun m::test4($t0: m::W) { - var $t1: m::W +public fun m::test4($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W 0: $t1 := copy($t0) 1: m::consume_($t1) 2: m::consume_($t0) @@ -115,7 +115,7 @@ fun m::consume($t0: u64) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { # live vars: $t0 # events: b:$t0, e:$t0 0: return () @@ -157,8 +157,8 @@ public fun m::test2($t0: u64) { [variant baseline] -public fun m::test3($t0: m::W) { - var $t1: m::W +public fun m::test3($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W # live vars: $t0 # events: b:$t0, b:$t1 0: $t1 := copy($t0) @@ -174,8 +174,8 @@ public fun m::test3($t0: m::W) { [variant baseline] -public fun m::test4($t0: m::W) { - var $t1: m::W +public fun m::test4($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W # live vars: $t0 # events: b:$t0, b:$t1 0: $t1 := copy($t0) @@ -198,7 +198,7 @@ fun m::consume($t0: u64) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -224,8 +224,8 @@ public fun m::test2($t0: u64) { [variant baseline] -public fun m::test3($t0: m::W) { - var $t1: m::W +public fun m::test3($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W 0: $t1 := copy($t0) 1: m::consume_($t0) 2: m::consume_($t1) @@ -234,8 +234,8 @@ public fun m::test3($t0: m::W) { [variant baseline] -public fun m::test4($t0: m::W) { - var $t1: m::W +public fun m::test4($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W 0: $t1 := copy($t0) 1: m::consume_($t1) 2: m::consume_($t0) @@ -251,7 +251,7 @@ fun m::consume($t0: u64) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -277,8 +277,8 @@ public fun m::test2($t0: u64) { [variant baseline] -public fun m::test3($t0: m::W) { - var $t1: m::W +public fun m::test3($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W 0: $t1 := copy($t0) 1: m::consume_($t0) 2: m::consume_($t1) @@ -287,8 +287,8 @@ public fun m::test3($t0: m::W) { [variant baseline] -public fun m::test4($t0: m::W) { - var $t1: m::W +public fun m::test4($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W 0: $t1 := copy($t0) 1: m::consume_($t1) 2: m::consume_($t0) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_1.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_1.opt.exp index 2f685d7e7352d..74ef544575ec3 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_1.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_1.opt.exp @@ -7,7 +7,7 @@ fun m::consume($t0: u64) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -33,8 +33,8 @@ public fun m::test2($t0: u64) { [variant baseline] -public fun m::test3($t0: m::W) { - var $t1: m::W +public fun m::test3($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W 0: $t1 := infer($t0) 1: m::consume_($t0) 2: m::consume_($t1) @@ -43,8 +43,8 @@ public fun m::test3($t0: m::W) { [variant baseline] -public fun m::test4($t0: m::W) { - var $t1: m::W +public fun m::test4($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W 0: $t1 := infer($t0) 1: m::consume_($t1) 2: m::consume_($t0) @@ -60,7 +60,7 @@ fun m::consume($t0: u64) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -86,8 +86,8 @@ public fun m::test2($t0: u64) { [variant baseline] -public fun m::test3($t0: m::W) { - var $t1: m::W +public fun m::test3($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W 0: $t1 := copy($t0) 1: m::consume_($t0) 2: m::consume_($t1) @@ -96,8 +96,8 @@ public fun m::test3($t0: m::W) { [variant baseline] -public fun m::test4($t0: m::W) { - var $t1: m::W +public fun m::test4($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W 0: $t1 := copy($t0) 1: m::consume_($t1) 2: m::consume_($t0) @@ -115,7 +115,7 @@ fun m::consume($t0: u64) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { # live vars: $t0 # events: b:$t0, e:$t0 0: return () @@ -157,8 +157,8 @@ public fun m::test2($t0: u64) { [variant baseline] -public fun m::test3($t0: m::W) { - var $t1: m::W +public fun m::test3($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W # live vars: $t0 # events: b:$t0, b:$t1 0: $t1 := copy($t0) @@ -174,8 +174,8 @@ public fun m::test3($t0: m::W) { [variant baseline] -public fun m::test4($t0: m::W) { - var $t1: m::W +public fun m::test4($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W # live vars: $t0 # events: b:$t0, b:$t1 0: $t1 := copy($t0) @@ -198,7 +198,7 @@ fun m::consume($t0: u64) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -224,8 +224,8 @@ public fun m::test2($t0: u64) { [variant baseline] -public fun m::test3($t0: m::W) { - var $t1: m::W +public fun m::test3($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W 0: $t1 := copy($t0) 1: m::consume_($t0) 2: m::consume_($t1) @@ -234,8 +234,8 @@ public fun m::test3($t0: m::W) { [variant baseline] -public fun m::test4($t0: m::W) { - var $t1: m::W +public fun m::test4($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W 0: $t1 := copy($t0) 1: m::consume_($t1) 2: m::consume_($t0) @@ -251,7 +251,7 @@ fun m::consume($t0: u64) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -277,8 +277,8 @@ public fun m::test2($t0: u64) { [variant baseline] -public fun m::test3($t0: m::W) { - var $t1: m::W +public fun m::test3($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W 0: $t1 := copy($t0) 1: m::consume_($t0) 2: m::consume_($t1) @@ -287,8 +287,8 @@ public fun m::test3($t0: m::W) { [variant baseline] -public fun m::test4($t0: m::W) { - var $t1: m::W +public fun m::test4($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W 0: $t1 := copy($t0) 1: m::consume_($t1) 2: m::consume_($t0) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_2.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_2.exp index d80d47d848cef..9467564dc9e2c 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_2.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_2.exp @@ -7,7 +7,7 @@ fun m::consume($t0: u64) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -23,8 +23,8 @@ public fun m::test1($t0: u64) { [variant baseline] -public fun m::test2($t0: m::W) { - var $t1: m::W +public fun m::test2($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W 0: $t1 := move($t0) 1: m::consume_($t1) 2: m::consume_($t1) @@ -40,7 +40,7 @@ fun m::consume($t0: u64) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -56,8 +56,8 @@ public fun m::test1($t0: u64) { [variant baseline] -public fun m::test2($t0: m::W) { - var $t1: m::W +public fun m::test2($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W 0: $t1 := move($t0) 1: m::consume_($t1) 2: m::consume_($t1) @@ -75,7 +75,7 @@ fun m::consume($t0: u64) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { # live vars: $t0 # events: b:$t0, e:$t0 0: return () @@ -99,8 +99,8 @@ public fun m::test1($t0: u64) { [variant baseline] -public fun m::test2($t0: m::W) { - var $t1: m::W +public fun m::test2($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W # live vars: $t0 # events: b:$t0, e:$t0, b:$t1 0: $t1 := move($t0) @@ -122,7 +122,7 @@ fun m::consume($t0: u64) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -138,8 +138,8 @@ public fun m::test1($t0: u64) { [variant baseline] -public fun m::test2($t0: m::W) { - var $t1: m::W [unused] +public fun m::test2($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W [unused] 0: $t0 := move($t0) 1: m::consume_($t0) 2: m::consume_($t0) @@ -155,7 +155,7 @@ fun m::consume($t0: u64) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -170,8 +170,8 @@ public fun m::test1($t0: u64) { [variant baseline] -public fun m::test2($t0: m::W) { - var $t1: m::W [unused] +public fun m::test2($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W [unused] 0: m::consume_($t0) 1: m::consume_($t0) 2: return () diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_2.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_2.opt.exp index d80d47d848cef..9467564dc9e2c 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_2.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_2.opt.exp @@ -7,7 +7,7 @@ fun m::consume($t0: u64) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -23,8 +23,8 @@ public fun m::test1($t0: u64) { [variant baseline] -public fun m::test2($t0: m::W) { - var $t1: m::W +public fun m::test2($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W 0: $t1 := move($t0) 1: m::consume_($t1) 2: m::consume_($t1) @@ -40,7 +40,7 @@ fun m::consume($t0: u64) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -56,8 +56,8 @@ public fun m::test1($t0: u64) { [variant baseline] -public fun m::test2($t0: m::W) { - var $t1: m::W +public fun m::test2($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W 0: $t1 := move($t0) 1: m::consume_($t1) 2: m::consume_($t1) @@ -75,7 +75,7 @@ fun m::consume($t0: u64) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { # live vars: $t0 # events: b:$t0, e:$t0 0: return () @@ -99,8 +99,8 @@ public fun m::test1($t0: u64) { [variant baseline] -public fun m::test2($t0: m::W) { - var $t1: m::W +public fun m::test2($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W # live vars: $t0 # events: b:$t0, e:$t0, b:$t1 0: $t1 := move($t0) @@ -122,7 +122,7 @@ fun m::consume($t0: u64) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -138,8 +138,8 @@ public fun m::test1($t0: u64) { [variant baseline] -public fun m::test2($t0: m::W) { - var $t1: m::W [unused] +public fun m::test2($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W [unused] 0: $t0 := move($t0) 1: m::consume_($t0) 2: m::consume_($t0) @@ -155,7 +155,7 @@ fun m::consume($t0: u64) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -170,8 +170,8 @@ public fun m::test1($t0: u64) { [variant baseline] -public fun m::test2($t0: m::W) { - var $t1: m::W [unused] +public fun m::test2($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W [unused] 0: m::consume_($t0) 1: m::consume_($t0) 2: return () diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_3.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_3.exp index 606dd277acd0c..7ecc0e6a884b1 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_3.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_3.exp @@ -7,7 +7,7 @@ fun m::consume($t0: u32) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -23,8 +23,8 @@ public fun m::test($t0: u32) { [variant baseline] -public fun m::test_($t0: m::W) { - var $t1: m::W +public fun m::test_($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W 0: $t1 := copy($t0) 1: m::consume_($t1) 2: m::consume_($t0) @@ -40,7 +40,7 @@ fun m::consume($t0: u32) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -56,8 +56,8 @@ public fun m::test($t0: u32) { [variant baseline] -public fun m::test_($t0: m::W) { - var $t1: m::W +public fun m::test_($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W 0: $t1 := copy($t0) 1: m::consume_($t1) 2: m::consume_($t0) @@ -75,7 +75,7 @@ fun m::consume($t0: u32) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { # live vars: $t0 # events: b:$t0, e:$t0 0: return () @@ -100,8 +100,8 @@ public fun m::test($t0: u32) { [variant baseline] -public fun m::test_($t0: m::W) { - var $t1: m::W +public fun m::test_($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W # live vars: $t0 # events: b:$t0, b:$t1 0: $t1 := copy($t0) @@ -124,7 +124,7 @@ fun m::consume($t0: u32) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -140,8 +140,8 @@ public fun m::test($t0: u32) { [variant baseline] -public fun m::test_($t0: m::W) { - var $t1: m::W +public fun m::test_($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W 0: $t1 := copy($t0) 1: m::consume_($t1) 2: m::consume_($t0) @@ -157,7 +157,7 @@ fun m::consume($t0: u32) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -173,8 +173,8 @@ public fun m::test($t0: u32) { [variant baseline] -public fun m::test_($t0: m::W) { - var $t1: m::W +public fun m::test_($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W 0: $t1 := copy($t0) 1: m::consume_($t1) 2: m::consume_($t0) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_3.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_3.opt.exp index 606dd277acd0c..7ecc0e6a884b1 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_3.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_3.opt.exp @@ -7,7 +7,7 @@ fun m::consume($t0: u32) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -23,8 +23,8 @@ public fun m::test($t0: u32) { [variant baseline] -public fun m::test_($t0: m::W) { - var $t1: m::W +public fun m::test_($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W 0: $t1 := copy($t0) 1: m::consume_($t1) 2: m::consume_($t0) @@ -40,7 +40,7 @@ fun m::consume($t0: u32) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -56,8 +56,8 @@ public fun m::test($t0: u32) { [variant baseline] -public fun m::test_($t0: m::W) { - var $t1: m::W +public fun m::test_($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W 0: $t1 := copy($t0) 1: m::consume_($t1) 2: m::consume_($t0) @@ -75,7 +75,7 @@ fun m::consume($t0: u32) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { # live vars: $t0 # events: b:$t0, e:$t0 0: return () @@ -100,8 +100,8 @@ public fun m::test($t0: u32) { [variant baseline] -public fun m::test_($t0: m::W) { - var $t1: m::W +public fun m::test_($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W # live vars: $t0 # events: b:$t0, b:$t1 0: $t1 := copy($t0) @@ -124,7 +124,7 @@ fun m::consume($t0: u32) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -140,8 +140,8 @@ public fun m::test($t0: u32) { [variant baseline] -public fun m::test_($t0: m::W) { - var $t1: m::W +public fun m::test_($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W 0: $t1 := copy($t0) 1: m::consume_($t1) 2: m::consume_($t0) @@ -157,7 +157,7 @@ fun m::consume($t0: u32) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -173,8 +173,8 @@ public fun m::test($t0: u32) { [variant baseline] -public fun m::test_($t0: m::W) { - var $t1: m::W +public fun m::test_($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W 0: $t1 := copy($t0) 1: m::consume_($t1) 2: m::consume_($t0) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_4.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_4.exp index 0c6d1f781f678..f2b1a0c6caaf7 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_4.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_4.exp @@ -7,7 +7,7 @@ fun m::consume($t0: u32) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -25,9 +25,9 @@ public fun m::test($t0: u32) { [variant baseline] -public fun m::test_struct($t0: m::W) { - var $t1: m::W - var $t2: m::W +public fun m::test_struct($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W + var $t2: 0xc0ffee::m::W 0: $t1 := copy($t0) 1: $t2 := move($t1) 2: m::consume_($t2) @@ -44,7 +44,7 @@ fun m::consume($t0: u32) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -62,9 +62,9 @@ public fun m::test($t0: u32) { [variant baseline] -public fun m::test_struct($t0: m::W) { - var $t1: m::W - var $t2: m::W +public fun m::test_struct($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W + var $t2: 0xc0ffee::m::W 0: $t1 := copy($t0) 1: $t2 := move($t1) 2: m::consume_($t2) @@ -83,7 +83,7 @@ fun m::consume($t0: u32) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { # live vars: $t0 # events: b:$t0, e:$t0 0: return () @@ -112,9 +112,9 @@ public fun m::test($t0: u32) { [variant baseline] -public fun m::test_struct($t0: m::W) { - var $t1: m::W - var $t2: m::W +public fun m::test_struct($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W + var $t2: 0xc0ffee::m::W # live vars: $t0 # events: b:$t0, b:$t1 0: $t1 := copy($t0) @@ -140,7 +140,7 @@ fun m::consume($t0: u32) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -158,9 +158,9 @@ public fun m::test($t0: u32) { [variant baseline] -public fun m::test_struct($t0: m::W) { - var $t1: m::W - var $t2: m::W [unused] +public fun m::test_struct($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W + var $t2: 0xc0ffee::m::W [unused] 0: $t1 := copy($t0) 1: $t1 := move($t1) 2: m::consume_($t1) @@ -177,7 +177,7 @@ fun m::consume($t0: u32) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -194,9 +194,9 @@ public fun m::test($t0: u32) { [variant baseline] -public fun m::test_struct($t0: m::W) { - var $t1: m::W - var $t2: m::W [unused] +public fun m::test_struct($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W + var $t2: 0xc0ffee::m::W [unused] 0: $t1 := copy($t0) 1: m::consume_($t1) 2: m::consume_($t0) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_4.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_4.opt.exp index 0c6d1f781f678..f2b1a0c6caaf7 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_4.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_4.opt.exp @@ -7,7 +7,7 @@ fun m::consume($t0: u32) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -25,9 +25,9 @@ public fun m::test($t0: u32) { [variant baseline] -public fun m::test_struct($t0: m::W) { - var $t1: m::W - var $t2: m::W +public fun m::test_struct($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W + var $t2: 0xc0ffee::m::W 0: $t1 := copy($t0) 1: $t2 := move($t1) 2: m::consume_($t2) @@ -44,7 +44,7 @@ fun m::consume($t0: u32) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -62,9 +62,9 @@ public fun m::test($t0: u32) { [variant baseline] -public fun m::test_struct($t0: m::W) { - var $t1: m::W - var $t2: m::W +public fun m::test_struct($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W + var $t2: 0xc0ffee::m::W 0: $t1 := copy($t0) 1: $t2 := move($t1) 2: m::consume_($t2) @@ -83,7 +83,7 @@ fun m::consume($t0: u32) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { # live vars: $t0 # events: b:$t0, e:$t0 0: return () @@ -112,9 +112,9 @@ public fun m::test($t0: u32) { [variant baseline] -public fun m::test_struct($t0: m::W) { - var $t1: m::W - var $t2: m::W +public fun m::test_struct($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W + var $t2: 0xc0ffee::m::W # live vars: $t0 # events: b:$t0, b:$t1 0: $t1 := copy($t0) @@ -140,7 +140,7 @@ fun m::consume($t0: u32) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -158,9 +158,9 @@ public fun m::test($t0: u32) { [variant baseline] -public fun m::test_struct($t0: m::W) { - var $t1: m::W - var $t2: m::W [unused] +public fun m::test_struct($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W + var $t2: 0xc0ffee::m::W [unused] 0: $t1 := copy($t0) 1: $t1 := move($t1) 2: m::consume_($t1) @@ -177,7 +177,7 @@ fun m::consume($t0: u32) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -194,9 +194,9 @@ public fun m::test($t0: u32) { [variant baseline] -public fun m::test_struct($t0: m::W) { - var $t1: m::W - var $t2: m::W [unused] +public fun m::test_struct($t0: 0xc0ffee::m::W) { + var $t1: 0xc0ffee::m::W + var $t2: 0xc0ffee::m::W [unused] 0: $t1 := copy($t0) 1: m::consume_($t1) 2: m::consume_($t0) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_5.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_5.exp index 77bfd28f9ff4c..1c5c097d9e7c9 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_5.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_5.exp @@ -7,7 +7,7 @@ fun m::consume($t0: u32) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -37,8 +37,8 @@ public fun m::test($t0: bool, $t1: u32) { [variant baseline] -public fun m::test_struct($t0: bool, $t1: m::W) { - var $t2: m::W +public fun m::test_struct($t0: bool, $t1: 0xc0ffee::m::W) { + var $t2: 0xc0ffee::m::W var $t3: bool 0: $t2 := copy($t1) 1: if ($t0) goto 2 else goto 5 @@ -68,7 +68,7 @@ fun m::consume($t0: u32) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -98,8 +98,8 @@ public fun m::test($t0: bool, $t1: u32) { [variant baseline] -public fun m::test_struct($t0: bool, $t1: m::W) { - var $t2: m::W +public fun m::test_struct($t0: bool, $t1: 0xc0ffee::m::W) { + var $t2: 0xc0ffee::m::W var $t3: bool 0: $t2 := copy($t1) 1: if ($t0) goto 2 else goto 14 @@ -131,7 +131,7 @@ fun m::consume($t0: u32) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { # live vars: $t0 # events: b:$t0, e:$t0 0: return () @@ -184,8 +184,8 @@ public fun m::test($t0: bool, $t1: u32) { [variant baseline] -public fun m::test_struct($t0: bool, $t1: m::W) { - var $t2: m::W +public fun m::test_struct($t0: bool, $t1: 0xc0ffee::m::W) { + var $t2: 0xc0ffee::m::W var $t3: bool # live vars: $t0, $t1 # events: b:$t0, b:$t1, b:$t2 @@ -236,7 +236,7 @@ fun m::consume($t0: u32) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -266,8 +266,8 @@ public fun m::test($t0: bool, $t1: u32) { [variant baseline] -public fun m::test_struct($t0: bool, $t1: m::W) { - var $t2: m::W +public fun m::test_struct($t0: bool, $t1: 0xc0ffee::m::W) { + var $t2: 0xc0ffee::m::W var $t3: bool 0: $t2 := copy($t1) 1: if ($t0) goto 2 else goto 14 @@ -297,7 +297,7 @@ fun m::consume($t0: u32) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -327,8 +327,8 @@ public fun m::test($t0: bool, $t1: u32) { [variant baseline] -public fun m::test_struct($t0: bool, $t1: m::W) { - var $t2: m::W +public fun m::test_struct($t0: bool, $t1: 0xc0ffee::m::W) { + var $t2: 0xc0ffee::m::W var $t3: bool 0: $t2 := copy($t1) 1: if ($t0) goto 2 else goto 14 diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_5.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_5.opt.exp index 77bfd28f9ff4c..1c5c097d9e7c9 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_5.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_5.opt.exp @@ -7,7 +7,7 @@ fun m::consume($t0: u32) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -37,8 +37,8 @@ public fun m::test($t0: bool, $t1: u32) { [variant baseline] -public fun m::test_struct($t0: bool, $t1: m::W) { - var $t2: m::W +public fun m::test_struct($t0: bool, $t1: 0xc0ffee::m::W) { + var $t2: 0xc0ffee::m::W var $t3: bool 0: $t2 := copy($t1) 1: if ($t0) goto 2 else goto 5 @@ -68,7 +68,7 @@ fun m::consume($t0: u32) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -98,8 +98,8 @@ public fun m::test($t0: bool, $t1: u32) { [variant baseline] -public fun m::test_struct($t0: bool, $t1: m::W) { - var $t2: m::W +public fun m::test_struct($t0: bool, $t1: 0xc0ffee::m::W) { + var $t2: 0xc0ffee::m::W var $t3: bool 0: $t2 := copy($t1) 1: if ($t0) goto 2 else goto 14 @@ -131,7 +131,7 @@ fun m::consume($t0: u32) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { # live vars: $t0 # events: b:$t0, e:$t0 0: return () @@ -184,8 +184,8 @@ public fun m::test($t0: bool, $t1: u32) { [variant baseline] -public fun m::test_struct($t0: bool, $t1: m::W) { - var $t2: m::W +public fun m::test_struct($t0: bool, $t1: 0xc0ffee::m::W) { + var $t2: 0xc0ffee::m::W var $t3: bool # live vars: $t0, $t1 # events: b:$t0, b:$t1, b:$t2 @@ -236,7 +236,7 @@ fun m::consume($t0: u32) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -266,8 +266,8 @@ public fun m::test($t0: bool, $t1: u32) { [variant baseline] -public fun m::test_struct($t0: bool, $t1: m::W) { - var $t2: m::W +public fun m::test_struct($t0: bool, $t1: 0xc0ffee::m::W) { + var $t2: 0xc0ffee::m::W var $t3: bool 0: $t2 := copy($t1) 1: if ($t0) goto 2 else goto 14 @@ -297,7 +297,7 @@ fun m::consume($t0: u32) { [variant baseline] -fun m::consume_($t0: m::W) { +fun m::consume_($t0: 0xc0ffee::m::W) { 0: return () } @@ -327,8 +327,8 @@ public fun m::test($t0: bool, $t1: u32) { [variant baseline] -public fun m::test_struct($t0: bool, $t1: m::W) { - var $t2: m::W +public fun m::test_struct($t0: bool, $t1: 0xc0ffee::m::W) { + var $t2: 0xc0ffee::m::W var $t3: bool 0: $t2 := copy($t1) 1: if ($t0) goto 2 else goto 14 diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/mut_refs_2.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/mut_refs_2.exp index 1a59b3c7f2a73..1b05ff1d6aaec 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/mut_refs_2.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/mut_refs_2.exp @@ -1,23 +1,23 @@ ============ initial bytecode ================ [variant baseline] -fun m::test($t0: m::S): u64 { +fun m::test($t0: 0xc0ffee::m::S): u64 { var $t1: u64 - var $t2: m::S - var $t3: m::S + var $t2: 0xc0ffee::m::S + var $t3: 0xc0ffee::m::S var $t4: &mut u64 - var $t5: &mut m::S + var $t5: &mut 0xc0ffee::m::S var $t6: u64 - var $t7: &m::S + var $t7: &0xc0ffee::m::S var $t8: &u64 0: $t2 := infer($t0) 1: $t3 := infer($t2) 2: $t5 := borrow_local($t2) - 3: $t4 := borrow_field.a($t5) + 3: $t4 := borrow_field<0xc0ffee::m::S>.a($t5) 4: $t6 := 0 5: write_ref($t4, $t6) 6: $t7 := borrow_local($t3) - 7: $t8 := borrow_field.a($t7) + 7: $t8 := borrow_field<0xc0ffee::m::S>.a($t7) 8: $t1 := read_ref($t8) 9: return $t1 } @@ -25,23 +25,23 @@ fun m::test($t0: m::S): u64 { ============ after DeadStoreElimination: ================ [variant baseline] -fun m::test($t0: m::S): u64 { +fun m::test($t0: 0xc0ffee::m::S): u64 { var $t1: u64 - var $t2: m::S - var $t3: m::S + var $t2: 0xc0ffee::m::S + var $t3: 0xc0ffee::m::S var $t4: &mut u64 - var $t5: &mut m::S + var $t5: &mut 0xc0ffee::m::S var $t6: u64 - var $t7: &m::S + var $t7: &0xc0ffee::m::S var $t8: &u64 0: $t2 := move($t0) 1: $t3 := copy($t2) 2: $t5 := borrow_local($t2) - 3: $t4 := borrow_field.a($t5) + 3: $t4 := borrow_field<0xc0ffee::m::S>.a($t5) 4: $t6 := 0 5: write_ref($t4, $t6) 6: $t7 := borrow_local($t3) - 7: $t8 := borrow_field.a($t7) + 7: $t8 := borrow_field<0xc0ffee::m::S>.a($t7) 8: $t1 := read_ref($t8) 9: return $t1 } @@ -49,14 +49,14 @@ fun m::test($t0: m::S): u64 { ============ after VariableCoalescingAnnotator: ================ [variant baseline] -fun m::test($t0: m::S): u64 { +fun m::test($t0: 0xc0ffee::m::S): u64 { var $t1: u64 - var $t2: m::S - var $t3: m::S + var $t2: 0xc0ffee::m::S + var $t3: 0xc0ffee::m::S var $t4: &mut u64 - var $t5: &mut m::S + var $t5: &mut 0xc0ffee::m::S var $t6: u64 - var $t7: &m::S + var $t7: &0xc0ffee::m::S var $t8: &u64 # live vars: $t0 # events: b:$t0, e:$t0 @@ -68,7 +68,7 @@ fun m::test($t0: m::S): u64 { 2: $t5 := borrow_local($t2) # live vars: $t3, $t5 # events: e:$t5, b:$t4 - 3: $t4 := borrow_field.a($t5) + 3: $t4 := borrow_field<0xc0ffee::m::S>.a($t5) # live vars: $t3, $t4 # events: b:$t6 4: $t6 := 0 @@ -80,7 +80,7 @@ fun m::test($t0: m::S): u64 { 6: $t7 := borrow_local($t3) # live vars: $t7 # events: e:$t7, b:$t8 - 7: $t8 := borrow_field.a($t7) + 7: $t8 := borrow_field<0xc0ffee::m::S>.a($t7) # live vars: $t8 # events: e:$t8, b:$t1 8: $t1 := read_ref($t8) @@ -92,23 +92,23 @@ fun m::test($t0: m::S): u64 { ============ after VariableCoalescingTransformer: ================ [variant baseline] -fun m::test($t0: m::S): u64 { +fun m::test($t0: 0xc0ffee::m::S): u64 { var $t1: u64 [unused] - var $t2: m::S - var $t3: m::S + var $t2: 0xc0ffee::m::S + var $t3: 0xc0ffee::m::S var $t4: &mut u64 - var $t5: &mut m::S + var $t5: &mut 0xc0ffee::m::S var $t6: u64 - var $t7: &m::S + var $t7: &0xc0ffee::m::S var $t8: &u64 0: $t2 := move($t0) 1: $t3 := copy($t2) 2: $t5 := borrow_local($t2) - 3: $t4 := borrow_field.a($t5) + 3: $t4 := borrow_field<0xc0ffee::m::S>.a($t5) 4: $t6 := 0 5: write_ref($t4, $t6) 6: $t7 := borrow_local($t3) - 7: $t8 := borrow_field.a($t7) + 7: $t8 := borrow_field<0xc0ffee::m::S>.a($t7) 8: $t6 := read_ref($t8) 9: return $t6 } @@ -116,23 +116,23 @@ fun m::test($t0: m::S): u64 { ============ after DeadStoreElimination: ================ [variant baseline] -fun m::test($t0: m::S): u64 { +fun m::test($t0: 0xc0ffee::m::S): u64 { var $t1: u64 [unused] - var $t2: m::S - var $t3: m::S + var $t2: 0xc0ffee::m::S + var $t3: 0xc0ffee::m::S var $t4: &mut u64 - var $t5: &mut m::S + var $t5: &mut 0xc0ffee::m::S var $t6: u64 - var $t7: &m::S + var $t7: &0xc0ffee::m::S var $t8: &u64 0: $t2 := move($t0) 1: $t3 := copy($t2) 2: $t5 := borrow_local($t2) - 3: $t4 := borrow_field.a($t5) + 3: $t4 := borrow_field<0xc0ffee::m::S>.a($t5) 4: $t6 := 0 5: write_ref($t4, $t6) 6: $t7 := borrow_local($t3) - 7: $t8 := borrow_field.a($t7) + 7: $t8 := borrow_field<0xc0ffee::m::S>.a($t7) 8: $t6 := read_ref($t8) 9: return $t6 } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/mut_refs_2.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/mut_refs_2.opt.exp index 1a59b3c7f2a73..1b05ff1d6aaec 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/mut_refs_2.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/mut_refs_2.opt.exp @@ -1,23 +1,23 @@ ============ initial bytecode ================ [variant baseline] -fun m::test($t0: m::S): u64 { +fun m::test($t0: 0xc0ffee::m::S): u64 { var $t1: u64 - var $t2: m::S - var $t3: m::S + var $t2: 0xc0ffee::m::S + var $t3: 0xc0ffee::m::S var $t4: &mut u64 - var $t5: &mut m::S + var $t5: &mut 0xc0ffee::m::S var $t6: u64 - var $t7: &m::S + var $t7: &0xc0ffee::m::S var $t8: &u64 0: $t2 := infer($t0) 1: $t3 := infer($t2) 2: $t5 := borrow_local($t2) - 3: $t4 := borrow_field.a($t5) + 3: $t4 := borrow_field<0xc0ffee::m::S>.a($t5) 4: $t6 := 0 5: write_ref($t4, $t6) 6: $t7 := borrow_local($t3) - 7: $t8 := borrow_field.a($t7) + 7: $t8 := borrow_field<0xc0ffee::m::S>.a($t7) 8: $t1 := read_ref($t8) 9: return $t1 } @@ -25,23 +25,23 @@ fun m::test($t0: m::S): u64 { ============ after DeadStoreElimination: ================ [variant baseline] -fun m::test($t0: m::S): u64 { +fun m::test($t0: 0xc0ffee::m::S): u64 { var $t1: u64 - var $t2: m::S - var $t3: m::S + var $t2: 0xc0ffee::m::S + var $t3: 0xc0ffee::m::S var $t4: &mut u64 - var $t5: &mut m::S + var $t5: &mut 0xc0ffee::m::S var $t6: u64 - var $t7: &m::S + var $t7: &0xc0ffee::m::S var $t8: &u64 0: $t2 := move($t0) 1: $t3 := copy($t2) 2: $t5 := borrow_local($t2) - 3: $t4 := borrow_field.a($t5) + 3: $t4 := borrow_field<0xc0ffee::m::S>.a($t5) 4: $t6 := 0 5: write_ref($t4, $t6) 6: $t7 := borrow_local($t3) - 7: $t8 := borrow_field.a($t7) + 7: $t8 := borrow_field<0xc0ffee::m::S>.a($t7) 8: $t1 := read_ref($t8) 9: return $t1 } @@ -49,14 +49,14 @@ fun m::test($t0: m::S): u64 { ============ after VariableCoalescingAnnotator: ================ [variant baseline] -fun m::test($t0: m::S): u64 { +fun m::test($t0: 0xc0ffee::m::S): u64 { var $t1: u64 - var $t2: m::S - var $t3: m::S + var $t2: 0xc0ffee::m::S + var $t3: 0xc0ffee::m::S var $t4: &mut u64 - var $t5: &mut m::S + var $t5: &mut 0xc0ffee::m::S var $t6: u64 - var $t7: &m::S + var $t7: &0xc0ffee::m::S var $t8: &u64 # live vars: $t0 # events: b:$t0, e:$t0 @@ -68,7 +68,7 @@ fun m::test($t0: m::S): u64 { 2: $t5 := borrow_local($t2) # live vars: $t3, $t5 # events: e:$t5, b:$t4 - 3: $t4 := borrow_field.a($t5) + 3: $t4 := borrow_field<0xc0ffee::m::S>.a($t5) # live vars: $t3, $t4 # events: b:$t6 4: $t6 := 0 @@ -80,7 +80,7 @@ fun m::test($t0: m::S): u64 { 6: $t7 := borrow_local($t3) # live vars: $t7 # events: e:$t7, b:$t8 - 7: $t8 := borrow_field.a($t7) + 7: $t8 := borrow_field<0xc0ffee::m::S>.a($t7) # live vars: $t8 # events: e:$t8, b:$t1 8: $t1 := read_ref($t8) @@ -92,23 +92,23 @@ fun m::test($t0: m::S): u64 { ============ after VariableCoalescingTransformer: ================ [variant baseline] -fun m::test($t0: m::S): u64 { +fun m::test($t0: 0xc0ffee::m::S): u64 { var $t1: u64 [unused] - var $t2: m::S - var $t3: m::S + var $t2: 0xc0ffee::m::S + var $t3: 0xc0ffee::m::S var $t4: &mut u64 - var $t5: &mut m::S + var $t5: &mut 0xc0ffee::m::S var $t6: u64 - var $t7: &m::S + var $t7: &0xc0ffee::m::S var $t8: &u64 0: $t2 := move($t0) 1: $t3 := copy($t2) 2: $t5 := borrow_local($t2) - 3: $t4 := borrow_field.a($t5) + 3: $t4 := borrow_field<0xc0ffee::m::S>.a($t5) 4: $t6 := 0 5: write_ref($t4, $t6) 6: $t7 := borrow_local($t3) - 7: $t8 := borrow_field.a($t7) + 7: $t8 := borrow_field<0xc0ffee::m::S>.a($t7) 8: $t6 := read_ref($t8) 9: return $t6 } @@ -116,23 +116,23 @@ fun m::test($t0: m::S): u64 { ============ after DeadStoreElimination: ================ [variant baseline] -fun m::test($t0: m::S): u64 { +fun m::test($t0: 0xc0ffee::m::S): u64 { var $t1: u64 [unused] - var $t2: m::S - var $t3: m::S + var $t2: 0xc0ffee::m::S + var $t3: 0xc0ffee::m::S var $t4: &mut u64 - var $t5: &mut m::S + var $t5: &mut 0xc0ffee::m::S var $t6: u64 - var $t7: &m::S + var $t7: &0xc0ffee::m::S var $t8: &u64 0: $t2 := move($t0) 1: $t3 := copy($t2) 2: $t5 := borrow_local($t2) - 3: $t4 := borrow_field.a($t5) + 3: $t4 := borrow_field<0xc0ffee::m::S>.a($t5) 4: $t6 := 0 5: write_ref($t4, $t6) 6: $t7 := borrow_local($t3) - 7: $t8 := borrow_field.a($t7) + 7: $t8 := borrow_field<0xc0ffee::m::S>.a($t7) 8: $t6 := read_ref($t8) 9: return $t6 } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/sequential_assign_struct.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/sequential_assign_struct.exp index ef5799020a8ac..d07e8b35bdcd3 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/sequential_assign_struct.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/sequential_assign_struct.exp @@ -1,13 +1,13 @@ ============ initial bytecode ================ [variant baseline] -fun m::sequential($t0: m::Foo): m::Foo { - var $t1: m::Foo - var $t2: m::Foo - var $t3: m::Foo - var $t4: m::Foo - var $t5: m::Foo - var $t6: m::Foo +fun m::sequential($t0: 0xc0ffee::m::Foo): 0xc0ffee::m::Foo { + var $t1: 0xc0ffee::m::Foo + var $t2: 0xc0ffee::m::Foo + var $t3: 0xc0ffee::m::Foo + var $t4: 0xc0ffee::m::Foo + var $t5: 0xc0ffee::m::Foo + var $t6: 0xc0ffee::m::Foo 0: $t2 := infer($t0) 1: $t3 := infer($t2) 2: $t4 := infer($t3) @@ -20,13 +20,13 @@ fun m::sequential($t0: m::Foo): m::Foo { ============ after DeadStoreElimination: ================ [variant baseline] -fun m::sequential($t0: m::Foo): m::Foo { - var $t1: m::Foo - var $t2: m::Foo - var $t3: m::Foo - var $t4: m::Foo - var $t5: m::Foo - var $t6: m::Foo +fun m::sequential($t0: 0xc0ffee::m::Foo): 0xc0ffee::m::Foo { + var $t1: 0xc0ffee::m::Foo + var $t2: 0xc0ffee::m::Foo + var $t3: 0xc0ffee::m::Foo + var $t4: 0xc0ffee::m::Foo + var $t5: 0xc0ffee::m::Foo + var $t6: 0xc0ffee::m::Foo 0: $t2 := move($t0) 1: $t3 := move($t2) 2: $t4 := move($t3) @@ -39,13 +39,13 @@ fun m::sequential($t0: m::Foo): m::Foo { ============ after VariableCoalescingAnnotator: ================ [variant baseline] -fun m::sequential($t0: m::Foo): m::Foo { - var $t1: m::Foo - var $t2: m::Foo - var $t3: m::Foo - var $t4: m::Foo - var $t5: m::Foo - var $t6: m::Foo +fun m::sequential($t0: 0xc0ffee::m::Foo): 0xc0ffee::m::Foo { + var $t1: 0xc0ffee::m::Foo + var $t2: 0xc0ffee::m::Foo + var $t3: 0xc0ffee::m::Foo + var $t4: 0xc0ffee::m::Foo + var $t5: 0xc0ffee::m::Foo + var $t6: 0xc0ffee::m::Foo # live vars: $t0 # events: b:$t0, e:$t0, b:$t2 0: $t2 := move($t0) @@ -72,13 +72,13 @@ fun m::sequential($t0: m::Foo): m::Foo { ============ after VariableCoalescingTransformer: ================ [variant baseline] -fun m::sequential($t0: m::Foo): m::Foo { - var $t1: m::Foo [unused] - var $t2: m::Foo [unused] - var $t3: m::Foo [unused] - var $t4: m::Foo [unused] - var $t5: m::Foo [unused] - var $t6: m::Foo [unused] +fun m::sequential($t0: 0xc0ffee::m::Foo): 0xc0ffee::m::Foo { + var $t1: 0xc0ffee::m::Foo [unused] + var $t2: 0xc0ffee::m::Foo [unused] + var $t3: 0xc0ffee::m::Foo [unused] + var $t4: 0xc0ffee::m::Foo [unused] + var $t5: 0xc0ffee::m::Foo [unused] + var $t6: 0xc0ffee::m::Foo [unused] 0: $t0 := move($t0) 1: $t0 := move($t0) 2: $t0 := move($t0) @@ -91,13 +91,13 @@ fun m::sequential($t0: m::Foo): m::Foo { ============ after DeadStoreElimination: ================ [variant baseline] -fun m::sequential($t0: m::Foo): m::Foo { - var $t1: m::Foo [unused] - var $t2: m::Foo [unused] - var $t3: m::Foo [unused] - var $t4: m::Foo [unused] - var $t5: m::Foo [unused] - var $t6: m::Foo [unused] +fun m::sequential($t0: 0xc0ffee::m::Foo): 0xc0ffee::m::Foo { + var $t1: 0xc0ffee::m::Foo [unused] + var $t2: 0xc0ffee::m::Foo [unused] + var $t3: 0xc0ffee::m::Foo [unused] + var $t4: 0xc0ffee::m::Foo [unused] + var $t5: 0xc0ffee::m::Foo [unused] + var $t6: 0xc0ffee::m::Foo [unused] 0: return $t0 } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/sequential_assign_struct.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/sequential_assign_struct.opt.exp index ef5799020a8ac..d07e8b35bdcd3 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/sequential_assign_struct.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/sequential_assign_struct.opt.exp @@ -1,13 +1,13 @@ ============ initial bytecode ================ [variant baseline] -fun m::sequential($t0: m::Foo): m::Foo { - var $t1: m::Foo - var $t2: m::Foo - var $t3: m::Foo - var $t4: m::Foo - var $t5: m::Foo - var $t6: m::Foo +fun m::sequential($t0: 0xc0ffee::m::Foo): 0xc0ffee::m::Foo { + var $t1: 0xc0ffee::m::Foo + var $t2: 0xc0ffee::m::Foo + var $t3: 0xc0ffee::m::Foo + var $t4: 0xc0ffee::m::Foo + var $t5: 0xc0ffee::m::Foo + var $t6: 0xc0ffee::m::Foo 0: $t2 := infer($t0) 1: $t3 := infer($t2) 2: $t4 := infer($t3) @@ -20,13 +20,13 @@ fun m::sequential($t0: m::Foo): m::Foo { ============ after DeadStoreElimination: ================ [variant baseline] -fun m::sequential($t0: m::Foo): m::Foo { - var $t1: m::Foo - var $t2: m::Foo - var $t3: m::Foo - var $t4: m::Foo - var $t5: m::Foo - var $t6: m::Foo +fun m::sequential($t0: 0xc0ffee::m::Foo): 0xc0ffee::m::Foo { + var $t1: 0xc0ffee::m::Foo + var $t2: 0xc0ffee::m::Foo + var $t3: 0xc0ffee::m::Foo + var $t4: 0xc0ffee::m::Foo + var $t5: 0xc0ffee::m::Foo + var $t6: 0xc0ffee::m::Foo 0: $t2 := move($t0) 1: $t3 := move($t2) 2: $t4 := move($t3) @@ -39,13 +39,13 @@ fun m::sequential($t0: m::Foo): m::Foo { ============ after VariableCoalescingAnnotator: ================ [variant baseline] -fun m::sequential($t0: m::Foo): m::Foo { - var $t1: m::Foo - var $t2: m::Foo - var $t3: m::Foo - var $t4: m::Foo - var $t5: m::Foo - var $t6: m::Foo +fun m::sequential($t0: 0xc0ffee::m::Foo): 0xc0ffee::m::Foo { + var $t1: 0xc0ffee::m::Foo + var $t2: 0xc0ffee::m::Foo + var $t3: 0xc0ffee::m::Foo + var $t4: 0xc0ffee::m::Foo + var $t5: 0xc0ffee::m::Foo + var $t6: 0xc0ffee::m::Foo # live vars: $t0 # events: b:$t0, e:$t0, b:$t2 0: $t2 := move($t0) @@ -72,13 +72,13 @@ fun m::sequential($t0: m::Foo): m::Foo { ============ after VariableCoalescingTransformer: ================ [variant baseline] -fun m::sequential($t0: m::Foo): m::Foo { - var $t1: m::Foo [unused] - var $t2: m::Foo [unused] - var $t3: m::Foo [unused] - var $t4: m::Foo [unused] - var $t5: m::Foo [unused] - var $t6: m::Foo [unused] +fun m::sequential($t0: 0xc0ffee::m::Foo): 0xc0ffee::m::Foo { + var $t1: 0xc0ffee::m::Foo [unused] + var $t2: 0xc0ffee::m::Foo [unused] + var $t3: 0xc0ffee::m::Foo [unused] + var $t4: 0xc0ffee::m::Foo [unused] + var $t5: 0xc0ffee::m::Foo [unused] + var $t6: 0xc0ffee::m::Foo [unused] 0: $t0 := move($t0) 1: $t0 := move($t0) 2: $t0 := move($t0) @@ -91,13 +91,13 @@ fun m::sequential($t0: m::Foo): m::Foo { ============ after DeadStoreElimination: ================ [variant baseline] -fun m::sequential($t0: m::Foo): m::Foo { - var $t1: m::Foo [unused] - var $t2: m::Foo [unused] - var $t3: m::Foo [unused] - var $t4: m::Foo [unused] - var $t5: m::Foo [unused] - var $t6: m::Foo [unused] +fun m::sequential($t0: 0xc0ffee::m::Foo): 0xc0ffee::m::Foo { + var $t1: 0xc0ffee::m::Foo [unused] + var $t2: 0xc0ffee::m::Foo [unused] + var $t3: 0xc0ffee::m::Foo [unused] + var $t4: 0xc0ffee::m::Foo [unused] + var $t5: 0xc0ffee::m::Foo [unused] + var $t6: 0xc0ffee::m::Foo [unused] 0: return $t0 } diff --git a/third_party/move/move-compiler-v2/tests/visibility-checker/mix_friend_package_visibility_valid.exp b/third_party/move/move-compiler-v2/tests/visibility-checker/mix_friend_package_visibility_valid.exp index cd4161e3b9462..45287e306b344 100644 --- a/third_party/move/move-compiler-v2/tests/visibility-checker/mix_friend_package_visibility_valid.exp +++ b/third_party/move/move-compiler-v2/tests/visibility-checker/mix_friend_package_visibility_valid.exp @@ -10,3 +10,15 @@ module 0x42::A { Tuple() } } // end 0x42::A + +// -- Sourcified model before bytecode pipeline +module 0x42::B { + friend 0x42::A; + friend fun foo() { + } +} +module 0x42::A { + friend fun foo() { + 0x42::B::foo(); + } +} diff --git a/third_party/move/move-compiler-v2/tests/visibility-checker/package_visibility.exp b/third_party/move/move-compiler-v2/tests/visibility-checker/package_visibility.exp index 1423e7fb8a51c..f06c111924612 100644 --- a/third_party/move/move-compiler-v2/tests/visibility-checker/package_visibility.exp +++ b/third_party/move/move-compiler-v2/tests/visibility-checker/package_visibility.exp @@ -31,3 +31,37 @@ module 0x42::C { B::foo() } } // end 0x42::C + +// -- Sourcified model before bytecode pipeline +module 0x42::A { + friend 0x42::B; + friend fun bar() { + } + fun foo() { + } +} +module 0x42::B { + use 0x42::A; + friend 0x42::C; + public fun bar() { + A::bar() + } + friend fun foo() { + A::bar() + } + fun baz() { + A::bar() + } +} +module 0x42::C { + use 0x42::B; + public fun bar() { + B::foo() + } + friend fun foo() { + B::foo() + } + fun baz() { + B::foo() + } +} diff --git a/third_party/move/move-compiler-v2/tests/visibility-checker/v1-typing/module_call_visibility_friend.exp b/third_party/move/move-compiler-v2/tests/visibility-checker/v1-typing/module_call_visibility_friend.exp index f3424d16dd504..46adaacca8b01 100644 --- a/third_party/move/move-compiler-v2/tests/visibility-checker/v1-typing/module_call_visibility_friend.exp +++ b/third_party/move/move-compiler-v2/tests/visibility-checker/v1-typing/module_call_visibility_friend.exp @@ -49,3 +49,51 @@ module 0x2::M { M::f_friend() } } // end 0x2::M + +// -- Sourcified model before bytecode pipeline +module 0x2::Y { + friend 0x2::M; + friend fun f_friend() { + } +} +module 0x2::X { + public fun f_public() { + } +} +module 0x2::M { + use 0x2::Y; + use 0x2::X; + friend fun f_friend() { + } + public fun f_public() { + } + friend fun f_friend_call_friend() { + Y::f_friend() + } + friend fun f_friend_call_public() { + X::f_public() + } + friend fun f_friend_call_self_friend() { + f_friend() + } + friend fun f_friend_call_self_private() { + f_private() + } + friend fun f_friend_call_self_public() { + f_public() + } + fun f_private() { + } + fun f_private_call_friend() { + Y::f_friend() + } + fun f_private_call_self_friend() { + f_friend() + } + public fun f_public_call_friend() { + Y::f_friend() + } + public fun f_public_call_self_friend() { + f_friend() + } +} diff --git a/third_party/move/move-compiler-v2/tests/visibility-checker/visibility_complex.exp b/third_party/move/move-compiler-v2/tests/visibility-checker/visibility_complex.exp index 6cf8b10e577f7..1196b8a46fbea 100644 --- a/third_party/move/move-compiler-v2/tests/visibility-checker/visibility_complex.exp +++ b/third_party/move/move-compiler-v2/tests/visibility-checker/visibility_complex.exp @@ -23,3 +23,29 @@ module 0x42::D { Tuple() } } // end 0x42::D + +// -- Sourcified model before bytecode pipeline +module 0x42::B { + friend 0x42::C; + friend 0x42::D; + friend fun foo() { + } +} +module 0x42::A { + friend 0x42::C; + friend fun foo() { + } +} +module 0x42::C { + friend 0x42::D; + friend fun foo() { + 0x42::A::foo(); + 0x42::B::foo(); + } +} +module 0x42::D { + friend fun bar() { + 0x42::B::foo(); + 0x42::C::foo(); + } +} diff --git a/third_party/move/move-model/bytecode/Cargo.toml b/third_party/move/move-model/bytecode/Cargo.toml index 43e0ed1ef7a07..ae85ec999da93 100644 --- a/third_party/move/move-model/bytecode/Cargo.toml +++ b/third_party/move/move-model/bytecode/Cargo.toml @@ -24,6 +24,7 @@ log = { workspace = true } num = { workspace = true } paste = { workspace = true } petgraph = { workspace = true } +topological-sort = { workspace = true } [dev-dependencies] anyhow = { workspace = true } diff --git a/third_party/move/move-model/bytecode/ast-generator-tests/Cargo.toml b/third_party/move/move-model/bytecode/ast-generator-tests/Cargo.toml new file mode 100644 index 0000000000000..984877d3123a5 --- /dev/null +++ b/third_party/move/move-model/bytecode/ast-generator-tests/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "move-ast-generator-tests" +version = "0.1.0" +edition = "2021" +license = { workspace = true } + +[dev-dependencies] +anyhow = { workspace = true } +codespan-reporting = { workspace = true, features = ["serde", "serialization"] } +datatest-stable = { workspace = true } +move-compiler-v2 = { workspace = true } +move-model = { workspace = true } +move-prover-test-utils = { workspace = true } +move-stackless-bytecode = { workspace = true } + +[[test]] +name = "testsuite" +harness = false + +[lib] +doctest = false diff --git a/third_party/move/move-model/bytecode/ast-generator-tests/src/lib.rs b/third_party/move/move-model/bytecode/ast-generator-tests/src/lib.rs new file mode 100644 index 0000000000000..dd271f8c0ff7b --- /dev/null +++ b/third_party/move/move-model/bytecode/ast-generator-tests/src/lib.rs @@ -0,0 +1,5 @@ +// Copyright © Aptos Foundation +// Parts of the project are originally copyright © Meta Platforms, Inc. +// SPDX-License-Identifier: Apache-2.0 + +//! Intentionally empty diff --git a/third_party/move/move-model/bytecode/ast-generator-tests/tests/conditionals.exp b/third_party/move/move-model/bytecode/ast-generator-tests/tests/conditionals.exp new file mode 100644 index 0000000000000..faa1807d0cec8 --- /dev/null +++ b/third_party/move/move-model/bytecode/ast-generator-tests/tests/conditionals.exp @@ -0,0 +1,469 @@ + +=== Processing m::if_1 ===================================================== +--- Source +fun if_1(c: bool): u8 { + let result = 0; + if (c) { + result = 1; + }; + result + } + +--- Stackless Bytecode +fun m::if_1($t0|c: bool): u8 { + var $t1|result: u8 + var $t2: u8 + var $t3: bool + var $t4: u8 + var $t5: u8 + 0: $t2 := 0 + 1: $t1 := $t2 + 2: $t3 := move($t0) + 3: if ($t3) goto 4 else goto 8 + 4: label L1 + 5: $t4 := 1 + 6: $t1 := $t4 + 7: goto 8 + 8: label L0 + 9: $t5 := move($t1) + 10: return $t5 +} + +--- Raw Generated AST +_t2: u8 = 0; +_t1: u8 = _t2; +_t3: bool = c; +loop { + if (Not(_t3)) break; + _t4: u8 = 1; + _t1: u8 = _t4; + break +}; +_t5: u8 = _t1; +return _t5 + +--- If-Transformed Generated AST +_t2: u8 = 0; +_t1: u8 = _t2; +_t3: bool = c; +if _t3 { + _t4: u8 = 1; + _t1: u8 = _t4 +}; +_t5: u8 = _t1; +return _t5 + +--- Assign-Transformed Generated AST +{ + let _t1: u8 = 0; + if c { + _t1: u8 = 1 + }; + return _t1 +} + + +=== Processing m::if_else_1 ===================================================== +--- Source +fun if_else_1(c: bool): u8 { + if (c) 1 else 2 + } + +--- Stackless Bytecode +fun m::if_else_1($t0|c: bool): u8 { + var $t1|return: u8 + var $t2: bool + var $t3: u8 + var $t4: u8 + var $t5: u8 + 0: $t2 := move($t0) + 1: if ($t2) goto 2 else goto 6 + 2: label L1 + 3: $t3 := 1 + 4: $t1 := $t3 + 5: goto 10 + 6: label L0 + 7: $t4 := 2 + 8: $t1 := $t4 + 9: goto 10 + 10: label L2 + 11: $t5 := move($t1) + 12: return $t5 +} + +--- Raw Generated AST +_t2: bool = c; +loop { + loop { + if (Not(_t2)) break; + _t3: u8 = 1; + _t1: u8 = _t3; + break[1] + }; + _t4: u8 = 2; + _t1: u8 = _t4; + break +}; +_t5: u8 = _t1; +return _t5 + +--- If-Transformed Generated AST +_t2: bool = c; +if _t2 { + _t3: u8 = 1; + _t1: u8 = _t3 +} else { + _t4: u8 = 2; + _t1: u8 = _t4 +}; +_t5: u8 = _t1; +return _t5 + +--- Assign-Transformed Generated AST +{ + let _t1: u8; + if c { + _t1: u8 = 1 + } else { + _t1: u8 = 2 + }; + return _t1 +} + + +=== Processing m::if_else_2 ===================================================== +--- Source +fun if_else_2(c: bool, d: bool): u8 { + if (c) { + if (d) { + 1 + } else { + 2 + } + } else { + 3 + } + } + +--- Stackless Bytecode +fun m::if_else_2($t0|c: bool, $t1|d: bool): u8 { + var $t2|return: u8 + var $t3: bool + var $t4: bool + var $t5: u8 + var $t6: u8 + var $t7: u8 + var $t8: u8 + 0: $t3 := move($t0) + 1: if ($t3) goto 2 else goto 15 + 2: label L1 + 3: $t4 := move($t1) + 4: if ($t4) goto 5 else goto 9 + 5: label L3 + 6: $t5 := 1 + 7: $t2 := $t5 + 8: goto 13 + 9: label L2 + 10: $t6 := 2 + 11: $t2 := $t6 + 12: goto 13 + 13: label L4 + 14: goto 19 + 15: label L0 + 16: $t7 := 3 + 17: $t2 := $t7 + 18: goto 19 + 19: label L5 + 20: $t8 := move($t2) + 21: return $t8 +} + +--- Raw Generated AST +_t3: bool = c; +loop { + loop { + if (_t3) break; + _t7: u8 = 3; + _t2: u8 = _t7; + break[1] + }; + _t4: bool = d; + loop { + loop { + if (Not(_t4)) break; + _t5: u8 = 1; + _t2: u8 = _t5; + break[1] + }; + _t6: u8 = 2; + _t2: u8 = _t6; + break + }; + break +}; +_t8: u8 = _t2; +return _t8 + +--- If-Transformed Generated AST +_t3: bool = c; +if _t3 { + _t4: bool = d; + if _t4 { + _t5: u8 = 1; + _t2: u8 = _t5 + } else { + _t6: u8 = 2; + _t2: u8 = _t6 + } +} else { + _t7: u8 = 3; + _t2: u8 = _t7 +}; +_t8: u8 = _t2; +return _t8 + +--- Assign-Transformed Generated AST +{ + let _t2: u8; + if c { + if d { + _t2: u8 = 1 + } else { + _t2: u8 = 2 + } + } else { + _t2: u8 = 3 + }; + return _t2 +} + + +=== Processing m::if_else_3 ===================================================== +--- Source +fun if_else_3(c: bool): u64 { + let r = if (c) 1 else 2; + r + } + +--- Stackless Bytecode +fun m::if_else_3($t0|c: bool): u64 { + var $t1|r: u64 + var $t2: bool + var $t3: u64 + var $t4: u64 + var $t5: u64 + 0: $t2 := move($t0) + 1: if ($t2) goto 2 else goto 6 + 2: label L1 + 3: $t3 := 1 + 4: $t1 := $t3 + 5: goto 10 + 6: label L0 + 7: $t4 := 2 + 8: $t1 := $t4 + 9: goto 10 + 10: label L2 + 11: $t5 := move($t1) + 12: return $t5 +} + +--- Raw Generated AST +_t2: bool = c; +loop { + loop { + if (Not(_t2)) break; + _t3: u64 = 1; + _t1: u64 = _t3; + break[1] + }; + _t4: u64 = 2; + _t1: u64 = _t4; + break +}; +_t5: u64 = _t1; +return _t5 + +--- If-Transformed Generated AST +_t2: bool = c; +if _t2 { + _t3: u64 = 1; + _t1: u64 = _t3 +} else { + _t4: u64 = 2; + _t1: u64 = _t4 +}; +_t5: u64 = _t1; +return _t5 + +--- Assign-Transformed Generated AST +{ + let _t1: u64; + if c { + _t1: u64 = 1 + } else { + _t1: u64 = 2 + }; + return _t1 +} + + +=== Processing m::if_else_with_shard_exp ===================================================== +--- Source +fun if_else_with_shard_exp(x: u64): u64 { + let y = x + x; + let z = y * y; + if (z > 0) z + 1 else z - 1 + } + +--- Stackless Bytecode +fun m::if_else_with_shard_exp($t0|x: u64): u64 { + var $t1|$t5: u64 + var $t2|$t7: u64 [unused] + var $t3: u64 + var $t4: u64 + var $t5: u64 + var $t6: u64 + var $t7: u64 + var $t8: u64 + var $t9: u64 + var $t10: u64 + var $t11: bool + var $t12: u64 + var $t13: u64 + var $t14: u64 + var $t15: u64 + var $t16: u64 + var $t17: u64 + var $t18: u64 + 0: $t3 := copy($t0) + 1: $t4 := move($t0) + 2: $t5 := +($t3, $t4) + 3: $t0 := $t5 + 4: $t6 := copy($t0) + 5: $t7 := move($t0) + 6: $t8 := *($t6, $t7) + 7: $t0 := $t8 + 8: $t9 := copy($t0) + 9: $t10 := 0 + 10: $t11 := >($t9, $t10) + 11: if ($t11) goto 12 else goto 18 + 12: label L1 + 13: $t12 := move($t0) + 14: $t13 := 1 + 15: $t14 := +($t12, $t13) + 16: $t1 := $t14 + 17: goto 24 + 18: label L0 + 19: $t15 := move($t0) + 20: $t16 := 1 + 21: $t17 := -($t15, $t16) + 22: $t1 := $t17 + 23: goto 24 + 24: label L2 + 25: $t18 := move($t1) + 26: return $t18 +} + +--- Raw Generated AST +_t3: u64 = x; +_t4: u64 = x; +_t5: u64 = Add(_t3, _t4); +x: u64 = _t5; +_t6: u64 = x; +_t7: u64 = x; +_t8: u64 = Mul(_t6, _t7); +x: u64 = _t8; +_t9: u64 = x; +_t10: u64 = 0; +_t11: bool = Gt(_t9, _t10); +loop { + loop { + if (Not(_t11)) break; + _t12: u64 = x; + _t13: u64 = 1; + _t14: u64 = Add(_t12, _t13); + _t1: u64 = _t14; + break[1] + }; + _t15: u64 = x; + _t16: u64 = 1; + _t17: u64 = Sub(_t15, _t16); + _t1: u64 = _t17; + break +}; +_t18: u64 = _t1; +return _t18 + +--- If-Transformed Generated AST +_t3: u64 = x; +_t4: u64 = x; +_t5: u64 = Add(_t3, _t4); +x: u64 = _t5; +_t6: u64 = x; +_t7: u64 = x; +_t8: u64 = Mul(_t6, _t7); +x: u64 = _t8; +_t9: u64 = x; +_t10: u64 = 0; +_t11: bool = Gt(_t9, _t10); +if _t11 { + _t12: u64 = x; + _t13: u64 = 1; + _t14: u64 = Add(_t12, _t13); + _t1: u64 = _t14 +} else { + _t15: u64 = x; + _t16: u64 = 1; + _t17: u64 = Sub(_t15, _t16); + _t1: u64 = _t17 +}; +_t18: u64 = _t1; +return _t18 + +--- Assign-Transformed Generated AST +{ + let _t1: u64; + { + let x: u64 = Add(x, x); + { + let x: u64 = Mul(x, x); + if Gt(x, 0) { + _t1: u64 = Add(x, 1) + } else { + _t1: u64 = Sub(x, 1) + }; + return _t1 + } + } +} + +=== Sourcified Output ============================================ +module 0x815::m { + fun if_1(c: bool): u8 { + let _t1 = 0u8; + if (c) _t1 = 1u8; + _t1 + } + fun if_else_1(c: bool): u8 { + let _t1; + if (c) _t1 = 1u8 else _t1 = 2u8; + _t1 + } + fun if_else_2(c: bool, d: bool): u8 { + let _t2; + if (c) if (d) _t2 = 1u8 else _t2 = 2u8 else _t2 = 3u8; + _t2 + } + fun if_else_3(c: bool): u64 { + let _t1; + if (c) _t1 = 1 else _t1 = 2; + _t1 + } + fun if_else_with_shard_exp(x: u64): u64 { + let _t1; + let x = x + x; + let x = x * x; + if (x > 0) _t1 = x + 1 else _t1 = x - 1; + _t1 + } +} diff --git a/third_party/move/move-model/bytecode/ast-generator-tests/tests/conditionals.move b/third_party/move/move-model/bytecode/ast-generator-tests/tests/conditionals.move new file mode 100644 index 0000000000000..f7b1261d66cb7 --- /dev/null +++ b/third_party/move/move-model/bytecode/ast-generator-tests/tests/conditionals.move @@ -0,0 +1,38 @@ +module 0x815::m { + + fun if_else_1(c: bool): u8 { + if (c) 1 else 2 + } + + fun if_else_2(c: bool, d: bool): u8 { + if (c) { + if (d) { + 1 + } else { + 2 + } + } else { + 3 + } + } + + + fun if_1(c: bool): u8 { + let result = 0; + if (c) { + result = 1; + }; + result + } + + fun if_else_3(c: bool): u64 { + let r = if (c) 1 else 2; + r + } + + fun if_else_with_shard_exp(x: u64): u64 { + let y = x + x; + let z = y * y; + if (z > 0) z + 1 else z - 1 + } +} diff --git a/third_party/move/move-model/bytecode/ast-generator-tests/tests/loops.exp b/third_party/move/move-model/bytecode/ast-generator-tests/tests/loops.exp new file mode 100644 index 0000000000000..1d788d950ed56 --- /dev/null +++ b/third_party/move/move-model/bytecode/ast-generator-tests/tests/loops.exp @@ -0,0 +1,499 @@ + +=== Processing m::loop_1 ===================================================== +--- Source +fun loop_1(c: u64): u64 { + loop { + c = c + 1; + if (c % 2 == 0) continue; + c = c + 3; + if (c % 2 == 1) break; + }; + c + } + +--- Stackless Bytecode +fun m::loop_1($t0|c: u64): u64 { + var $t1|$t3: u64 [unused] + var $t2: u64 + var $t3: u64 + var $t4: u64 + var $t5: u64 + var $t6: u64 + var $t7: u64 + var $t8: u64 + var $t9: bool + var $t10: u64 + var $t11: u64 + var $t12: u64 + var $t13: u64 + var $t14: u64 + var $t15: u64 + var $t16: u64 + var $t17: bool + var $t18: u64 + 0: label L2 + 1: $t2 := move($t0) + 2: $t3 := 1 + 3: $t4 := +($t2, $t3) + 4: $t0 := $t4 + 5: $t5 := copy($t0) + 6: $t6 := 2 + 7: $t7 := %($t5, $t6) + 8: $t8 := 0 + 9: $t9 := ==($t7, $t8) + 10: if ($t9) goto 11 else goto 13 + 11: label L1 + 12: goto 0 + 13: label L0 + 14: $t10 := move($t0) + 15: $t11 := 3 + 16: $t12 := +($t10, $t11) + 17: $t0 := $t12 + 18: $t13 := copy($t0) + 19: $t14 := 2 + 20: $t15 := %($t13, $t14) + 21: $t16 := 1 + 22: $t17 := ==($t15, $t16) + 23: if ($t17) goto 24 else goto 26 + 24: label L4 + 25: goto 28 + 26: label L3 + 27: goto 0 + 28: label L5 + 29: $t18 := move($t0) + 30: return $t18 +} + +--- Raw Generated AST +loop { + _t2: u64 = c; + _t3: u64 = 1; + _t4: u64 = Add(_t2, _t3); + c: u64 = _t4; + _t5: u64 = c; + _t6: u64 = 2; + _t7: u64 = Mod(_t5, _t6); + _t8: u64 = 0; + _t9: bool = Eq(_t7, _t8); + if (_t9) continue; + _t10: u64 = c; + _t11: u64 = 3; + _t12: u64 = Add(_t10, _t11); + c: u64 = _t12; + _t13: u64 = c; + _t14: u64 = 2; + _t15: u64 = Mod(_t13, _t14); + _t16: u64 = 1; + _t17: bool = Eq(_t15, _t16); + if (Not(_t17)) continue; + break +}; +_t18: u64 = c; +return _t18 + +--- If-Transformed Generated AST +loop { + _t2: u64 = c; + _t3: u64 = 1; + _t4: u64 = Add(_t2, _t3); + c: u64 = _t4; + _t5: u64 = c; + _t6: u64 = 2; + _t7: u64 = Mod(_t5, _t6); + _t8: u64 = 0; + _t9: bool = Eq(_t7, _t8); + if (_t9) continue; + _t10: u64 = c; + _t11: u64 = 3; + _t12: u64 = Add(_t10, _t11); + c: u64 = _t12; + _t13: u64 = c; + _t14: u64 = 2; + _t15: u64 = Mod(_t13, _t14); + _t16: u64 = 1; + _t17: bool = Eq(_t15, _t16); + if (Not(_t17)) continue; + break +}; +_t18: u64 = c; +return _t18 + +--- Assign-Transformed Generated AST +loop { + c: u64 = Add(c, 1); + if (Eq(Mod(c, 2), 0)) continue; + c: u64 = Add(c, 3); + if (Not(Eq(Mod(c, 2), 1))) continue; + break +}; +return c + + +=== Processing m::while_1 ===================================================== +--- Source +fun while_1(c: u64) { + while (c > 0) c = c - 1 + } + +--- Stackless Bytecode +fun m::while_1($t0|c: u64) { + var $t1|$t2: u64 [unused] + var $t2: u64 + var $t3: u64 + var $t4: bool + var $t5: u64 + var $t6: u64 + var $t7: u64 + 0: label L4 + 1: $t2 := copy($t0) + 2: $t3 := 0 + 3: $t4 := >($t2, $t3) + 4: if ($t4) goto 5 else goto 11 + 5: label L1 + 6: $t5 := move($t0) + 7: $t6 := 1 + 8: $t7 := -($t5, $t6) + 9: $t0 := $t7 + 10: goto 13 + 11: label L0 + 12: goto 15 + 13: label L2 + 14: goto 0 + 15: label L3 + 16: return () +} + +--- Raw Generated AST +loop { + _t2: u64 = c; + _t3: u64 = 0; + _t4: bool = Gt(_t2, _t3); + loop { + if (Not(_t4)) break; + _t5: u64 = c; + _t6: u64 = 1; + _t7: u64 = Sub(_t5, _t6); + c: u64 = _t7; + continue[1] + }; + break +}; +return Tuple() + +--- If-Transformed Generated AST +loop { + _t2: u64 = c; + _t3: u64 = 0; + _t4: bool = Gt(_t2, _t3); + if _t4 { + _t5: u64 = c; + _t6: u64 = 1; + _t7: u64 = Sub(_t5, _t6); + c: u64 = _t7; + continue + }; + break +}; +return Tuple() + +--- Assign-Transformed Generated AST +loop { + if Gt(c, 0) { + { + let c: u64 = Sub(c, 1); + continue + } + }; + break +}; +return Tuple() + + +=== Processing m::while_2 ===================================================== +--- Source +fun while_2(c: u64): u64 { + while (c > 0) { + if (c >= 10) { + c = c - 10 + } + }; + c = c + 1; + c + } + +--- Stackless Bytecode +fun m::while_2($t0|c: u64): u64 { + var $t1|$t3: u64 [unused] + var $t2: u64 + var $t3: u64 + var $t4: bool + var $t5: u64 + var $t6: u64 + var $t7: bool + var $t8: u64 + var $t9: u64 + var $t10: u64 + var $t11: u64 + var $t12: u64 + var $t13: u64 + 0: label L6 + 1: $t2 := copy($t0) + 2: $t3 := 0 + 3: $t4 := >($t2, $t3) + 4: if ($t4) goto 5 else goto 18 + 5: label L1 + 6: $t5 := copy($t0) + 7: $t6 := 10 + 8: $t7 := >=($t5, $t6) + 9: if ($t7) goto 10 else goto 16 + 10: label L3 + 11: $t8 := move($t0) + 12: $t9 := 10 + 13: $t10 := -($t8, $t9) + 14: $t0 := $t10 + 15: goto 16 + 16: label L2 + 17: goto 20 + 18: label L0 + 19: goto 22 + 20: label L4 + 21: goto 0 + 22: label L5 + 23: $t11 := move($t0) + 24: $t12 := 1 + 25: $t13 := +($t11, $t12) + 26: return $t13 +} + +--- Raw Generated AST +loop { + _t2: u64 = c; + _t3: u64 = 0; + _t4: bool = Gt(_t2, _t3); + loop { + if (Not(_t4)) break; + _t5: u64 = c; + _t6: u64 = 10; + _t7: bool = Ge(_t5, _t6); + if (Not(_t7)) continue[1]; + _t8: u64 = c; + _t9: u64 = 10; + _t10: u64 = Sub(_t8, _t9); + c: u64 = _t10; + continue[1] + }; + break +}; +_t11: u64 = c; +_t12: u64 = 1; +_t13: u64 = Add(_t11, _t12); +return _t13 + +--- If-Transformed Generated AST +loop { + _t2: u64 = c; + _t3: u64 = 0; + _t4: bool = Gt(_t2, _t3); + if _t4 { + _t5: u64 = c; + _t6: u64 = 10; + _t7: bool = Ge(_t5, _t6); + if (Not(_t7)) continue; + _t8: u64 = c; + _t9: u64 = 10; + _t10: u64 = Sub(_t8, _t9); + c: u64 = _t10; + continue + }; + break +}; +_t11: u64 = c; +_t12: u64 = 1; +_t13: u64 = Add(_t11, _t12); +return _t13 + +--- Assign-Transformed Generated AST +loop { + if Gt(c, 0) { + if (Not(Ge(c, 10))) continue; + c: u64 = Sub(c, 10); + continue + }; + break +}; +return Add(c, 1) + + +=== Processing m::while_3 ===================================================== +--- Source +fun while_3(c: u64): u64 { + while (c > 0) { + while (c > 10) c = c - 10; + c = c - 1; + }; + c + } + +--- Stackless Bytecode +fun m::while_3($t0|c: u64): u64 { + var $t1|$t3: u64 [unused] + var $t2: u64 + var $t3: u64 + var $t4: bool + var $t5: u64 + var $t6: u64 + var $t7: bool + var $t8: u64 + var $t9: u64 + var $t10: u64 + var $t11: u64 + var $t12: u64 + var $t13: u64 + var $t14: u64 + 0: label L8 + 1: $t2 := copy($t0) + 2: $t3 := 0 + 3: $t4 := >($t2, $t3) + 4: if ($t4) goto 5 else goto 26 + 5: label L1 + 6: $t5 := copy($t0) + 7: $t6 := 10 + 8: $t7 := >($t5, $t6) + 9: if ($t7) goto 10 else goto 16 + 10: label L3 + 11: $t8 := move($t0) + 12: $t9 := 10 + 13: $t10 := -($t8, $t9) + 14: $t0 := $t10 + 15: goto 18 + 16: label L2 + 17: goto 20 + 18: label L4 + 19: goto 5 + 20: label L5 + 21: $t11 := move($t0) + 22: $t12 := 1 + 23: $t13 := -($t11, $t12) + 24: $t0 := $t13 + 25: goto 28 + 26: label L0 + 27: goto 30 + 28: label L6 + 29: goto 0 + 30: label L7 + 31: $t14 := move($t0) + 32: return $t14 +} + +--- Raw Generated AST +loop { + _t2: u64 = c; + _t3: u64 = 0; + _t4: bool = Gt(_t2, _t3); + loop { + if (Not(_t4)) break; + loop { + _t5: u64 = c; + _t6: u64 = 10; + _t7: bool = Gt(_t5, _t6); + loop { + if (Not(_t7)) break; + _t8: u64 = c; + _t9: u64 = 10; + _t10: u64 = Sub(_t8, _t9); + c: u64 = _t10; + continue[1] + }; + break + }; + _t11: u64 = c; + _t12: u64 = 1; + _t13: u64 = Sub(_t11, _t12); + c: u64 = _t13; + continue[1] + }; + break +}; +_t14: u64 = c; +return _t14 + +--- If-Transformed Generated AST +loop { + _t2: u64 = c; + _t3: u64 = 0; + _t4: bool = Gt(_t2, _t3); + if _t4 { + loop { + _t5: u64 = c; + _t6: u64 = 10; + _t7: bool = Gt(_t5, _t6); + if _t7 { + _t8: u64 = c; + _t9: u64 = 10; + _t10: u64 = Sub(_t8, _t9); + c: u64 = _t10; + continue + }; + break + }; + _t11: u64 = c; + _t12: u64 = 1; + _t13: u64 = Sub(_t11, _t12); + c: u64 = _t13; + continue + }; + break +}; +_t14: u64 = c; +return _t14 + +--- Assign-Transformed Generated AST +loop { + if Gt(c, 0) { + loop { + if Gt(c, 10) { + c: u64 = Sub(c, 10); + continue + }; + break + }; + c: u64 = Sub(c, 1); + continue + }; + break +}; +return c + +=== Sourcified Output ============================================ +module 0x815::m { + fun loop_1(c: u64): u64 { + loop { + c = c + 1; + if (c % 2 == 0) continue; + c = c + 3; + if (!(c % 2 == 1)) continue; + break + }; + c + } + fun while_1(c: u64) { + while (c > 0) { + let c = c - 1; + continue + }; + } + fun while_2(c: u64): u64 { + while (c > 0) { + if (!(c >= 10)) continue; + c = c - 10 + }; + c + 1 + } + fun while_3(c: u64): u64 { + while (c > 0) { + while (c > 10) c = c - 10; + c = c - 1 + }; + c + } +} diff --git a/third_party/move/move-model/bytecode/ast-generator-tests/tests/loops.move b/third_party/move/move-model/bytecode/ast-generator-tests/tests/loops.move new file mode 100644 index 0000000000000..95a671341c962 --- /dev/null +++ b/third_party/move/move-model/bytecode/ast-generator-tests/tests/loops.move @@ -0,0 +1,34 @@ +module 0x815::m { + + fun while_1(c: u64) { + while (c > 0) c = c - 1 + } + + fun while_2(c: u64): u64 { + while (c > 0) { + if (c >= 10) { + c = c - 10 + } + }; + c = c + 1; + c + } + + fun while_3(c: u64): u64 { + while (c > 0) { + while (c > 10) c = c - 10; + c = c - 1; + }; + c + } + + fun loop_1(c: u64): u64 { + loop { + c = c + 1; + if (c % 2 == 0) continue; + c = c + 3; + if (c % 2 == 1) break; + }; + c + } +} diff --git a/third_party/move/move-model/bytecode/ast-generator-tests/tests/match.exp b/third_party/move/move-model/bytecode/ast-generator-tests/tests/match.exp new file mode 100644 index 0000000000000..b73b6ca767690 --- /dev/null +++ b/third_party/move/move-model/bytecode/ast-generator-tests/tests/match.exp @@ -0,0 +1,335 @@ + +=== Processing m::id ===================================================== +--- Source +fun id(self: &Entity): u64 { + match (self) { + Person{id} => *id, + Institution{id, ..} => *id + } + } + +--- Stackless Bytecode +fun m::id($t0|self: &m::Entity): u64 { + var $t1|return: u64 + var $t2: &m::Entity + var $t3: bool + var $t4: &m::Entity + var $t5: &u64 + var $t6: u64 + var $t7: &m::Entity + var $t8: bool + var $t9: &m::Entity + var $t10: &u64 + var $t11: u64 + var $t12: &m::Entity + var $t13: u64 + var $t14: u64 + 0: $t2 := copy($t0) + 1: $t3 := test_variant m::Entity::Person($t2) + 2: if ($t3) goto 3 else goto 9 + 3: label L1 + 4: $t4 := move($t0) + 5: $t5 := borrow_variant_field.id($t4) + 6: $t6 := read_ref($t5) + 7: $t1 := $t6 + 8: goto 24 + 9: label L0 + 10: $t7 := copy($t0) + 11: $t8 := test_variant m::Entity::Institution($t7) + 12: if ($t8) goto 13 else goto 19 + 13: label L4 + 14: $t9 := move($t0) + 15: $t10 := borrow_variant_field.id($t9) + 16: $t11 := read_ref($t10) + 17: $t1 := $t11 + 18: goto 24 + 19: label L3 + 20: $t12 := move($t0) + 21: drop($t12) + 22: $t13 := 14566554180833181697 + 23: abort($t13) + 24: label L2 + 25: $t14 := move($t1) + 26: return $t14 +} + +--- Raw Generated AST +_t2: &m::Entity = self; +_t3: bool = test_variants m::Entity::Person(_t2); +loop { + loop { + if (Not(_t3)) break; + _t4: &m::Entity = self; + _t5: &u64 = select_variants m::Entity.id(_t4); + _t6: u64 = Deref(_t5); + _t1: u64 = _t6; + break[1] + }; + _t7: &m::Entity = self; + _t8: bool = test_variants m::Entity::Institution(_t7); + loop { + loop { + if (Not(_t8)) break; + _t9: &m::Entity = self; + _t10: &u64 = select_variants m::Entity.id(_t9); + _t11: u64 = Deref(_t10); + _t1: u64 = _t11; + break[1] + }; + _t12: &m::Entity = self; + _t13: u64 = 14566554180833181697; + Abort(_t13) + }; + break +}; +_t14: u64 = _t1; +return _t14 + +--- If-Transformed Generated AST +_t2: &m::Entity = self; +_t3: bool = test_variants m::Entity::Person(_t2); +if _t3 { + _t4: &m::Entity = self; + _t5: &u64 = select_variants m::Entity.id(_t4); + _t6: u64 = Deref(_t5); + _t1: u64 = _t6 +} else { + _t7: &m::Entity = self; + _t8: bool = test_variants m::Entity::Institution(_t7); + if _t8 { + _t9: &m::Entity = self; + _t10: &u64 = select_variants m::Entity.id(_t9); + _t11: u64 = Deref(_t10); + _t1: u64 = _t11 + } else { + _t12: &m::Entity = self; + _t13: u64 = 14566554180833181697; + Abort(_t13) + } +}; +_t14: u64 = _t1; +return _t14 + +--- Assign-Transformed Generated AST +{ + let _t1: u64; + if test_variants m::Entity::Person(self) { + _t1: u64 = Deref(select_variants m::Entity.id(self)) + } else { + if test_variants m::Entity::Institution(self) { + _t1: u64 = Deref(select_variants m::Entity.id(self)) + } else { + Abort(14566554180833181697) + } + }; + return _t1 +} + + +=== Processing m::id2 ===================================================== +--- Source +fun id2(self: Entity): u64 { + match (self) { + Person{id} if id > 0 => id, + Institution{id, ..} => id, + _ => 0 + } + } + +--- Stackless Bytecode +fun m::id2($t0|self: m::Entity): u64 { + var $t1|$t2: &m::Entity + var $t2|$t5: u64 + var $t3: &m::Entity + var $t4: &m::Entity + var $t5: bool + var $t6: &m::Entity + var $t7: &u64 + var $t8: u64 + var $t9: u64 + var $t10: bool + var $t11: &m::Entity + var $t12: m::Entity + var $t13: u64 + var $t14: &m::Entity + var $t15: bool + var $t16: m::Entity + var $t17: u64 + var $t18: u64 + var $t19: u64 + var $t20: u64 + 0: $t3 := borrow_local($t0) + 1: $t1 := $t3 + 2: $t4 := copy($t1) + 3: $t5 := test_variant m::Entity::Person($t4) + 4: if ($t5) goto 5 else goto 19 + 5: label L1 + 6: $t6 := copy($t1) + 7: $t7 := borrow_variant_field.id($t6) + 8: $t8 := read_ref($t7) + 9: $t9 := 0 + 10: $t10 := >($t8, $t9) + 11: if ($t10) goto 12 else goto 19 + 12: label L2 + 13: $t11 := move($t1) + 14: drop($t11) + 15: $t12 := move($t0) + 16: $t13 := unpack_variant m::Entity::Person($t12) + 17: $t2 := $t13 + 18: goto 33 + 19: label L0 + 20: $t14 := move($t1) + 21: $t15 := test_variant m::Entity::Institution($t14) + 22: if ($t15) goto 23 else goto 29 + 23: label L5 + 24: $t16 := move($t0) + 25: ($t17, $t18) := unpack_variant m::Entity::Institution($t16) + 26: drop($t18) + 27: $t2 := $t17 + 28: goto 33 + 29: label L4 + 30: $t19 := 0 + 31: $t2 := $t19 + 32: goto 33 + 33: label L3 + 34: $t20 := move($t2) + 35: return $t20 +} + +--- Raw Generated AST +_t3: &m::Entity = Borrow(Immutable)(self); +_t1: &m::Entity = _t3; +_t4: &m::Entity = _t1; +_t5: bool = test_variants m::Entity::Person(_t4); +loop { + loop { + if (Not(_t5)) break; + _t6: &m::Entity = _t1; + _t7: &u64 = select_variants m::Entity.id(_t6); + _t8: u64 = Deref(_t7); + _t9: u64 = 0; + _t10: bool = Gt(_t8, _t9); + if (Not(_t10)) break; + _t11: &m::Entity = _t1; + _t12: m::Entity = self; + m::Entity::Person{ id: _t13 } = _t12; + _t2: u64 = _t13; + break[1] + }; + _t14: &m::Entity = _t1; + _t15: bool = test_variants m::Entity::Institution(_t14); + loop { + loop { + if (Not(_t15)) break; + _t16: m::Entity = self; + m::Entity::Institution{ id: _t17, admin: _t18 } = _t16; + _t2: u64 = _t17; + break[1] + }; + _t19: u64 = 0; + _t2: u64 = _t19; + break + }; + break +}; +_t20: u64 = _t2; +return _t20 + +--- If-Transformed Generated AST +_t3: &m::Entity = Borrow(Immutable)(self); +_t1: &m::Entity = _t3; +_t4: &m::Entity = _t1; +_t5: bool = test_variants m::Entity::Person(_t4); +loop { + loop { + if (Not(_t5)) break; + _t6: &m::Entity = _t1; + _t7: &u64 = select_variants m::Entity.id(_t6); + _t8: u64 = Deref(_t7); + _t9: u64 = 0; + _t10: bool = Gt(_t8, _t9); + if (Not(_t10)) break; + _t11: &m::Entity = _t1; + _t12: m::Entity = self; + m::Entity::Person{ id: _t13 } = _t12; + _t2: u64 = _t13; + break[1] + }; + _t14: &m::Entity = _t1; + _t15: bool = test_variants m::Entity::Institution(_t14); + if _t15 { + _t16: m::Entity = self; + m::Entity::Institution{ id: _t17, admin: _t18 } = _t16; + _t2: u64 = _t17 + } else { + _t19: u64 = 0; + _t2: u64 = _t19 + }; + break +}; +_t20: u64 = _t2; +return _t20 + +--- Assign-Transformed Generated AST +{ + let _t2: u64; + { + let _t1: &m::Entity = Borrow(Immutable)(self); + loop { + loop { + if (Not(test_variants m::Entity::Person(_t1))) break; + if (Not(Gt(Deref(select_variants m::Entity.id(_t1)), 0))) break; + { + let m::Entity::Person{ id: _t13 } = self; + break[1] + } + }; + if test_variants m::Entity::Institution(_t1) { + { + let m::Entity::Institution{ id: _t17, admin: _t18 } = self; + _t2: u64 = _t17 + } + } else { + _t2: u64 = 0 + }; + break + }; + return _t2 + } +} + +=== Sourcified Output ============================================ +module 0x815::m { + enum Entity has drop { + Person { + id: u64, + } + Institution { + id: u64, + admin: u64, + } + } + fun id(self: &Entity): u64 { + let _t1; + if (self is Person) _t1 = *self.id else if (self is Institution) _t1 = *self.id else abort 14566554180833181697; + _t1 + } + fun id2(self: Entity): u64 { + let _t2; + let _t1 = &self; + 'l0: loop { + loop { + if (!(_t1 is Person)) break; + if (!(*_t1.id > 0)) break; + let Entity::Person{id: _t13} = self; + break 'l0 + }; + if (_t1 is Institution) { + let Entity::Institution{id: _t17,admin: _t18} = self; + _t2 = _t17 + } else _t2 = 0; + break + }; + _t2 + } +} diff --git a/third_party/move/move-model/bytecode/ast-generator-tests/tests/match.move b/third_party/move/move-model/bytecode/ast-generator-tests/tests/match.move new file mode 100644 index 0000000000000..451429e02f126 --- /dev/null +++ b/third_party/move/move-model/bytecode/ast-generator-tests/tests/match.move @@ -0,0 +1,21 @@ +module 0x815::m { + enum Entity has drop { + Person { id: u64 }, + Institution { id: u64, admin: u64 } + } + + fun id(self: &Entity): u64 { + match (self) { + Person{id} => *id, + Institution{id, ..} => *id + } + } + + fun id2(self: Entity): u64 { + match (self) { + Person{id} if id > 0 => id, + Institution{id, ..} => id, + _ => 0 + } + } +} diff --git a/third_party/move/move-model/bytecode/ast-generator-tests/tests/testsuite.rs b/third_party/move/move-model/bytecode/ast-generator-tests/tests/testsuite.rs new file mode 100644 index 0000000000000..067f8f3a8b0b7 --- /dev/null +++ b/third_party/move/move-model/bytecode/ast-generator-tests/tests/testsuite.rs @@ -0,0 +1,133 @@ +// Copyright © Aptos Foundation +// Parts of the project are originally copyright © Meta Platforms, Inc. +// SPDX-License-Identifier: Apache-2.0 + +use codespan_reporting::term::termcolor::Buffer; +use move_compiler_v2::{logging, run_move_compiler_for_analysis, Options}; +use move_model::{ast::Exp, metadata::LanguageVersion, model::GlobalEnv, sourcifier::Sourcifier}; +use move_prover_test_utils::{baseline_test, extract_test_directives}; +use move_stackless_bytecode::{ + astifier, + function_target::FunctionTarget, + function_target_pipeline::{FunctionTargetsHolder, FunctionVariant}, +}; +use std::{ + collections::BTreeSet, + path::{Path, PathBuf}, +}; + +/// Extension for expected output files +pub const EXP_EXT: &str = "exp"; + +datatest_stable::harness!(test_runner, "tests", r".*\.move$"); + +fn test_runner(path: &Path) -> datatest_stable::Result<()> { + logging::setup_logging_for_testing(); + let path_str = path.display().to_string(); + let mut options = Options { + sources_deps: extract_test_directives(path, "// dep:")?, + sources: vec![path_str.clone()], + dependencies: if extract_test_directives(path, "// no-stdlib")?.is_empty() { + vec![path_from_crate_root("../../../move-stdlib/sources")] + } else { + vec![] + }, + named_address_mapping: vec!["std=0x1".to_string()], + ..Options::default() + }; + options = options.set_language_version(LanguageVersion::V2_1); + let mut test_output = String::new(); + let mut error_writer = Buffer::no_color(); + match run_move_compiler_for_analysis(&mut error_writer, options) { + Err(_) => { + test_output.push_str(&format!( + "--- Aborting with compilation errors:\n{}\n", + String::from_utf8_lossy(&error_writer.into_inner()) + )); + }, + Ok(mut env) => { + let targets = create_targets(&env); + let mut modules = BTreeSet::new(); + for fun_id in targets.get_funs() { + let fun_env = env.get_function(fun_id); + modules.insert(fun_env.module_env.get_id()); + let def = generate_output( + &targets.get_target(&env.get_function(fun_id), &FunctionVariant::Baseline), + &mut test_output, + ); + if let Some(def) = def { + env.set_function_def(fun_id, def); + } + } + let sourcifier = Sourcifier::new(&env); + for mid in modules { + sourcifier.print_module(mid) + } + test_output += &format!( + "=== Sourcified Output ============================================\n{}", + sourcifier.result() + ) + }, + } + // Generate/check baseline. + let baseline_path = path.with_extension(EXP_EXT); + baseline_test::verify_or_update_baseline(baseline_path.as_path(), &test_output)?; + Ok(()) +} + +fn generate_output(target: &FunctionTarget, test_output: &mut String) -> Option { + *test_output += &format!( + "\n=== Processing {} =====================================================\n", + target.func_env.get_full_name_str() + ); + *test_output += &format!( + "--- Source\n{}\n", + target + .global_env() + .get_source(&target.get_loc()) + .unwrap_or("UNKNOWN") + ); + + *test_output += &format!("\n--- Stackless Bytecode\n{}\n", target); + + let Some(exp) = astifier::generate_ast_raw(target) else { + *test_output += "--- Raw Generated AST\nFAILED\n"; + return None; + }; + *test_output += &format!( + "--- Raw Generated AST\n{}\n\n", + exp.display_for_fun(target.func_env.clone()) + ); + let exp = astifier::transform_conditionals(target, exp); + *test_output += &format!( + "--- If-Transformed Generated AST\n{}\n\n", + exp.display_for_fun(target.func_env.clone()) + ); + let exp = astifier::transform_assigns(target, exp); + *test_output += &format!( + "--- Assign-Transformed Generated AST\n{}\n\n", + exp.display_for_fun(target.func_env.clone()) + ); + Some(exp) +} + +/// Create function targets with stackless bytecode for modules which are target. +/// This decompiles Move binary format into stackless bytecode. +fn create_targets(env: &GlobalEnv) -> FunctionTargetsHolder { + let mut targets = FunctionTargetsHolder::default(); + for module_env in env.get_modules() { + if module_env.is_primary_target() { + for func_env in module_env.get_functions() { + targets.add_target(&func_env) + } + } + } + targets +} + +/// Returns a path relative to the crate root. +fn path_from_crate_root(path: &str) -> String { + let mut buf = PathBuf::from(env!("CARGO_MANIFEST_DIR")); + buf.push(path); + buf.to_string_lossy().to_string() +} diff --git a/third_party/move/move-model/bytecode/src/astifier.rs b/third_party/move/move-model/bytecode/src/astifier.rs new file mode 100644 index 0000000000000..1f76329dea2e6 --- /dev/null +++ b/third_party/move/move-model/bytecode/src/astifier.rs @@ -0,0 +1,1990 @@ +// Copyright © Aptos Foundation +// Parts of the project are originally copyright © Meta Platforms, Inc. +// SPDX-License-Identifier: Apache-2.0 + +//! Converts stackless bytecode into Model AST. +//! +//! See [this article](https://medium.com/leaningtech/solving-the-structured-control-flow-problem-once-and-for-all-5123117b1ee2) +//! for an introduction into how this code works. This is an excellent high-level overview of +//! the decompilation problem and the solution which is adapted here. The article is a relative +//! light read and hence leaves many details open, which an implementation has to determine. +//! +//! In a nutshell, the decompilation from stackless bytecode into the Model AST here +//! works in the steps outlined below +//! +//! # 1. Cleanup +//! +//! The code is cleaned up such that there are no jump proxies of the form `label L; goto L1`. +//! Also, adjacent sequential blocks are merged, and fallthroughs extended by explicit jumps. +//! It is important for the algorithm to work that all those intermediate blocks are removed +//! and all remaining blocks represent a true branching structure. +//! +//! # 2. Loop Analysis +//! +//! Compute loop information using the `fat_loop` module. This allows to distinguish +//! backward jumps from forward jumps. The fat_loop bails out if the control graph is +//! not reducible. +//! +//! # 3. Topological Sorting +//! +//! Topological sort the blocks using forward edges only. For those blocks which are not related +//! in the partial order, prioritize that for a branch `if c goto L1 else goto L2`, target +//! blocks follow after the branch. Moreover, for any blocks belonging to a loop, ensure that +//! they all appear before any blocks which are part of the loop. +//! +//! # 4. Raw AST Generation +//! +//! The article linked above describes well how blocks can be used to synthesize structured +//! code. However, it leaves open when to open blocks and when to close them. +//! +//! First, in Move, we express blocks (whether they have back jumps and are proper loops or not) +//! by `loop { ..; break }`. Now, in the presence of nested `break[n]` and `continue[n]`, any +//! forward (via break) and backward (via continue) jump can be modelled. +//! +//! ## 4.1 Opening Loops +//! +//! Loops are opened when we either encounter a loop header or a branch. We know what block +//! a loop header is and what are the back edges from (2) above. In the case of +//! branches we need two loops. Consider bytecode for an if-then-else +//! +//! ```ignore +//! if c goto L1 else goto L2 +//! label L1 +//! .. then .. +//! goto L3 +//! label L2 +//! .. else .. +//! goto L3 +//! label L3 +//! .. end .. +//! ``` +//! +//! This is translated to: +//! +//! ```ignore +//! loop { +//! loop { +//! if !c break; +//! .. then .. +//! break[1] +//! } // L2 jumps here +//! .. else .. +//! break +//! } // L3 jumps here +//! ``` +//! +//! Notice at the point when those two loops are opened (on encountering +//! `if c goto L1 else goto L2`), the label `L3` is not known. It appears +//! somewhere later in the sequence of blocks, with an arbitrary number +//! of other blocks in between resulting from nested control flows. +//! The algorithm continues to process the blocks in topological +//! order, opening sub-blocks as needed, until it encounters a jump +//! to a label which is not yet associated with any loop, which is then +//! associated with the unbound loop label. In the above bytecode example, this +//! would be the first `jump L3` in sequence. This is sound +//! because of the way how the blocks were sorted in (3): there are no +//! "interleaving" control flows (as also mentioned in the linked article), +//! and at the moment `L3` is encountered, no other sub-graphs of the control flow +//! have still open blocks. +//! +//! ## 4.2 Closing Loops +//! +//! Loops are closed when their exit label is reached. For the above +//! example, the inner loop is closed on bytecode `label L2` and the +//! outer on `label 3`. Some loops which have been opened may never +//! be associated with a label (for example, in an +//! `if goto L1 else goto L2` where one of the targets is a back jump +//! in a loop). Those are closed when an enclosing loop's label +//! is reached. +//! +//! # 5. AST Transformations +//! +//! Once the raw AST has been generated as described above, it is +//! run through a few transformation steps: +//! +//! 1. *Conditional Transformation* discovers if-then-else +//! expressions from the nested loops as generated by the core +//! algorithm. This is based on pattern matching against the AST. +//! It is possible that the rules used here need to be extended +//! over time, as it is kind of heuristic. +//! 2. *Assignment Transformation* removes obsoletes assignments +//! by propagating reaching definitions. It also introduces +//! `let` declarations for temporaries scoped to a block. +//! +//! A number of tools are defined in this module to perform AST +//! transformations, including a data flow analysis +//! framework for ASTs in the form as generated by the core +//! algorithms. They are kept local here but can be pulled +//! out of this module if more general use cases arise. + +use crate::{ + dataflow_domains::{AbstractDomain, JoinResult, MapDomain, SetDomain}, + fat_loop::{build_loop_info, FatLoopFunctionInfo}, + function_target::FunctionTarget, + stackless_bytecode::{AttrId, Bytecode, Label, Operation as BytecodeOperation}, + stackless_control_flow_graph::{BlockId, StacklessControlFlowGraph}, +}; +use abstract_domain_derive::AbstractDomain; +use itertools::Itertools; +use log::{debug, log_enabled, Level}; +use move_binary_format::file_format::CodeOffset; +use move_model::{ + ast::{Exp, ExpData, Operation, Pattern, TempIndex}, + exp_builder::ExpBuilder, + exp_rewriter::ExpRewriterFunctions, + model::{GlobalEnv, Loc, NodeId, QualifiedInstId, StructId}, + symbol::Symbol, + ty::{ReferenceKind, Type}, +}; +use std::collections::{BTreeMap, BTreeSet}; +use topological_sort::TopologicalSort; + +const DEBUG: bool = false; + +// =========================================================================================== +// Ast Generator + +/// Main entry point for generating AST for a given function target with associated stackless +/// bytecode. +pub fn generate_ast(target: &FunctionTarget) -> Option { + let exp = generate_ast_raw(target)?; + Some(transform_assigns( + target, + transform_conditionals(target, exp), + )) +} + +/// Entry point for raw generation, without prettifying the AST. +pub fn generate_ast_raw(target: &FunctionTarget) -> Option { + // First cleanup the code. In order to make the algorithm work, unnecessary blocks need to + // be eliminated. + let cleanup_context = Context::new(target); + let cleaned_code = cleanup_context.clean_bytecode(); + let mut new_data = target.data.clone(); + new_data.code = cleaned_code; + let target = FunctionTarget::new(target.func_env, &new_data); + + // Now create a new context for working with the cleaned code. + let mut ctx = Context::new(&target); + + let unreached_labels = ctx + // All labels with corresponding blocks in code. + .forward_cfg + .blocks() + .iter() + .filter_map(|blk_id| ctx.label_of_block(*blk_id)) + .collect(); + + let fat_loop_info = match build_loop_info(&target) { + // Compute the fat loops of this code. A fat loop is a loop with multiple back-edges all + // sharing the same loop header. + Ok(loop_info) => loop_info, + Err(err) => { + // This happens if the cfg is not reducible. + // TODO: we may want to have a fallback strategy for this case. We can generate + // a big outer loop with a case for each block and a variable holding the current + // block number. + target.global_env().error( + &target.get_loc(), + &format!("cannot decompile function: {}", err), + ); + return None; + }, + }; + ctx.compute_loop_info(&fat_loop_info); + + // Create the generator and run it. + let mut gen = Generator { + block_stack: vec![], + unreached_labels, + used_labels: BTreeSet::new(), + current_attr: None, + }; + Some(gen.gen(&ctx)) +} + +// ------------------------------------------------------------------------------------------- +// Data Types + +/// Immutable context used for generation. +struct Context<'a> { + /// The function target. + target: &'a FunctionTarget<'a>, + /// Forward control flow graph of the given code. + forward_cfg: StacklessControlFlowGraph, + /// Expression builder. + builder: ExpBuilder<'a>, + /// Mapping from labels to the code offset they are associated with. + label_offsets: BTreeMap, + /// Loop headers. These are the labels of the blocks which dominate all other blocks + /// in a loop. + loop_headers: BTreeSet