From 27a97e927acbec85c5fcf0c63e161de4c3a6201f Mon Sep 17 00:00:00 2001 From: Wolfgang Grieskamp Date: Thu, 14 Mar 2024 12:38:11 -0700 Subject: [PATCH 1/3] [prover-v2] Connecting Prover to v2 code generation toolchain This concludes connecting the Move prover to the bytecode generated by the v2 compiler (modulo some remaining issues for which bugs have been opened). - Generates full SourceMap as the prover needs it for error messages - Generates new `SpecBlock` stackless bytecode instruction for specification blocks, and processes them such that they can be associated by the prover with the bytecode - Plumbs the CLI `--compiler-version v2` and `MOVE_COMPILER_V2` env var through the spaghetti of aptos cli and Move package system such that v2 compiler is called for model building - Adds a new entry point to the compiler `run_move_compiler_for_analysis` which builds a model with the v2 compiler for tools like the prover. Also refactors a few other entrypoints in the compiler. - Adds a new flag to prover driver `--compiler-v2` to for direct prover invocation. Also adds `--aptos` for adding Aptos specific prelude in standalone command line mode. - Fixes a bug in the borrow analyis (but also see #12533) - Adds some `verify_duration_estimate` pragmas to the framework spec as v2 prover times out (this might be a result of more complex code generated which we should fix down the road with optimizations) - Adds a new test feature to the prover unit tests such that all of them run both against v1 and v2. The v2 exp files are different if it comes to backtracs, which is to be expected with different generated code, but have been compared 1:1 to check whether they are equivalent - Fixes a small bug in reference-safety discovered by the prover tests --- Cargo.lock | 1 + .../aptos-framework/doc/staking_config.md | 3 +- .../sources/configs/staking_config.spec.move | 1 + .../tests/smart_vector_test.move | 1 + .../framework/move-stdlib/doc/features.md | 3 + .../sources/configs/features.spec.move | 4 + aptos-move/framework/src/built_package.rs | 2 + aptos-move/framework/src/prover.rs | 10 +- .../framework/tests/move_prover_tests.rs | 1 + crates/aptos/src/move_tool/mod.rs | 1 + .../move/evm/move-to-yul/src/functions.rs | 7 +- .../src/bytecode_generator.rs | 22 +- .../function_generator.rs | 151 ++++++++-- .../file_format_generator/module_generator.rs | 51 +++- third_party/move/move-compiler-v2/src/lib.rs | 106 ++++++- .../move/move-compiler-v2/src/options.rs | 3 + .../pipeline/reference_safety_processor.rs | 2 +- .../tests/ability-transform/mutate_return.exp | 36 +-- .../tests/bytecode-generator/assign.exp | 2 +- .../tests/bytecode-generator/borrow.exp | 4 +- .../bytecode-generator/borrow_invalid.exp | 60 +++- .../bytecode-generator/conditional_borrow.exp | 16 +- .../bytecode-generator/escape_autoref.exp | 8 +- .../tests/bytecode-generator/fields.exp | 18 +- .../bytecode-generator/fields_invalid.exp | 2 +- .../tests/bytecode-generator/inline_specs.exp | 10 +- .../bytecode-generator/spec_construct.exp | 2 +- .../bytecode-verify-failure/equality.exp | 10 +- .../checking/inlining/acquires_error_msg.exp | 2 +- .../checking/inlining/resources_invalid.exp | 4 +- .../checking/specs/inline_fun_in_spec.exp | 2 +- .../checking/specs/intrinsic_decl_ok.exp | 2 +- .../tests/checking/specs/invariants_ok.exp | 2 +- .../specs/move_function_in_spec_ok.exp | 8 +- .../tests/checking/specs/quantifiers_ok.exp | 4 +- .../tests/checking/specs/schemas_err.exp | 77 +++++ .../tests/checking/specs/schemas_ok.exp | 52 ++++ .../tests/checking/specs/structs_ok.exp | 6 +- .../tests/checking/specs/update_field_ok.exp | 2 +- .../tests/checking/typing/binary_add.exp | 4 +- .../tests/checking/typing/binary_and.exp | 2 +- .../tests/checking/typing/binary_bit_and.exp | 4 +- .../tests/checking/typing/binary_bit_or.exp | 4 +- .../tests/checking/typing/binary_div.exp | 4 +- .../tests/checking/typing/binary_geq.exp | 4 +- .../tests/checking/typing/binary_gt.exp | 4 +- .../tests/checking/typing/binary_leq.exp | 4 +- .../tests/checking/typing/binary_lt.exp | 4 +- .../tests/checking/typing/binary_mod.exp | 4 +- .../tests/checking/typing/binary_mul.exp | 4 +- .../tests/checking/typing/binary_or.exp | 2 +- .../tests/checking/typing/binary_shl.exp | 4 +- .../tests/checking/typing/binary_shr.exp | 4 +- .../tests/checking/typing/binary_sub.exp | 4 +- .../tests/checking/typing/binary_xor.exp | 4 +- .../tests/checking/typing/borrow_field.exp | 2 +- .../checking/typing/borrow_field_chain.exp | 18 +- .../typing/borrow_field_complex_root_expr.exp | 12 +- .../checking/typing/borrow_field_internal.exp | 4 +- .../typing/borrow_field_non_ref_root.exp | 8 +- .../tests/checking/typing/derefrence.exp | 16 +- .../checking/typing/derefrence_reference.exp | 6 +- .../typing/implicit_deref_borrow_field.exp | 2 +- .../implicit_deref_borrow_field_chain.exp | 8 +- ...t_deref_borrow_field_complex_root_expr.exp | 10 +- .../implicit_deref_borrow_field_internal.exp | 4 +- ...ef_borrow_field_non_ref_non_local_root.exp | 8 +- ...plicit_deref_borrow_field_non_ref_root.exp | 4 +- .../checking/typing/mutable_eq_and_neq.exp | 24 +- .../tests/checking/typing/mutate.exp | 14 +- .../checking/typing/mutate_field_internal.exp | 4 +- .../checking/typing/nested_post_process.exp | 8 +- .../tests/checking/typing/unary_not.exp | 2 +- .../tests/file-format-generator/with_spec.exp | 3 +- .../tests/lambda-lifting/modify.exp | 6 +- .../simplifier-elimination/binary_add.exp | 4 +- .../tests/simplifier/conditional_borrow.exp | 16 +- .../tests/simplifier/simplifier_test4.exp | 4 +- .../access_control/dynamic.exp | 4 +- .../access_control/generic.exp | 2 +- .../access_control/negation.exp | 4 +- .../access_control/resource.exp | 8 +- .../access_control/wildcard.exp | 4 +- .../bytecode/src/borrow_analysis.rs | 33 ++- .../bytecode/src/stackless_bytecode.rs | 15 +- .../src/stackless_bytecode_generator.rs | 7 +- third_party/move/move-model/src/ast.rs | 22 ++ .../move-model/src/builder/exp_builder.rs | 1 + .../move/move-model/src/exp_rewriter.rs | 68 ----- third_party/move/move-model/src/lib.rs | 22 +- third_party/move/move-model/src/model.rs | 66 +++-- third_party/move/move-model/src/symbol.rs | 6 + third_party/move/move-model/src/well_known.rs | 2 +- .../boogie-backend/src/bytecode_translator.rs | 25 +- .../boogie-backend/src/spec_translator.rs | 2 +- .../src/verification_analysis.rs | 8 + third_party/move/move-prover/src/cli.rs | 20 +- third_party/move/move-prover/src/lib.rs | 42 ++- third_party/move/move-prover/src/main.rs | 8 +- .../functional/ModifiesErrorTest.v2_exp | 79 +++++ .../functional/ModifiesSchemaTest.v2_exp | 20 ++ .../functional/ModifiesTypeTest.v2_exp | 16 + .../tests/sources/functional/aborts_if.v2_exp | 159 ++++++++++ .../functional/aborts_if_with_code.v2_exp | 101 +++++++ .../sources/functional/address_quant.v2_exp | 16 + ...address_serialization_constant_size.v2_exp | 15 + .../tests/sources/functional/arithm.v2_exp | 221 ++++++++++++++ .../sources/functional/bitwise_features.move | 14 +- .../tests/sources/functional/cast.v2_exp | 64 ++++ .../tests/sources/functional/choice.v2_exp | 154 ++++++++++ .../tests/sources/functional/consts.v2_exp | 48 +++ .../data_invariant_for_mut_ref_arg.v2_exp | 51 ++++ .../functional/data_invariant_in_map.v2_exp | 15 + .../sources/functional/disable_inv.v2_exp | 29 ++ .../functional/disable_inv_friends.v2_exp | 15 + .../functional/disable_inv_indirect.v2_exp | 20 ++ .../duplicate_function_declarations.v2_exp | 8 + .../tests/sources/functional/emits.v2_exp | 266 +++++++++++++++++ .../functional/fixed_point_arithm.v2_exp | 156 ++++++++++ .../functional/generic_invariants.v2_exp | 280 ++++++++++++++++++ .../functional/global_invariants.v2_exp | 65 ++++ .../sources/functional/global_vars.v2_exp | 79 +++++ .../sources/functional/hash_model.v2_exp | 44 +++ .../functional/hash_model_invalid.v2_exp | 44 +++ .../sources/functional/inconsistency.v2_exp | 11 + .../inconsistency_always_abort.v2_exp | 20 ++ .../sources/functional/inline-lambda.v2_exp | 37 +++ .../functional/inline_fun_simple.v2_exp | 12 + .../sources/functional/invariants.v2_exp | 57 ++++ .../functional/invariants_resources.v2_exp | 13 + .../sources/functional/is_txn_signer.v2_exp | 62 ++++ .../tests/sources/functional/let.v2_exp | 69 +++++ .../functional/loop_invariant_invalid.v2_exp | 24 ++ .../sources/functional/loop_unroll.v2_exp | 122 ++++++++ .../tests/sources/functional/loops.v2_exp | 166 +++++++++++ .../functional/loops_with_memory_ops.v2_exp | 115 +++++++ .../functional/macro_verification.v2_exp | 148 +++++++++ .../functional/module_level_spec.v2_exp | 15 + .../tests/sources/functional/mono.v2_exp | 70 +++++ .../tests/sources/functional/mut_ref.v2_exp | 45 +++ .../functional/nested_invariants.v2_exp | 60 ++++ .../functional/nonlinear_arithm.v2_exp | 170 +++++++++++ .../sources/functional/old_param_err.v2_exp | 6 + .../tests/sources/functional/opaque.v2_exp | 11 + .../tests/sources/functional/pragma.v2_exp | 17 ++ .../pure_function_call_incorrect.v2_exp | 15 + .../sources/functional/references.v2_exp | 25 ++ .../tests/sources/functional/resources.v2_exp | 18 ++ .../sources/functional/restrictions.v2_exp | 36 +++ .../sources/functional/return_values.v2_exp | 34 +++ .../sources/functional/schema_apply.v2_exp | 8 + .../sources/functional/schema_exp.v2_exp | 33 +++ .../sources/functional/schema_name.v2_exp | 9 + .../functional/script_incorrect.v2_exp | 32 ++ .../sources/functional/serialize_model.v2_exp | 22 ++ .../tests/sources/functional/shift.v2_exp | 42 +++ .../sources/functional/signer_display.v2_exp | 10 + .../sources/functional/specs_in_fun.v2_exp | 51 ++++ .../sources/functional/strong_edges.v2_exp | 31 ++ .../tests/sources/functional/trace.v2_exp | 89 ++++++ .../functional/type_dependent_code.v2_exp | 90 ++++++ .../sources/functional/type_reflection.v2_exp | 15 + .../functional/uninst_global_invariant.v2_exp | 11 + .../functional/unused_global_invariant.v2_exp | 29 ++ .../sources/functional/unused_schema.v2_exp | 9 + .../functional/verify_custom_table.v2_exp | 97 ++++++ .../sources/functional/verify_table.v2_exp | 46 +++ .../tests/sources/regression/Escape.v2_exp | 27 ++ .../mono_after_global_invariant.v2_exp | 23 ++ .../regression/type_param_bug_121721.v2_exp | 24 ++ .../regression/type_param_bug_200228.v2_exp | 15 + .../vector_theory_boogie_array.v2_exp | 21 ++ .../move/move-prover/tests/testsuite.rs | 25 +- .../move/tools/move-cli/src/base/docgen.rs | 7 +- .../move/tools/move-cli/src/base/errmap.rs | 3 +- .../move/tools/move-cli/src/base/prove.rs | 2 + .../move/tools/move-package/Cargo.toml | 1 + .../src/compilation/model_builder.rs | 52 +++- .../move/tools/move-package/src/lib.rs | 2 + .../tools/move-package/tests/test_runner.rs | 43 ++- .../compilation/basic_no_deps/Move.exp | 4 +- .../basic_no_deps_address_assigned/Move.exp | 4 +- .../Move.exp | 4 +- .../basic_no_deps_test_mode/Move.exp | 4 +- .../Move.exp | 4 +- .../diamond_problem_no_conflict/Move.exp | 4 +- .../compilation/multiple_deps_rename/Move.exp | 4 +- .../multiple_deps_rename_one/Move.exp | 4 +- .../test_sources/compilation/one_dep/Move.exp | 4 +- .../one_dep_assigned_address/Move.exp | 4 +- .../compilation/one_dep_renamed/Move.exp | 4 +- .../compilation/one_dep_with_scripts/Move.exp | 4 +- .../compilation/test_symlinks/Move.exp | 4 +- .../invalid_identifier_package_name/Move.exp | 4 +- .../parsing/minimal_manifest/Move.exp | 4 +- .../resolution/basic_no_deps/Move.exp | 4 +- .../basic_no_deps_address_assigned/Move.exp | 4 +- .../Move.exp | 4 +- .../resolution/dep_good_digest/Move.exp | 4 +- .../Move.exp | 4 +- .../diamond_problem_no_conflict/Move.exp | 4 +- .../resolution/multiple_deps_rename/Move.exp | 4 +- .../test_sources/resolution/one_dep/Move.exp | 4 +- .../one_dep_assigned_address/Move.exp | 4 +- .../one_dep_multiple_of_same_name/Move.exp | 4 +- .../one_dep_reassigned_address/Move.exp | 4 +- .../Move.exp | 4 +- 207 files changed, 5190 insertions(+), 458 deletions(-) create mode 100644 third_party/move/move-prover/tests/sources/functional/ModifiesErrorTest.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/ModifiesSchemaTest.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/ModifiesTypeTest.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/aborts_if.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/aborts_if_with_code.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/address_quant.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/address_serialization_constant_size.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/arithm.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/cast.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/choice.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/consts.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/data_invariant_for_mut_ref_arg.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/data_invariant_in_map.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/disable_inv.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/disable_inv_friends.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/disable_inv_indirect.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/duplicate_function_declarations.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/emits.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/fixed_point_arithm.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/generic_invariants.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/global_invariants.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/global_vars.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/hash_model.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/hash_model_invalid.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/inconsistency.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/inconsistency_always_abort.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/inline-lambda.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/inline_fun_simple.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/invariants.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/invariants_resources.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/is_txn_signer.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/let.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/loop_invariant_invalid.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/loop_unroll.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/loops.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/loops_with_memory_ops.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/macro_verification.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/module_level_spec.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/mono.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/mut_ref.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/nested_invariants.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/nonlinear_arithm.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/old_param_err.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/opaque.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/pragma.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/pure_function_call_incorrect.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/references.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/resources.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/restrictions.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/return_values.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/schema_apply.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/schema_exp.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/schema_name.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/script_incorrect.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/serialize_model.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/shift.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/signer_display.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/specs_in_fun.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/strong_edges.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/trace.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/type_dependent_code.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/type_reflection.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/uninst_global_invariant.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/unused_global_invariant.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/unused_schema.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/verify_custom_table.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/functional/verify_table.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/regression/Escape.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/regression/mono_after_global_invariant.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/regression/type_param_bug_121721.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/regression/type_param_bug_200228.v2_exp create mode 100644 third_party/move/move-prover/tests/sources/regression/vector_theory_boogie_array.v2_exp diff --git a/Cargo.lock b/Cargo.lock index 6dada90d6c061..60ff109e9b00f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11127,6 +11127,7 @@ dependencies = [ "evm-exec-utils", "hex", "itertools 0.10.5", + "log", "move-abigen", "move-binary-format", "move-bytecode-source-map", diff --git a/aptos-move/framework/aptos-framework/doc/staking_config.md b/aptos-move/framework/aptos-framework/doc/staking_config.md index 0f89c9afc8de1..1dced05834f3d 100644 --- a/aptos-move/framework/aptos-framework/doc/staking_config.md +++ b/aptos-move/framework/aptos-framework/doc/staking_config.md @@ -1405,7 +1405,8 @@ Caller must be @aptos_framework. StakingRewardsConfig is under the @aptos_framework. -
include StakingRewardsConfigRequirement;
+
pragma verify_duration_estimate = 120;
+include StakingRewardsConfigRequirement;
 let addr = signer::address_of(aptos_framework);
 // This enforces high-level requirement 1:
 aborts_if addr != @aptos_framework;
diff --git a/aptos-move/framework/aptos-framework/sources/configs/staking_config.spec.move b/aptos-move/framework/aptos-framework/sources/configs/staking_config.spec.move
index 878da8fa9daa2..3cf9045c52457 100644
--- a/aptos-move/framework/aptos-framework/sources/configs/staking_config.spec.move
+++ b/aptos-move/framework/aptos-framework/sources/configs/staking_config.spec.move
@@ -237,6 +237,7 @@ spec aptos_framework::staking_config {
         rewards_rate_decrease_rate: FixedPoint64,
     ) {
         use std::signer;
+        pragma verify_duration_estimate = 120; // verified but takes long
         include StakingRewardsConfigRequirement;
         let addr = signer::address_of(aptos_framework);
         /// [high-level-req-1.6]
diff --git a/aptos-move/framework/aptos-stdlib/sources/data_structures/tests/smart_vector_test.move b/aptos-move/framework/aptos-stdlib/sources/data_structures/tests/smart_vector_test.move
index 40ce2c417e4e4..ed7cb50af35f6 100644
--- a/aptos-move/framework/aptos-stdlib/sources/data_structures/tests/smart_vector_test.move
+++ b/aptos-move/framework/aptos-stdlib/sources/data_structures/tests/smart_vector_test.move
@@ -103,6 +103,7 @@ module aptos_std::smart_vector_test {
         assert!(sum == 5050, 0);
     }
 
+    #[test]
     fun smart_vector_map_test() {
         let v = make_smart_vector(100);
         let mapped_v = V::map(v, |x| { x * 2 });
diff --git a/aptos-move/framework/move-stdlib/doc/features.md b/aptos-move/framework/move-stdlib/doc/features.md
index 88e231ad57113..86e55abc9cf5b 100644
--- a/aptos-move/framework/move-stdlib/doc/features.md
+++ b/aptos-move/framework/move-stdlib/doc/features.md
@@ -2882,6 +2882,9 @@ Helper to check whether a feature flag is enabled.
 
 
 
aborts_if signer::address_of(framework) != @std;
+pragma opaque;
+modifies global<Features>(@std);
+modifies global<PendingFeatures>(@std);
 
diff --git a/aptos-move/framework/move-stdlib/sources/configs/features.spec.move b/aptos-move/framework/move-stdlib/sources/configs/features.spec.move index 996091fe88508..1246a616d8489 100644 --- a/aptos-move/framework/move-stdlib/sources/configs/features.spec.move +++ b/aptos-move/framework/move-stdlib/sources/configs/features.spec.move @@ -33,6 +33,10 @@ spec std::features { spec change_feature_flags_for_next_epoch(framework: &signer, enable: vector, disable: vector) { aborts_if signer::address_of(framework) != @std; // TODO(tengzhang): add functional spec + // TODO(#12526): undo declaring opaque once fixed + pragma opaque; + modifies global(@std); + modifies global(@std); } spec fun spec_contains(features: vector, feature: u64): bool { diff --git a/aptos-move/framework/src/built_package.rs b/aptos-move/framework/src/built_package.rs index 5fbf1c7c00c52..c69610146b1f0 100644 --- a/aptos-move/framework/src/built_package.rs +++ b/aptos-move/framework/src/built_package.rs @@ -150,9 +150,11 @@ pub fn build_model( known_attributes, }, }; + let compiler_version = compiler_version.unwrap_or_default(); build_config.move_model_for_package(package_path, ModelConfig { target_filter, all_files_as_targets: false, + compiler_version, }) } diff --git a/aptos-move/framework/src/prover.rs b/aptos-move/framework/src/prover.rs index 5614c273b435b..20adcad9e6b5c 100644 --- a/aptos-move/framework/src/prover.rs +++ b/aptos-move/framework/src/prover.rs @@ -8,6 +8,7 @@ use codespan_reporting::{ }; use log::LevelFilter; use move_core_types::account_address::AccountAddress; +use move_package::CompilerVersion; use std::{ collections::{BTreeMap, BTreeSet}, path::Path, @@ -118,6 +119,7 @@ impl ProverOptions { package_path: &Path, named_addresses: BTreeMap, bytecode_version: Option, + compiler_version: Option, skip_attribute_checks: bool, known_attributes: &BTreeSet, ) -> anyhow::Result<()> { @@ -129,7 +131,7 @@ impl ProverOptions { named_addresses, self.filter.clone(), bytecode_version, - None, // compiler_version + compiler_version, skip_attribute_checks, known_attributes.clone(), )?; @@ -162,7 +164,11 @@ impl ProverOptions { )], }); let mut writer = StandardStream::stderr(ColorChoice::Auto); - move_prover::run_move_prover_with_model(&mut model, &mut writer, options, Some(now))?; + if compiler_version.unwrap_or_default() == CompilerVersion::V1 { + move_prover::run_move_prover_with_model(&mut model, &mut writer, options, Some(now))?; + } else { + move_prover::run_move_prover_with_model_v2(&mut model, &mut writer, options, now)?; + } Ok(()) } diff --git a/aptos-move/framework/tests/move_prover_tests.rs b/aptos-move/framework/tests/move_prover_tests.rs index 54947cb469e9a..defcf9e69b26c 100644 --- a/aptos-move/framework/tests/move_prover_tests.rs +++ b/aptos-move/framework/tests/move_prover_tests.rs @@ -58,6 +58,7 @@ pub fn run_prover_for_pkg(path_to_pkg: impl Into) { pkg_path.as_path(), BTreeMap::default(), None, + None, skip_attribute_checks, extended_checks::get_all_attribute_names(), ) diff --git a/crates/aptos/src/move_tool/mod.rs b/crates/aptos/src/move_tool/mod.rs index cde0fe0703b89..899d11cdf4f4e 100644 --- a/crates/aptos/src/move_tool/mod.rs +++ b/crates/aptos/src/move_tool/mod.rs @@ -556,6 +556,7 @@ impl CliCommand<&'static str> for ProvePackage { move_options.get_package_path()?.as_path(), move_options.named_addresses(), move_options.bytecode_version, + move_options.compiler_version, move_options.skip_attribute_checks, extended_checks::get_all_attribute_names(), ) diff --git a/third_party/move/evm/move-to-yul/src/functions.rs b/third_party/move/evm/move-to-yul/src/functions.rs index 7dd8776998bd1..1187a3cc652a6 100644 --- a/third_party/move/evm/move-to-yul/src/functions.rs +++ b/third_party/move/evm/move-to-yul/src/functions.rs @@ -576,7 +576,12 @@ impl<'a> FunctionGenerator<'a> { } }, - Label(_, _) | Nop(_) | SaveMem(_, _, _) | SaveSpecVar(_, _, _) | Prop(_, _, _) => { + SpecBlock(..) + | Label(_, _) + | Nop(_) + | SaveMem(_, _, _) + | SaveSpecVar(_, _, _) + | Prop(_, _, _) => { // These opcodes are not needed, ignore them }, } 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 fe6d26423dca3..b4034adf5d141 100644 --- a/third_party/move/move-compiler-v2/src/bytecode_generator.rs +++ b/third_party/move/move-compiler-v2/src/bytecode_generator.rs @@ -5,7 +5,8 @@ use codespan_reporting::diagnostic::Severity; use ethnum::U256; use move_model::{ - ast::{Exp, ExpData, Operation, Pattern, TempIndex, Value}, + ast::{Exp, ExpData, Operation, Pattern, SpecBlockTarget, TempIndex, Value}, + exp_rewriter::{ExpRewriter, ExpRewriterFunctions, RewriteTarget}, model::{ FieldId, FunId, FunctionEnv, GlobalEnv, Loc, NodeId, Parameter, QualifiedId, QualifiedInstId, StructId, @@ -451,13 +452,18 @@ impl<'env> Generator<'env> { self.error(*id, "missing enclosing loop statement") } }, - ExpData::SpecBlock(_, spec) => { - let (mut code, mut update_map) = self.context.generate_spec(&self.func_env, spec); - self.code.append(&mut code); - self.func_env - .get_mut_spec() - .update_map - .append(&mut update_map) + ExpData::SpecBlock(id, spec) => { + // Map locals in spec to assigned temporaries. + let mut replacer = |id, target| { + if let RewriteTarget::LocalVar(sym) = target { + Some(ExpData::Temporary(id, self.find_local(id, sym)).into_exp()) + } else { + None + } + }; + let (_, spec) = ExpRewriter::new(self.env(), &mut replacer) + .rewrite_spec_descent(&SpecBlockTarget::Inline, spec); + self.emit_with(*id, |attr| Bytecode::SpecBlock(attr, spec)); }, ExpData::Invoke(id, _, _) | ExpData::Lambda(id, _, _) => { self.internal_error(*id, format!("not yet implemented: {:?}", exp)) diff --git a/third_party/move/move-compiler-v2/src/file_format_generator/function_generator.rs b/third_party/move/move-compiler-v2/src/file_format_generator/function_generator.rs index 2bcf54fe92fd2..42132bc41096b 100644 --- a/third_party/move/move-compiler-v2/src/file_format_generator/function_generator.rs +++ b/third_party/move/move-compiler-v2/src/file_format_generator/function_generator.rs @@ -3,21 +3,25 @@ use crate::{ file_format_generator::{ - module_generator::{ModuleContext, ModuleGenerator}, + module_generator::{ModuleContext, ModuleGenerator, SOURCE_MAP_OK}, MAX_FUNCTION_DEF_COUNT, MAX_LOCAL_COUNT, }, pipeline::livevar_analysis_processor::LiveVarAnnotation, }; -use move_binary_format::file_format as FF; +use move_binary_format::{ + file_format as FF, + file_format::{CodeOffset, FunctionDefinitionIndex}, +}; use move_model::{ - ast::TempIndex, - model::{FunId, FunctionEnv, Loc, QualifiedId, StructId, TypeParameter}, + ast::{ExpData, Spec, SpecBlockTarget, TempIndex}, + exp_rewriter::{ExpRewriter, ExpRewriterFunctions, RewriteTarget}, + model::{FunId, FunctionEnv, Loc, NodeId, Parameter, QualifiedId, StructId, TypeParameter}, ty::{PrimitiveType, Type}, }; use move_stackless_bytecode::{ function_target::FunctionTarget, function_target_pipeline::FunctionVariant, - stackless_bytecode::{AssignKind, Bytecode, Constant, Label, Operation}, + stackless_bytecode::{AssignKind, AttrId, Bytecode, Constant, Label, Operation}, }; use std::collections::{BTreeMap, BTreeSet}; @@ -25,7 +29,7 @@ pub struct FunctionGenerator<'a> { /// The underlying module generator. gen: &'a mut ModuleGenerator, /// The set of temporaries which need to be pinned to locals because references are taken for - /// them. + /// them, or they are used in specs. pinned: BTreeSet, /// A map from a temporary to information associated with it. temps: BTreeMap, @@ -35,6 +39,8 @@ pub struct FunctionGenerator<'a> { locals: Vec, /// A map from branching labels to information about them. label_info: BTreeMap, + /// A mao from code offset to spec blocks associated with them + spec_blocks: BTreeMap, /// The generated code code: Vec, } @@ -51,6 +57,8 @@ pub struct FunctionContext<'env> { pub loc: Loc, /// Type parameters, cached here. type_parameters: Vec, + /// Function definition index. + def_idx: FunctionDefinitionIndex, } /// Immutable context for processing a bytecode instruction. @@ -58,6 +66,7 @@ pub struct FunctionContext<'env> { struct BytecodeContext<'env> { fun_ctx: &'env FunctionContext<'env>, code_offset: FF::CodeOffset, + attr_id: AttrId, } #[derive(Debug, Copy, Clone)] @@ -95,6 +104,25 @@ impl<'a> FunctionGenerator<'a> { let function = gen.function_index(ctx, &loc, &fun_env); let visibility = fun_env.visibility(); let fun_count = gen.module.function_defs.len(); + let def_idx = FunctionDefinitionIndex::new(ctx.checked_bound( + &loc, + fun_count, + MAX_FUNCTION_DEF_COUNT, + "defined function", + )); + gen.source_map + .add_top_level_function_mapping(def_idx, ctx.env.to_ir_loc(&loc), fun_env.is_native()) + .expect(SOURCE_MAP_OK); + for TypeParameter(name, _, loc) in fun_env.get_type_parameters() { + gen.source_map + .add_function_type_parameter_mapping(def_idx, ctx.source_name(name, loc)) + .expect(SOURCE_MAP_OK) + } + for Parameter(name, _, loc) in fun_env.get_parameters() { + gen.source_map + .add_parameter_mapping(def_idx, ctx.source_name(name, loc)) + .expect(SOURCE_MAP_OK) + } let (gen, code) = if !fun_env.is_native() { let mut fun_gen = Self { gen, @@ -103,16 +131,21 @@ impl<'a> FunctionGenerator<'a> { stack: vec![], locals: vec![], label_info: Default::default(), + spec_blocks: BTreeMap::new(), code: vec![], }; let target = ctx.targets.get_target(&fun_env, &FunctionVariant::Baseline); - let code = fun_gen.gen_code(&FunctionContext { module: ctx.clone(), fun: target, loc: loc.clone(), type_parameters: fun_env.get_type_parameters(), + def_idx, }); + // Write the spec block table back to the environment. + if !fun_gen.spec_blocks.is_empty() { + fun_env.get_mut_spec().on_impl = fun_gen.spec_blocks; + } (fun_gen.gen, Some(code)) } else { (gen, None) @@ -131,12 +164,7 @@ impl<'a> FunctionGenerator<'a> { acquires_global_resources, code, }; - ctx.checked_bound( - loc, - fun_count, // gen.module.function_defs.len(), - MAX_FUNCTION_DEF_COUNT, - "defined function", - ); + gen.module.function_defs.push(def) } @@ -145,7 +173,7 @@ impl<'a> FunctionGenerator<'a> { // Initialize the abstract virtual machine self.pinned = Self::pinned_temps(ctx); self.temps = (0..ctx.fun.get_parameter_count()) - .map(|temp| (temp, TempInfo::new(self.temp_to_local(ctx, temp)))) + .map(|temp| (temp, TempInfo::new(self.temp_to_local(ctx, None, temp)))) .collect(); self.locals = (0..ctx.fun.get_parameter_count()) .map(|temp| ctx.temp_type(temp).to_owned()) @@ -155,21 +183,22 @@ impl<'a> FunctionGenerator<'a> { let bytecode = ctx.fun.get_bytecode(); for i in 0..bytecode.len() { let code_offset = i as FF::CodeOffset; + let bc = &bytecode[i]; let bytecode_ctx = BytecodeContext { fun_ctx: ctx, code_offset, + attr_id: bc.get_attr_id(), }; if i + 1 < bytecode.len() { - let bc = &bytecode[i]; let next_bc = &bytecode[i + 1]; - self.gen_bytecode(&bytecode_ctx, &bytecode[i], Some(next_bc)); + self.gen_bytecode(&bytecode_ctx, bc, Some(next_bc)); if !bc.is_branching() && matches!(next_bc, Bytecode::Label(..)) { // At block boundaries without a preceding branch, need to flush stack // TODO: to avoid this, we should use the CFG for code generation. self.abstract_flush_stack_after(&bytecode_ctx, 0); } } else { - self.gen_bytecode(&bytecode_ctx, &bytecode[i], None) + self.gen_bytecode(&bytecode_ctx, bc, None) } } @@ -211,8 +240,22 @@ impl<'a> FunctionGenerator<'a> { fn pinned_temps(ctx: &FunctionContext) -> BTreeSet { let mut result = BTreeSet::new(); for bc in ctx.fun.get_bytecode() { - if let Bytecode::Call(_, _, Operation::BorrowLoc | Operation::Drop, args, _) = bc { - result.insert(args[0]); + match bc { + Bytecode::Call(_, _, Operation::BorrowLoc | Operation::Drop, args, _) => { + result.insert(args[0]); + }, + Bytecode::SpecBlock(_, spec) => { + // All Temporaries used in the spec need to be pinned. Notice that + // any bound variables inside the spec are LocalVar, so we can just + // unconditionally collect them. + let mut collect = |exp: &ExpData| { + if let ExpData::Temporary(_, temp) = exp { + result.insert(*temp); + } + }; + spec.visit_post_order(&mut collect) + }, + _ => {}, } } result @@ -221,10 +264,21 @@ impl<'a> FunctionGenerator<'a> { /// Generate file-format bytecode from a stackless bytecode and an optional next bytecode /// for peephole optimizations. fn gen_bytecode(&mut self, ctx: &BytecodeContext, bc: &Bytecode, next_bc: Option<&Bytecode>) { + self.gen + .source_map + .add_code_mapping( + ctx.fun_ctx.def_idx, + self.code.len() as FF::CodeOffset, + ctx.fun_ctx + .module + .env + .to_ir_loc(&ctx.fun_ctx.fun.get_bytecode_loc(ctx.attr_id)), + ) + .expect(SOURCE_MAP_OK); match bc { Bytecode::Assign(_, dest, source, mode) => { self.abstract_push_args(ctx, vec![*source], Some(mode)); - let local = self.temp_to_local(ctx.fun_ctx, *dest); + let local = self.temp_to_local(ctx.fun_ctx, Some(ctx.attr_id), *dest); self.emit(FF::Bytecode::StLoc(local)); self.abstract_pop(ctx) }, @@ -282,6 +336,7 @@ impl<'a> FunctionGenerator<'a> { Bytecode::Nop(_) => { // do nothing -- labels are relative }, + Bytecode::SpecBlock(_, spec) => self.gen_spec_block(ctx, spec), Bytecode::SaveMem(_, _, _) | Bytecode::Call(_, _, _, _, Some(_)) | Bytecode::SaveSpecVar(_, _, _) @@ -397,7 +452,7 @@ impl<'a> FunctionGenerator<'a> { ); }, Operation::BorrowLoc => { - let local = self.temp_to_local(fun_ctx, source[0]); + let local = self.temp_to_local(fun_ctx, Some(ctx.attr_id), source[0]); if fun_ctx.fun.get_local_type(dest[0]).is_mutable_reference() { self.emit(FF::Bytecode::MutBorrowLoc(local)) } else { @@ -679,6 +734,32 @@ impl<'a> FunctionGenerator<'a> { self.abstract_push_result(ctx, vec![*dest]); } + /// Generates code for an inline spec block. The spec block needs + /// to be rewritten s.t. free temporaries are replaced by the assigned + /// locals. The spec block is then stored in the spec block table + /// which will be written back to the function spec at the end of + /// translation. In the actual Move bytecode, a `Nop` is inserted + /// at the current code offset. + fn gen_spec_block(&mut self, ctx: &BytecodeContext, spec: &Spec) { + let mut replacer = |id: NodeId, target: RewriteTarget| { + if let RewriteTarget::Temporary(temp) = target { + Some( + ExpData::Temporary( + id, + self.temps.get(&temp).expect("temp has mapping").local as TempIndex, + ) + .into_exp(), + ) + } else { + None + } + }; + let (_, spec) = ExpRewriter::new(ctx.fun_ctx.module.env, &mut replacer) + .rewrite_spec_descent(&SpecBlockTarget::Inline, spec); + self.spec_blocks.insert(self.code.len() as CodeOffset, spec); + self.emit(FF::Bytecode::Nop) + } + /// Emits a file-format bytecode. fn emit(&mut self, bc: FF::Bytecode) { self.code.push(bc) @@ -714,7 +795,7 @@ impl<'a> FunctionGenerator<'a> { self.abstract_flush_stack_before(ctx, stack_to_flush); // Finally, push `temps_to_push` onto the stack. for (pos, temp) in temps_to_push.iter().enumerate() { - let local = self.temp_to_local(fun_ctx, *temp); + let local = self.temp_to_local(fun_ctx, Some(ctx.attr_id), *temp); match push_kind { Some(AssignKind::Move) => { self.emit(FF::Bytecode::MoveLoc(local)); @@ -786,7 +867,7 @@ impl<'a> FunctionGenerator<'a> { || self.pinned.contains(&temp) { // Only need to save to a local if the temp is still used afterwards - let local = self.temp_to_local(fun_ctx, temp); + let local = self.temp_to_local(fun_ctx, Some(ctx.attr_id), temp); self.emit(FF::Bytecode::StLoc(local)); } else { self.emit(FF::Bytecode::Pop) @@ -844,12 +925,34 @@ impl<'a> FunctionGenerator<'a> { } /// Allocates a local for the given temporary - fn temp_to_local(&mut self, ctx: &FunctionContext, temp: TempIndex) -> FF::LocalIndex { + fn temp_to_local( + &mut self, + ctx: &FunctionContext, + bc_attr_opt: Option, + temp: TempIndex, + ) -> FF::LocalIndex { if let Some(TempInfo { local }) = self.temps.get(&temp) { *local } else { let idx = self.new_local(ctx, ctx.temp_type(temp).to_owned()); self.temps.insert(temp, TempInfo::new(idx)); + + let loc = if let Some(id) = bc_attr_opt { + // Have a bytecode specific location for this local + ctx.fun.get_bytecode_loc(id) + } else if temp < ctx.fun.get_parameter_count() { + // Take location from parameter + ctx.fun.func_env.get_parameters()[temp].2.clone() + } else { + // Fall back to function identifier + ctx.fun.func_env.get_id_loc() + }; + let name = ctx.fun.get_local_name(temp); + self.gen + .source_map + .add_local_mapping(ctx.def_idx, ctx.module.source_name(name, loc)) + .expect(SOURCE_MAP_OK); + idx } } diff --git a/third_party/move/move-compiler-v2/src/file_format_generator/module_generator.rs b/third_party/move/move-compiler-v2/src/file_format_generator/module_generator.rs index 0b0c090443666..78d56f396b42a 100644 --- a/third_party/move/move-compiler-v2/src/file_format_generator/module_generator.rs +++ b/third_party/move/move-compiler-v2/src/file_format_generator/module_generator.rs @@ -8,12 +8,13 @@ use crate::file_format_generator::{ MAX_STRUCT_DEF_INST_COUNT, }; use codespan_reporting::diagnostic::Severity; +use itertools::Itertools; use move_binary_format::{ file_format as FF, - file_format::{FunctionHandle, ModuleHandle, TableIndex}, + file_format::{FunctionHandle, ModuleHandle, StructDefinitionIndex, TableIndex}, file_format_common, }; -use move_bytecode_source_map::source_map::SourceMap; +use move_bytecode_source_map::source_map::{SourceMap, SourceName}; use move_core_types::{account_address::AccountAddress, identifier::Identifier}; use move_ir_types::ast as IR_AST; use move_model::{ @@ -85,6 +86,10 @@ pub struct ModuleContext<'env> { pub targets: &'env FunctionTargetsHolder, } +/// Source map operations deliver Result but are really not expected to fail. +/// The below message is used if they do anyway. +pub(crate) const SOURCE_MAP_OK: &str = "expected valid source map"; + impl ModuleGenerator { /// Runs generation of `CompiledModule`. pub fn run( @@ -164,12 +169,32 @@ impl ModuleGenerator { return; } let loc = &struct_env.get_loc(); + let def_idx = StructDefinitionIndex::new(ctx.checked_bound( + loc, + self.module.struct_defs.len(), + MAX_STRUCT_DEF_COUNT, + "struct", + )); + self.source_map + .add_top_level_struct_mapping(def_idx, ctx.env.to_ir_loc(loc)) + .expect(SOURCE_MAP_OK); + for TypeParameter(name, _, loc) in struct_env.get_type_parameters() { + self.source_map + .add_struct_type_parameter_mapping(def_idx, ctx.source_name(name, loc)) + .expect(SOURCE_MAP_OK); + } let struct_handle = self.struct_index(ctx, loc, struct_env); + let fields = struct_env + .get_fields() + .sorted_by(|a, b| a.get_offset().cmp(&b.get_offset())); let field_information = FF::StructFieldInformation::Declared( - struct_env - .get_fields() + fields .map(|f| { - let name = self.name_index(ctx, loc, f.get_name()); + let field_loc = f.get_loc(); + self.source_map + .add_struct_field_mapping(def_idx, ctx.env.to_ir_loc(field_loc)) + .expect(SOURCE_MAP_OK); + let name = self.name_index(ctx, field_loc, f.get_name()); let signature = FF::TypeSignature(self.signature_token(ctx, loc, &f.get_type())); FF::FieldDefinition { name, signature } @@ -180,13 +205,7 @@ impl ModuleGenerator { struct_handle, field_information, }; - ctx.checked_bound( - loc, - self.module.struct_defs.len(), - MAX_STRUCT_DEF_COUNT, - "struct", - ); - self.module.struct_defs.push(def); + self.module.struct_defs.push(def) } /// Obtains or creates an index for a signature, a sequence of types. @@ -846,4 +865,12 @@ impl<'env> ModuleContext<'env> { } result } + + /// Converts to a name with location as expected by the SourceMap format. + pub(crate) fn source_name(&self, name: impl AsRef, loc: impl AsRef) -> SourceName { + ( + name.as_ref().display(self.env.symbol_pool()).to_string(), + self.env.to_ir_loc(loc.as_ref()), + ) + } } diff --git a/third_party/move/move-compiler-v2/src/lib.rs b/third_party/move/move-compiler-v2/src/lib.rs index 30cdf57f28abe..afd588d14c9e4 100644 --- a/third_party/move/move-compiler-v2/src/lib.rs +++ b/third_party/move/move-compiler-v2/src/lib.rs @@ -17,7 +17,9 @@ pub mod pipeline; pub mod recursive_struct_checker; use crate::{ - env_pipeline::{rewrite_target::RewritingScope, spec_checker, EnvProcessorPipeline}, + env_pipeline::{ + rewrite_target::RewritingScope, spec_checker, spec_rewriter, EnvProcessorPipeline, + }, pipeline::{ ability_processor::AbilityProcessor, dead_store_elimination::DeadStoreElimination, exit_state_analysis::ExitStateAnalysisProcessor, @@ -38,14 +40,19 @@ use move_command_line_common::files::FileHash; use move_compiler::{ compiled_unit::{ verify_units, AnnotatedCompiledModule, AnnotatedCompiledScript, AnnotatedCompiledUnit, - CompiledUnit, FunctionInfo, + CompiledUnit, FunctionInfo, NamedCompiledModule, NamedCompiledScript, }, diagnostics::FilesSourceText, shared::{known_attributes::KnownAttribute, unique_map::UniqueMap}, }; use move_disassembler::disassembler::Disassembler; use move_ir_types::location; -use move_model::{add_move_lang_diagnostics, model::GlobalEnv, PackageInfo}; +use move_model::{ + add_move_lang_diagnostics, + ast::{Address, ModuleName}, + model::GlobalEnv, + PackageInfo, +}; use move_stackless_bytecode::function_target_pipeline::{ FunctionTargetPipeline, FunctionTargetsHolder, FunctionVariant, }; @@ -61,7 +68,7 @@ pub fn run_move_compiler_to_stderr( run_move_compiler(&mut error_writer, options) } -/// Run move compiler and print errors to given writer. +/// Run move compiler and print errors to given writer. Returns the set of compiled units. pub fn run_move_compiler( error_writer: &mut W, options: Options, @@ -73,7 +80,7 @@ where info!("Move Compiler v2"); // Run context check. - let mut env = run_checker_and_rewriters(options.clone(), RewritingScope::CompilationTarget)?; + let mut env = run_checker_and_rewriters(options.clone())?; check_errors(&env, error_writer, "checking errors")?; // Run code generator @@ -118,9 +125,84 @@ where run_bytecode_verifier(&annotated_units, &mut env); check_errors(&env, error_writer, "bytecode verification errors")?; + // Finally mark this model to be generated by v2 + env.set_compiler_v2(true); + Ok((env, annotated_units)) } +/// Run move compiler and print errors to given writer for the purpose of analysis, like +/// e.g. the Move prover. After successful compilation attaches the generated bytecode +/// to the model. +pub fn run_move_compiler_for_analysis( + error_writer: &mut impl WriteColor, + mut options: Options, +) -> anyhow::Result { + options.whole_program = true; // will set `treat_everything_as_target` + let (mut env, units) = run_move_compiler(error_writer, options)?; + spec_rewriter::run_spec_rewriter(&mut env); + // Reset it for subsequent analysis + env.treat_everything_as_target(false); + // Script pseudo module names are sequentially constructed as `_1 .. _n`. To + // associate the bytecode module by name we need to count the index. This + // assumes script modules come out in the same order as they are were + // added to the environment. + let mut script_index = 0; // script names are named using a sequential index + for unit in units { + let unit = unit.into_compiled_unit(); + match unit { + CompiledUnit::Module(NamedCompiledModule { + package_name: _, + address, + name, + module, + source_map, + }) => { + let name = ModuleName::new( + Address::Numerical(address.into_inner()), + env.symbol_pool().make(name.as_str()), + ); + if let Some(id) = env.find_module(&name).map(|m| m.get_id()) { + env.attach_compiled_module(id, module, source_map) + } else { + env.error( + &env.unknown_loc(), + &format!( + "failed to attach bytecode: cannot find module `{}`", + name.display_full(&env) + ), + ); + } + }, + CompiledUnit::Script(NamedCompiledScript { + package_name: _, + name: _, + script, + source_map, + }) => { + let name = ModuleName::pseudo_script_name(env.symbol_pool(), script_index); + script_index += 1; + let module = move_model::script_into_module( + script, + &name.name().display(env.symbol_pool()).to_string(), + ); + if let Some(id) = env.find_module(&name).map(|m| m.get_id()) { + env.attach_compiled_module(id, module, source_map) + } else { + env.error( + &env.unknown_loc(), + &format!( + "failed to attach bytecode: cannot find script `{}`", + name.display_full(&env) + ), + ); + } + }, + } + } + Ok(env) +} + /// Run the type checker and return the global env (with errors if encountered). The result /// fails not on context checking errors, but possibly on i/o errors. pub fn run_checker(options: Options) -> anyhow::Result { @@ -157,10 +239,13 @@ pub fn run_checker(options: Options) -> anyhow::Result { /// Run the type checker as well as the AST rewriting pipeline and related additional /// checks, returning the global env (with errors if encountered). The result /// fails not on context checking errors, but possibly on i/o errors. -pub fn run_checker_and_rewriters( - options: Options, - scope: RewritingScope, -) -> anyhow::Result { +pub fn run_checker_and_rewriters(options: Options) -> anyhow::Result { + let whole_program = options.whole_program; + let scope = if whole_program { + RewritingScope::Everything + } else { + RewritingScope::CompilationTarget + }; let eliminate_code = options.experiment_on(Experiment::AST_AGGRESSIVE_OPTIMIZE); let mut env_pipeline = check_and_rewrite_pipeline(&options, false, scope); env_pipeline.add("simplifier", { @@ -168,6 +253,9 @@ pub fn run_checker_and_rewriters( }); let mut env = run_checker(options)?; if !env.has_errors() { + if whole_program { + env.treat_everything_as_target(true) + } env_pipeline.run(&mut env); } Ok(env) diff --git a/third_party/move/move-compiler-v2/src/options.rs b/third_party/move/move-compiler-v2/src/options.rs index b20b5c5ed170d..22d568683256c 100644 --- a/third_party/move/move-compiler-v2/src/options.rs +++ b/third_party/move/move-compiler-v2/src/options.rs @@ -59,6 +59,9 @@ pub struct Options { /// Note that the current value of this constant is "Wunused" #[clap(long = cli::WARN_UNUSED_FLAG, default_value="false")] pub warn_unused: bool, + /// Whether to compile everything, including dependencies. + #[clap(long)] + pub whole_program: bool, } impl Default for Options { diff --git a/third_party/move/move-compiler-v2/src/pipeline/reference_safety_processor.rs b/third_party/move/move-compiler-v2/src/pipeline/reference_safety_processor.rs index fd4d9b7de473a..12d9ed5e1de64 100644 --- a/third_party/move/move-compiler-v2/src/pipeline/reference_safety_processor.rs +++ b/third_party/move/move-compiler-v2/src/pipeline/reference_safety_processor.rs @@ -1014,7 +1014,7 @@ impl<'env, 'state> LifetimeAnalysisStep<'env, 'state> { fn check_borrow_safety(&mut self, temps_vec: &[TempIndex]) { // First check direct duplicates for (i, temp) in temps_vec.iter().enumerate() { - if temps_vec[i + 1..].contains(temp) { + if self.ty(*temp).is_mutable_reference() && temps_vec[i + 1..].contains(temp) { self.exclusive_access_direct_dup_error(*temp) } } diff --git a/third_party/move/move-compiler-v2/tests/ability-transform/mutate_return.exp b/third_party/move/move-compiler-v2/tests/ability-transform/mutate_return.exp index 6f2eea8516789..c92f139c8c001 100644 --- a/third_party/move/move-compiler-v2/tests/ability-transform/mutate_return.exp +++ b/third_party/move/move-compiler-v2/tests/ability-transform/mutate_return.exp @@ -1,11 +1,5 @@ ============ initial bytecode ================ -[variant baseline] -fun m::g<#0>($t0: &mut vector<#0>) { - 0: return () -} - - [variant baseline] public fun m::singleton<#0>($t0: #0): vector<#0> { var $t1: vector<#0> @@ -20,14 +14,13 @@ public fun m::singleton<#0>($t0: #0): vector<#0> { 5: return $t1 } -============ after LiveVarAnalysisProcessor: ================ [variant baseline] fun m::g<#0>($t0: &mut vector<#0>) { - # live vars: $t0 0: return () } +============ after LiveVarAnalysisProcessor: ================ [variant baseline] public fun m::singleton<#0>($t0: #0): vector<#0> { @@ -49,18 +42,14 @@ public fun m::singleton<#0>($t0: #0): vector<#0> { 5: return $t1 } -============ after ReferenceSafetyProcessor: ================ [variant baseline] fun m::g<#0>($t0: &mut vector<#0>) { # live vars: $t0 - # graph: {@1000000=external[borrow(true) -> @2000000],@2000000=derived[]} - # locals: {$t0=@2000000} - # globals: {} - # 0: return () } +============ after ReferenceSafetyProcessor: ================ [variant baseline] public fun m::singleton<#0>($t0: #0): vector<#0> { @@ -106,11 +95,9 @@ public fun m::singleton<#0>($t0: #0): vector<#0> { 5: return $t1 } -============ after AbortAnalysisProcessor: ================ [variant baseline] fun m::g<#0>($t0: &mut vector<#0>) { - # abort state: {returns} # live vars: $t0 # graph: {@1000000=external[borrow(true) -> @2000000],@2000000=derived[]} # locals: {$t0=@2000000} @@ -119,6 +106,7 @@ fun m::g<#0>($t0: &mut vector<#0>) { 0: return () } +============ after AbortAnalysisProcessor: ================ [variant baseline] public fun m::singleton<#0>($t0: #0): vector<#0> { @@ -170,14 +158,19 @@ public fun m::singleton<#0>($t0: #0): vector<#0> { 5: return $t1 } -============ after AbilityProcessor: ================ [variant baseline] fun m::g<#0>($t0: &mut vector<#0>) { - 0: drop($t0) - 1: return () + # abort state: {returns} + # live vars: $t0 + # graph: {@1000000=external[borrow(true) -> @2000000],@2000000=derived[]} + # locals: {$t0=@2000000} + # globals: {} + # + 0: return () } +============ after AbilityProcessor: ================ [variant baseline] public fun m::singleton<#0>($t0: #0): vector<#0> { @@ -192,3 +185,10 @@ public fun m::singleton<#0>($t0: #0): vector<#0> { 4: $t1 := move($t2) 5: return $t1 } + + +[variant baseline] +fun m::g<#0>($t0: &mut vector<#0>) { + 0: drop($t0) + 1: return () +} 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 33831b169b809..f07b7cfb5f43d 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 @@ -8,7 +8,7 @@ module 0x42::assign { g: assign::T, } private fun assign_field(s: &mut assign::S,f: u64) { - select assign::S.f(s) = f; + select assign::S.f<&mut assign::S>(s) = f; Tuple() } private fun assign_int(x: &mut u64) { 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 c45361d5ae379..21abae1b65fc1 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 @@ -19,7 +19,7 @@ module 0x42::borrow { } private fun field(s: &borrow::S): u64 { { - let r: &u64 = Borrow(Immutable)(select borrow::S.f(s)); + let r: &u64 = Borrow(Immutable)(select borrow::S.f<&borrow::S>(s)); Deref(r) } } @@ -37,7 +37,7 @@ module 0x42::borrow { } private fun mut_field(s: &mut borrow::S): u64 { { - let r: &mut u64 = Borrow(Mutable)(select borrow::S.f(s)); + let r: &mut u64 = Borrow(Mutable)(select borrow::S.f<&mut borrow::S>(s)); r = 22; Deref(r) } diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/borrow_invalid.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/borrow_invalid.exp index 6df26e844a8d2..fe5e732300cb2 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/borrow_invalid.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/borrow_invalid.exp @@ -1,7 +1,55 @@ +// -- Model dump before bytecode pipeline +module 0x42::borrow { + struct S { + f: u64, + } + private fun mut_expr(x: u64): u64 { + { + let r: &mut u64 = Borrow(Mutable)(Add(x, 1)); + r = 22; + Deref(r) + } + } + private fun mut_field(s: &borrow::S): u64 { + { + let r: &mut u64 = Borrow(Mutable)(select borrow::S.f<&borrow::S>(s)); + r = 22; + Deref(r) + } + } +} // end 0x42::borrow -Diagnostics: -error: cannot mutably borrow from an immutable ref - ┌─ tests/bytecode-generator/borrow_invalid.move:8:17 - │ -8 │ let r = &mut s.f; - │ ^^^^^^^^ +============ initial bytecode ================ + +[variant baseline] +fun borrow::mut_expr($t0: u64): u64 { + var $t1: u64 + var $t2: &mut u64 + var $t3: &mut u64 + var $t4: u64 + var $t5: u64 + var $t6: u64 + 0: $t5 := 1 + 1: $t4 := +($t0, $t5) + 2: $t3 := borrow_local($t4) + 3: $t2 := infer($t3) + 4: $t6 := 22 + 5: write_ref($t2, $t6) + 6: $t1 := read_ref($t2) + 7: return $t1 +} + + +[variant baseline] +fun borrow::mut_field($t0: &borrow::S): u64 { + var $t1: u64 + var $t2: &mut u64 + var $t3: &mut u64 + var $t4: u64 + 0: $t3 := borrow_field.f($t0) + 1: $t2 := infer($t3) + 2: $t4 := 22 + 3: write_ref($t2, $t4) + 4: $t1 := read_ref($t2) + 5: return $t1 +} 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 62441e8bbf890..c1abeacda9e7c 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 @@ -51,35 +51,35 @@ module 0x8675::M { { let x: M::S = pack M::S(3); { - let tref: &mut M::S = Borrow(Mutable)(if Lt(select M::S.f(r), 4) { + let tref: &mut M::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 tref2: &mut M::S = Borrow(Mutable)(y); - select M::S.f(Deref(tref2)) = Add(select M::S.f(Deref(tref2)), 1); + select M::S.f(Deref(tref2)) = Add(select M::S.f(Deref(tref2)), 1); { let z: M::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 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) } } } 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 1e33c882718ce..db29c430c5711 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 @@ -11,15 +11,15 @@ module 0x42::m { } private fun owner_correct(o: m::Object): address { { - let addr: address = select m::Object.inner(o); - select m::ObjectCore.owner(BorrowGlobal(Immutable)(addr)) + let addr: address = select m::Object.inner(o); + select m::ObjectCore.owner<&m::ObjectCore>(BorrowGlobal(Immutable)(addr)) } } private fun owner_read_ref_missing(o: m::Object): address { - select m::ObjectCore.owner(BorrowGlobal(Immutable)(select m::Object.inner(o))) + select m::ObjectCore.owner<&m::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 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 1a9cc9ce2d1cd..7b8f609ac7dbf 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 @@ -11,21 +11,21 @@ module 0x42::fields { g: fields::T, } private fun read_generic_val(x: fields::G): u64 { - select fields::G.f(x) + select fields::G.f>(x) } private fun read_ref(x: &fields::S): u64 { - select fields::T.h(select fields::S.g(x)) + select fields::T.h(select fields::S.g<&fields::S>(x)) } private fun read_val(x: fields::S): u64 { - select fields::T.h(select fields::S.g(x)) + select fields::T.h(select fields::S.g(x)) } private fun write_generic_val(x: &mut fields::G,v: u64) { - select fields::G.f(x) = v + select fields::G.f<&mut fields::G>(x) = v } private fun write_local_direct(): fields::S { { let x: fields::S = pack fields::S(0, pack fields::T(0)); - select fields::T.h(select fields::S.g(x)) = 42; + select fields::T.h(select fields::S.g(x)) = 42; x } } @@ -34,7 +34,7 @@ module 0x42::fields { let x: fields::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(r)) = 42; + select fields::T.h(select fields::S.g<&mut fields::S>(r)) = 42; x } } @@ -43,18 +43,18 @@ module 0x42::fields { { let x: fields::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(x)) = 42; + select fields::T.h(select fields::S.g<&mut fields::S>(x)) = 42; Tuple() } private fun write_val(x: fields::S): fields::S { - select fields::T.h(select fields::S.g(x)) = 42; + select fields::T.h(select fields::S.g(x)) = 42; x } } // end 0x42::fields 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 00da148628c9b..b8cd6367f2bae 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 @@ -8,7 +8,7 @@ module 0x42::fields { g: fields::T, } private fun write_ref(x: &fields::S) { - select fields::T.h(select fields::S.g(x)) = 42; + select fields::T.h(select fields::S.g<&fields::S>(x)) = 42; Tuple() } } // end 0x42::fields 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 0b554e4d24adc..81e82a0d5ea2f 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 @@ -30,10 +30,16 @@ fun inline_specs::specs(): u64 { var $t3: u64 0: $t2 := 0 1: $t1 := infer($t2) - 2: assert Eq(x, 0) + 2: spec { + assert Eq($t1, 0); +} + 3: $t3 := inline_specs::succ($t1) 4: $t1 := infer($t3) - 5: assert Eq(x, 1) + 5: spec { + assert Eq($t1, 1); +} + 6: $t0 := infer($t1) 7: return $t0 } 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 d37ff8d8d63e6..5a9371125a768 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 @@ -8,7 +8,7 @@ module 0x42::m { data: vector, } public fun foo(v: &m::S): u8 { - select m::E.k(vector::borrow(Borrow(Immutable)(select m::S.data(v)), 0)) + select m::E.k<&m::E>(vector::borrow(Borrow(Immutable)(select m::S.data<&m::S>(v)), 0)) } } // end 0x42::m diff --git a/third_party/move/move-compiler-v2/tests/bytecode-verify-failure/equality.exp b/third_party/move/move-compiler-v2/tests/bytecode-verify-failure/equality.exp index c6971722dbe49..3eadb90097892 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-verify-failure/equality.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-verify-failure/equality.exp @@ -14,14 +14,10 @@ B0: } Diagnostics: bug: BYTECODE VERIFICATION FAILED - ┌─ tests/bytecode-verify-failure/equality.move:1:1 + ┌─ tests/bytecode-verify-failure/equality.move:3:9 │ -1 │ ╭ module 0xc0ffee::m { -2 │ │ fun equality(x: T, y: T): bool { -3 │ │ x == y -4 │ │ } -5 │ │ } - │ ╰─^ ICE failed bytecode verifier: VMError { +3 │ x == y + │ ^^^^^^ ICE failed bytecode verifier: VMError { major_status: EQUALITY_OP_TYPE_MISMATCH_ERROR, sub_status: None, message: None, diff --git a/third_party/move/move-compiler-v2/tests/checking/inlining/acquires_error_msg.exp b/third_party/move/move-compiler-v2/tests/checking/inlining/acquires_error_msg.exp index 786d57ffbecfa..9fb427a5b80aa 100644 --- a/third_party/move/move-compiler-v2/tests/checking/inlining/acquires_error_msg.exp +++ b/third_party/move/move-compiler-v2/tests/checking/inlining/acquires_error_msg.exp @@ -10,7 +10,7 @@ module 0x42::test { public fun modify() acquires test::Test(*) { - select test::Test.value(BorrowGlobal(Mutable)(0xcafe)) = 2; + select test::Test.value<&mut test::Test>(BorrowGlobal(Mutable)(0xcafe)) = 2; Tuple() } } // end 0x42::test diff --git a/third_party/move/move-compiler-v2/tests/checking/inlining/resources_invalid.exp b/third_party/move/move-compiler-v2/tests/checking/inlining/resources_invalid.exp index 04f56c7eafca5..ad8acc2e74859 100644 --- a/third_party/move/move-compiler-v2/tests/checking/inlining/resources_invalid.exp +++ b/third_party/move/move-compiler-v2/tests/checking/inlining/resources_invalid.exp @@ -10,9 +10,9 @@ module 0x42::token { val: u64, } public fun get_value(ref: &objects::ReaderRef): u64 { - select token::Token.val({ + select token::Token.val<&token::Token>({ let (ref: &objects::ReaderRef): (&objects::ReaderRef) = Tuple(ref); - BorrowGlobal(Immutable)(select objects::ReaderRef.addr(ref)) + BorrowGlobal(Immutable)(select objects::ReaderRef.addr<&objects::ReaderRef>(ref)) }) } } // end 0x42::token 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 98da5547cd5b5..5b6e3342d18d0 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 @@ -6,7 +6,7 @@ module 0x42::m { { let r: bool = { let (a: address): (address) = Tuple(x); - Lt(select m::S.f({ + Lt(select m::S.f({ let (a: address): (address) = Tuple(a); global(a) }), 10) 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 afb27295027cf..6b81d226f4150 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 @@ -17,9 +17,9 @@ module 0x42::M { 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>; - private native fun remove(t: &mut M::MyTable2<#0, #1>,k: #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; 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 276639dfd1275..adfbe05e60cbc 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 @@ -4,7 +4,7 @@ module 0x42::M { s: M::S, } spec { - invariant M::less10(true, select M::S.x(select M::R.s())); + invariant M::less10(true, select M::S.x(select M::R.s())); } struct S { 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 dd83317856e3d..f6a3025c7b239 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 @@ -7,10 +7,10 @@ module 0x42::move_function_in_spec { { let type_info: move_function_in_spec::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(move_function_in_spec::$type_of<#0>())); } ; Tuple() @@ -22,7 +22,7 @@ module 0x42::move_function_in_spec { { { let ty: &move_function_in_spec::TypeInfo = BorrowGlobal(Immutable)(target); - Eq
(select move_function_in_spec::TypeInfo.account_address(ty), new_addr) + Eq
(select move_function_in_spec::TypeInfo.account_address<&move_function_in_spec::TypeInfo>(ty), new_addr) } } public fun type_of(): move_function_in_spec::TypeInfo { @@ -31,7 +31,7 @@ module 0x42::move_function_in_spec { 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) + Eq
(select move_function_in_spec::TypeInfo.account_address(ty), new_addr) } } spec fun $type_of(): move_function_in_spec::TypeInfo { 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 0308460927aaa..bef42715930d6 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 @@ -4,9 +4,9 @@ module 0x42::M { x: u64, } spec fun exists_in_vector(v: vector): bool { - exists s: M::S: v: Gt(select M::S.x(s), 0) + exists s: M::S: v: Gt(select M::S.x(s), 0) } spec fun some_in_vector(v: vector): M::S { - choose s: M::S: v: Eq(select M::S.x(s), 0) + choose s: M::S: v: Eq(select M::S.x(s), 0) } } // end 0x42::M diff --git a/third_party/move/move-compiler-v2/tests/checking/specs/schemas_err.exp b/third_party/move/move-compiler-v2/tests/checking/specs/schemas_err.exp index cfa80157a326e..b5c18ae48a499 100644 --- a/third_party/move/move-compiler-v2/tests/checking/specs/schemas_err.exp +++ b/third_party/move/move-compiler-v2/tests/checking/specs/schemas_err.exp @@ -6,48 +6,115 @@ error: undeclared `x` 4 │ ensures x > 0; │ ^ +note: unused schema M::UndeclaredVar + ┌─ tests/checking/specs/schemas_err.move:3:5 + │ +3 │ ╭ spec schema UndeclaredVar { +4 │ │ ensures x > 0; +5 │ │ } + │ ╰─────^ + error: schema `M::Undeclared` undeclared ┌─ tests/checking/specs/schemas_err.move:8:17 │ 8 │ include Undeclared; │ ^^^^^^^^^^ +note: unused schema M::UndeclaredSchema + ┌─ tests/checking/specs/schemas_err.move:7:5 + │ +7 │ ╭ spec schema UndeclaredSchema { +8 │ │ include Undeclared; +9 │ │ } + │ ╰─────^ + error: wrong number of type arguments (expected 1, got 2) ┌─ tests/checking/specs/schemas_err.move:12:17 │ 12 │ include WrongTypeArgsIncluded; │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: unused schema M::WrongTypeArgs + ┌─ tests/checking/specs/schemas_err.move:11:5 + │ +11 │ ╭ spec schema WrongTypeArgs { +12 │ │ include WrongTypeArgsIncluded; +13 │ │ } + │ ╰─────^ + error: `wrong` not declared in schema ┌─ tests/checking/specs/schemas_err.move:19:44 │ 19 │ include WrongTypeArgsIncluded{wrong: 1}; │ ^^^^^ +note: unused schema M::WrongRenaming + ┌─ tests/checking/specs/schemas_err.move:18:5 + │ +18 │ ╭ spec schema WrongRenaming { +19 │ │ include WrongTypeArgsIncluded{wrong: 1}; +20 │ │ } + │ ╰─────^ + error: expected `num` but found a value of type `bool` ┌─ tests/checking/specs/schemas_err.move:24:47 │ 24 │ include WrongTypeArgsIncluded{x: y}; │ ^ +note: unused schema M::WrongTypeAfterRenaming + ┌─ tests/checking/specs/schemas_err.move:22:5 + │ +22 │ ╭ spec schema WrongTypeAfterRenaming { +23 │ │ y: bool; +24 │ │ include WrongTypeArgsIncluded{x: y}; +25 │ │ } + │ ╰─────^ + error: expected `bool` but found a value of type `num` ┌─ tests/checking/specs/schemas_err.move:28:48 │ 28 │ include WrongTypeArgsIncluded{x: 1 + 2}; │ ^^^^^ +note: unused schema M::WrongTypeAfterRenamingExp + ┌─ tests/checking/specs/schemas_err.move:27:5 + │ +27 │ ╭ spec schema WrongTypeAfterRenamingExp { +28 │ │ include WrongTypeArgsIncluded{x: 1 + 2}; +29 │ │ } + │ ╰─────^ + error: variable `x` bound by schema inclusion expected to have type `bool` but provided was `num` ┌─ tests/checking/specs/schemas_err.move:33:17 │ 33 │ include WronglyTypedVarIncluded; │ ^^^^^^^^^^^^^^^^^^^^^^^ +note: unused schema M::WronglyTypedVar + ┌─ tests/checking/specs/schemas_err.move:31:5 + │ +31 │ ╭ spec schema WronglyTypedVar { +32 │ │ x: bool; +33 │ │ include WronglyTypedVarIncluded; +34 │ │ } + │ ╰─────^ + error: variable `x` bound by schema inclusion expected to have type `bool` but provided was `num` ┌─ tests/checking/specs/schemas_err.move:41:17 │ 41 │ include WronglyTypedInstantiationIncluded; │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: unused schema M::WronglyTypedInstantiation + ┌─ tests/checking/specs/schemas_err.move:39:5 + │ +39 │ ╭ spec schema WronglyTypedInstantiation { +40 │ │ x: bool; +41 │ │ include WronglyTypedInstantiationIncluded; +42 │ │ } + │ ╰─────^ + error: `y` cannot be matched to an existing name in inclusion context ┌─ tests/checking/specs/schemas_err.move:52:17 │ @@ -83,3 +150,13 @@ error: expression construct not supported for schemas │ 86 │ include Condition || Condition; │ ^^^^^^^^^^^^^^^^^^^^^^ + +note: unused schema M::SchemaExp + ┌─ tests/checking/specs/schemas_err.move:83:5 + │ +83 │ ╭ spec schema SchemaExp { +84 │ │ include 22 ==> Condition; +85 │ │ include true ==> 23; +86 │ │ include Condition || Condition; +87 │ │ } + │ ╰─────^ 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 074391a1a469d..3ef30afac08f9 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 @@ -1,3 +1,55 @@ + +Diagnostics: +note: unused schema M::IncreasesStrictly + ┌─ tests/checking/specs/schemas_ok.move:10:5 + │ +10 │ ╭ spec schema IncreasesStrictly { +11 │ │ include Increases; +12 │ │ ensures result > x; +13 │ │ } + │ ╰─────^ + +note: unused schema M::IncreasesWithTwoResults + ┌─ tests/checking/specs/schemas_ok.move:15:5 + │ +15 │ ╭ spec schema IncreasesWithTwoResults { +16 │ │ result_1: num; +17 │ │ result_2: num; +18 │ │ include Increases{result: result_1}; +19 │ │ ensures result_2 > result_1; +20 │ │ } + │ ╰─────^ + +note: unused schema M::IsEqualConcrete + ┌─ tests/checking/specs/schemas_ok.move:28:5 + │ +28 │ ╭ spec schema IsEqualConcrete { +29 │ │ z: num; +30 │ │ include IsEqual{x: z}; +31 │ │ ensures z <= y; +32 │ │ } + │ ╰─────^ + +note: unused schema M::GenericIncludesGeneric + ┌─ tests/checking/specs/schemas_ok.move:53:5 + │ +53 │ ╭ spec schema GenericIncludesGeneric { +54 │ │ include InvariantIsEqual; +55 │ │ } + │ ╰─────^ + +note: unused schema M::SchemaExp + ┌─ tests/checking/specs/schemas_ok.move:67:5 + │ +67 │ ╭ spec schema SchemaExp { +68 │ │ x: bool; +69 │ │ include x ==> InvariantIsEqual; +70 │ │ include !x ==> InvariantIsEqual; +71 │ │ include InvariantIsEqual && InvariantIsEqual; +72 │ │ include if (x) InvariantIsEqual else InvariantIsEqual; +73 │ │ } + │ ╰─────^ + // -- Model dump before bytecode pipeline module 0x42::M { struct S { 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 1cd90f24203b8..591fc4fd388df 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 @@ -16,13 +16,13 @@ module 0x42::M { z: vector, } public fun f(r: M::R): M::T { - pack M::T(select M::S.x(select M::R.s(r))) + 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) + select M::S.x(s) } spec fun nested_struct_access(r: M::R): bool { - select M::S.y(select M::R.s(r)) + select M::S.y(select M::R.s(r)) } spec fun struct_pack(x: u64,y: bool,z: vector): M::S { pack M::S(x, y, z) 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 9ac5e2b67ce7d..c88b2555a9bc3 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 @@ -5,7 +5,7 @@ module 0x42::update_field_ok { y: u64, } private fun f(r: &mut update_field_ok::R) { - select update_field_ok::R.x(r) = 1; + select update_field_ok::R.x<&mut update_field_ok::R>(r) = 1; Tuple() } spec { 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 560e23ec63ac8..9e087eb9543ed 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 @@ -13,8 +13,8 @@ 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: _ }: M::R = r; Tuple() 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 543d37df14725..32ca4b79ac6ea 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 @@ -9,7 +9,7 @@ module 0x8675309::M { 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: _ }: M::R = 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 71c2416e6c98c..2790687e71d0d 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 @@ -13,8 +13,8 @@ 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: _ }: M::R = r; Tuple() 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 8f66b1c8d0fea..dbf054f66724d 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 @@ -13,8 +13,8 @@ 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: _ }: M::R = r; Tuple() 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 a1b45684f38d7..ae44a168cf687 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 @@ -13,8 +13,8 @@ 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: _ }: M::R = r; Tuple() 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 f630f7b9f1efc..7d908dce88634 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 @@ -13,8 +13,8 @@ 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: _ }: M::R = r; Tuple() 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 46805bd4a7680..d20902dce81f9 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 @@ -13,8 +13,8 @@ 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: _ }: M::R = r; Tuple() 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 64c12af920785..a638674bf270d 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 @@ -13,8 +13,8 @@ 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: _ }: M::R = r; Tuple() 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 5c026e724bfe5..2b114f9cb3ebb 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 @@ -13,8 +13,8 @@ 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: _ }: M::R = r; Tuple() 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 22932659c4c62..250074d80f316 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 @@ -13,8 +13,8 @@ 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: _ }: M::R = r; Tuple() 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 7f94287c27364..433d904698cde 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 @@ -13,8 +13,8 @@ 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: _ }: M::R = r; Tuple() 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 55885283b3a8f..454508a1be28d 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 @@ -9,7 +9,7 @@ module 0x8675309::M { 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: _ }: M::R = 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 8269bc78a32cf..5b13887916dc0 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 @@ -13,8 +13,8 @@ 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: _ }: M::R = r } } // end 0x8675309::M 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 a6be9c9ad1bc9..0de2faf0e9406 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 @@ -13,8 +13,8 @@ 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: _ }: M::R = r } } // end 0x8675309::M 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 7d5c5d56c48db..8389a80b3c605 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 @@ -13,8 +13,8 @@ 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: _ }: M::R = r; Tuple() 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 e22e7ab1cb884..254f493239fbf 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 @@ -13,8 +13,8 @@ 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: _ }: M::R = r; Tuple() 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 7c47ac2ae0367..aa470df8dbe0c 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 @@ -4,6 +4,6 @@ module 0x8675309::M { 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(s)), Borrow(Immutable)(select M::S.f(s_mut)), Borrow(Mutable)(select M::S.f(s_mut2))) + 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))) } } // end 0x8675309::M 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 3c302dc7a8381..94a934431a457 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 @@ -10,15 +10,15 @@ module 0x8675309::M { f: u64, } private fun t0(x1: &M::X1,x1_mut: &mut M::X1) { - Borrow(Immutable)(select M::X1.x2(x1)); - Borrow(Immutable)(select M::X2.x3(select M::X1.x2(x1))); - Borrow(Immutable)(select M::X3.f(select M::X2.x3(select M::X1.x2(x1)))); - Borrow(Immutable)(select M::X1.x2(x1_mut)); - Borrow(Immutable)(select M::X2.x3(select M::X1.x2(x1_mut))); - Borrow(Immutable)(select M::X3.f(select M::X2.x3(select M::X1.x2(x1_mut)))); - Borrow(Mutable)(select M::X1.x2(x1_mut)); - Borrow(Mutable)(select M::X2.x3(select M::X1.x2(x1_mut))); - Borrow(Mutable)(select M::X3.f(select M::X2.x3(select M::X1.x2(x1_mut)))); + 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)))); Tuple() } } // end 0x8675309::M 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 218cb1bd72df0..f0056537c4f69 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 @@ -4,32 +4,32 @@ module 0x8675309::M { f: u64, } private fun t0(cond: bool,s: &M::S,s_mut: &mut M::S) { - Borrow(Immutable)(select M::S.f(if cond { + Borrow(Immutable)(select M::S.f<&M::S>(if cond { s } else { s })); - Borrow(Immutable)(select M::S.f(if cond { + Borrow(Immutable)(select M::S.f<&M::S>(if cond { s_mut } else { s })); - Borrow(Immutable)(select M::S.f(if cond { + Borrow(Immutable)(select M::S.f<&M::S>(if cond { s } else { s_mut })); - Borrow(Immutable)(select M::S.f(if cond { + Borrow(Immutable)(select M::S.f<&mut M::S>(if cond { s_mut } else { s_mut })); - Borrow(Mutable)(select M::S.f(if cond { + Borrow(Mutable)(select M::S.f<&mut M::S>(if cond { s_mut } else { s_mut })); - Borrow(Immutable)(select M::S.f({ + Borrow(Immutable)(select M::S.f<&M::S>({ let s: M::S = pack M::S(0); Borrow(Immutable)(s) })); diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/borrow_field_internal.exp b/third_party/move/move-compiler-v2/tests/checking/typing/borrow_field_internal.exp index 4df8a3de37629..7cf7ab7d87c3a 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/borrow_field_internal.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/borrow_field_internal.exp @@ -10,10 +10,10 @@ module 0x2::X { module 0x2::M { use 0x2::X; // resolved as: 0x2::X private fun t0() { - Borrow(Immutable)(select X::S.f(X::s())); + Borrow(Immutable)(select X::S.f(X::s())); { let s: &X::S = Borrow(Immutable)(X::s()); - Borrow(Immutable)(select X::S.f(s)); + Borrow(Immutable)(select X::S.f<&X::S>(s)); Abort(0) } } 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 4c6f111bc8d45..0a38afe6bcae3 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 @@ -4,14 +4,14 @@ module 0x8675309::M { 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 { + 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) 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 dc3e30ffad76f..bf84fdebe47b4 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 @@ -11,15 +11,15 @@ module 0x8675309::M { Deref(x); Deref(x_mut); Deref(s); - Deref(Borrow(Immutable)(select M::S.f(s))); - select M::S.f(s); - Deref(Borrow(Immutable)(select M::S.x(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(s_mut); - Deref(Borrow(Immutable)(select M::S.f(s_mut))); - Deref(Borrow(Mutable)(select M::S.f(s_mut))); - select M::S.f(s_mut); - Deref(Borrow(Immutable)(select M::S.x(s_mut))); - Deref(Borrow(Mutable)(select M::S.x(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))); Tuple() } } // end 0x8675309::M diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/derefrence_reference.exp b/third_party/move/move-compiler-v2/tests/checking/typing/derefrence_reference.exp index e0ceb030cd10d..08e7e8e5752fb 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/derefrence_reference.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/derefrence_reference.exp @@ -9,14 +9,14 @@ module 0x8675309::M { private fun t0(r: &M::R,b: &M::B) { M::R{ dummy_field: _ }: M::R = Deref(r); M::B{ r: M::R{ dummy_field: _ } }: M::B = Deref(b); - M::R{ dummy_field: _ }: M::R = Deref(Borrow(Immutable)(select M::B.r(b))); + M::R{ dummy_field: _ }: M::R = Deref(Borrow(Immutable)(select M::B.r<&M::B>(b))); Tuple() } private fun t1(r: &mut M::R,b: &mut M::B) { M::R{ dummy_field: _ }: M::R = Deref(r); M::B{ r: M::R{ dummy_field: _ } }: M::B = Deref(b); - M::R{ dummy_field: _ }: M::R = Deref(Borrow(Immutable)(select M::B.r(b))); - M::R{ dummy_field: _ }: M::R = Deref(Borrow(Mutable)(select M::B.r(b))); + M::R{ dummy_field: _ }: M::R = Deref(Borrow(Immutable)(select M::B.r<&mut M::B>(b))); + M::R{ dummy_field: _ }: M::R = Deref(Borrow(Mutable)(select M::B.r<&mut M::B>(b))); Tuple() } } // end 0x8675309::M 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 093708d3ebf02..091162a89bff2 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 @@ -4,6 +4,6 @@ module 0x8675309::M { f: u64, } private fun t0(s: &M::S,s_mut: &mut M::S): (u64, u64) { - Tuple(select M::S.f(s), select M::S.f(s_mut)) + Tuple(select M::S.f<&M::S>(s), select M::S.f<&mut M::S>(s_mut)) } } // end 0x8675309::M 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 997680d55682e..a295429bd20ef 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 @@ -10,10 +10,10 @@ module 0x8675309::M { 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(x1))); - select M::X3.f(select M::X2.x3(select M::X1.x2(x1_mut))); - select M::X3.f(select M::X2.x3(x2)); - select M::X3.f(select M::X2.x3(x2_mut)); + 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)); Tuple() } } // end 0x8675309::M 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 a147b6c595b52..5a48b21574477 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 @@ -4,27 +4,27 @@ module 0x8675309::M { f: u64, } private fun t0(cond: bool,s: &M::S,s_mut: &mut M::S) { - select M::S.f(if cond { + select M::S.f<&M::S>(if cond { s } else { s }); - select M::S.f(if cond { + select M::S.f<&M::S>(if cond { s_mut } else { s }); - select M::S.f(if cond { + select M::S.f<&M::S>(if cond { s } else { s_mut }); - select M::S.f(if cond { + select M::S.f<&mut M::S>(if cond { s_mut } else { s_mut }); - select M::S.f({ + select M::S.f<&M::S>({ let s: M::S = pack M::S(0); Borrow(Immutable)(s) }); diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/implicit_deref_borrow_field_internal.exp b/third_party/move/move-compiler-v2/tests/checking/typing/implicit_deref_borrow_field_internal.exp index b4233e2508643..5a9034982e31b 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/implicit_deref_borrow_field_internal.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/implicit_deref_borrow_field_internal.exp @@ -10,10 +10,10 @@ module 0x2::X { module 0x2::M { use 0x2::X; // resolved as: 0x2::X private fun t0() { - select X::S.f(X::s()); + select X::S.f(X::s()); { let s: &X::S = Borrow(Immutable)(X::s()); - select X::S.f(s); + select X::S.f<&X::S>(s); Abort(0) } } 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 52450acd4c3d5..71ba5235e8226 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 @@ -10,14 +10,14 @@ module 0x8675309::M { Abort(0) } private fun t0(cond: bool,_s: M::S) { - select M::S.f(M::foo()); - select M::S.f(M::bar()); - select M::S.f(if cond { + select M::S.f<&M::S>(M::foo()); + select M::S.f(M::bar()); + select M::S.f<&M::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() 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 7f7277f58a41e..32221dc6ce4a4 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 @@ -4,8 +4,8 @@ module 0x8675309::M { f: u64, } private fun t0(cond: bool,s: M::S) { - select M::S.f(s); - select M::S.f(if cond { + select M::S.f(s); + select M::S.f(if cond { pack M::S(0) } else { pack M::S(1) 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 fa05b02099235..2231412618dc8 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 @@ -20,26 +20,26 @@ module 0x8675309::M { Neq(Freeze(r1), Freeze(r2)); Neq(Freeze(r2), Freeze(r2)); Neq(Freeze(r2), Freeze(r2)); - Eq(Freeze(Borrow(Mutable)(select M::S.f(s))), Freeze(Borrow(Mutable)(select M::S.f(s)))); - Eq(Freeze(Borrow(Mutable)(select M::S.f(s))), Freeze(Borrow(Mutable)(select M::S.g(s)))); - Eq(Freeze(Borrow(Mutable)(select M::S.g(s))), Freeze(Borrow(Mutable)(select M::S.f(s)))); - Eq(Freeze(Borrow(Mutable)(select M::S.g(s))), Freeze(Borrow(Mutable)(select M::S.g(s)))); - Neq(Freeze(Borrow(Mutable)(select M::S.f(s))), Freeze(Borrow(Mutable)(select M::S.f(s)))); - Neq(Freeze(Borrow(Mutable)(select M::S.f(s))), Freeze(Borrow(Mutable)(select M::S.g(s)))); - Neq(Freeze(Borrow(Mutable)(select M::S.g(s))), Freeze(Borrow(Mutable)(select M::S.f(s)))); - Neq(Freeze(Borrow(Mutable)(select M::S.g(s))), Freeze(Borrow(Mutable)(select M::S.g(s)))); + Eq(Freeze(Borrow(Mutable)(select M::S.f<&mut M::S>(s))), Freeze(Borrow(Mutable)(select M::S.f<&mut M::S>(s)))); + Eq(Freeze(Borrow(Mutable)(select M::S.f<&mut M::S>(s))), Freeze(Borrow(Mutable)(select M::S.g<&mut M::S>(s)))); + Eq(Freeze(Borrow(Mutable)(select M::S.g<&mut M::S>(s))), Freeze(Borrow(Mutable)(select M::S.f<&mut M::S>(s)))); + Eq(Freeze(Borrow(Mutable)(select M::S.g<&mut M::S>(s))), Freeze(Borrow(Mutable)(select M::S.g<&mut M::S>(s)))); + Neq(Freeze(Borrow(Mutable)(select M::S.f<&mut M::S>(s))), Freeze(Borrow(Mutable)(select M::S.f<&mut M::S>(s)))); + Neq(Freeze(Borrow(Mutable)(select M::S.f<&mut M::S>(s))), Freeze(Borrow(Mutable)(select M::S.g<&mut M::S>(s)))); + Neq(Freeze(Borrow(Mutable)(select M::S.g<&mut M::S>(s))), Freeze(Borrow(Mutable)(select M::S.f<&mut M::S>(s)))); + Neq(Freeze(Borrow(Mutable)(select M::S.g<&mut M::S>(s))), Freeze(Borrow(Mutable)(select M::S.g<&mut M::S>(s)))); Tuple() } private fun t1(p: &mut M::P) { { - let comp: bool = Eq(Freeze(Borrow(Mutable)(select M::P.b1(p))), Freeze(Borrow(Mutable)(select M::P.b2(p)))); - select M::B.f(select M::P.b1(p)) = comp + let comp: bool = Eq(Freeze(Borrow(Mutable)(select M::P.b1<&mut M::P>(p))), Freeze(Borrow(Mutable)(select M::P.b2<&mut M::P>(p)))); + select M::B.f(select M::P.b1<&mut M::P>(p)) = comp } } private fun t2(p: &mut M::P) { { - let comp: bool = Neq(Freeze(Borrow(Mutable)(select M::P.b1(p))), Freeze(Borrow(Mutable)(select M::P.b2(p)))); - select M::B.f(select M::P.b1(p)) = comp + let comp: bool = Neq(Freeze(Borrow(Mutable)(select M::P.b1<&mut M::P>(p))), Freeze(Borrow(Mutable)(select M::P.b2<&mut M::P>(p)))); + select M::B.f(select M::P.b1<&mut M::P>(p)) = comp } } } // end 0x8675309::M 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 54038d4b21d70..f293fbeeac9c4 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 @@ -14,20 +14,20 @@ 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(M::bar(Borrow(Mutable)(pack M::S(0)))) = 1; - Borrow(Mutable)(select M::S.f(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 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; Tuple() } private fun t1() { { let r: &mut M::S = Borrow(Mutable)(pack M::S(0)); r = pack M::S(1); - select M::S.f(r) = 1; - Borrow(Mutable)(select M::S.f(r)) = 1; + select M::S.f<&mut M::S>(r) = 1; + Borrow(Mutable)(select M::S.f<&mut M::S>(r)) = 1; Tuple() } } diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/mutate_field_internal.exp b/third_party/move/move-compiler-v2/tests/checking/typing/mutate_field_internal.exp index f9d183712c210..49ad3d6aef41a 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/mutate_field_internal.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/mutate_field_internal.exp @@ -10,10 +10,10 @@ module 0x2::X { module 0x2::M { use 0x2::X; // resolved as: 0x2::X private fun t0() { - select X::S.f(X::s()) = 0; + select X::S.f(X::s()) = 0; { let s: &mut X::S = Borrow(Mutable)(X::s()); - select X::S.f(s) = 0; + select X::S.f<&mut X::S>(s) = 0; Abort(0) } } 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 57638fc0f6cd1..d82dc536aca59 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 @@ -20,20 +20,20 @@ module 0x42::simple_map { }; { let idx: u64 = option::extract(Borrow(Mutable)(maybe_idx)); - Borrow(Immutable)(select simple_map::Element.value(vector::borrow>(Borrow(Immutable)(select simple_map::SimpleMap.data(map)), 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))) } } } private fun find(map: &simple_map::SimpleMap<#0, #1>,key: �): option::Option { { - let leng: u64 = vector::length>(Borrow(Immutable)(select simple_map::SimpleMap.data(map))); + let leng: u64 = vector::length>(Borrow(Immutable)(select simple_map::SimpleMap.data<&simple_map::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(map)), i); - if Eq(Borrow(Immutable)(select simple_map::Element.key(element)), key) { + 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) { return option::some(i) } else { Tuple() 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 00574c36072b0..25bc49cbbf818 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 @@ -9,7 +9,7 @@ module 0x8675309::M { Not(x); Not(Copy(x)); Not(Move(x)); - Not(select M::R.f(r)); + Not(select M::R.f(r)); { let M::R{ f: _ }: M::R = r; Tuple() diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/with_spec.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/with_spec.exp index 7468ea8d787c5..aa71821145a82 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/with_spec.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/with_spec.exp @@ -11,7 +11,8 @@ struct S { bar() /* def_idx: 0 */ { B0: - 0: Ret + 0: Nop + 1: Ret } public foo(Arg0: &S): u8 /* def_idx: 1 */ { B0: diff --git a/third_party/move/move-compiler-v2/tests/lambda-lifting/modify.exp b/third_party/move/move-compiler-v2/tests/lambda-lifting/modify.exp index b3fe694d0cb5f..9b00da4dfeba8 100644 --- a/third_party/move/move-compiler-v2/tests/lambda-lifting/modify.exp +++ b/third_party/move/move-compiler-v2/tests/lambda-lifting/modify.exp @@ -3,6 +3,9 @@ module 0xcafe::m { struct S { x: u64, } + private fun map(x: u64,f: |u64|u64): u64 { + (f)(x) + } private fun assigns_local(x: u64,c: u64): u64 { { let z: u64 = 1; @@ -38,9 +41,6 @@ module 0xcafe::m { }) } } - private fun map(x: u64,f: |u64|u64): u64 { - (f)(x) - } } // end 0xcafe::m 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 580551a3a0f29..e7eba52ec1c8d 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 @@ -55,8 +55,8 @@ module 0x8675309::M { } private fun t0(x: u64,r: 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: _ }: M::R = r; Tuple() 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 2a849205ade5c..8dd2d677df781 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 @@ -51,35 +51,35 @@ module 0x8675::M { { let x: M::S = pack M::S(3); { - let tref: &mut M::S = Borrow(Mutable)(if Lt(select M::S.f(r), 4) { + let tref: &mut M::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 tref2: &mut M::S = Borrow(Mutable)(y); - select M::S.f(Deref(tref2)) = Add(select M::S.f(Deref(tref2)), 1); + select M::S.f(Deref(tref2)) = Add(select M::S.f(Deref(tref2)), 1); { let z: M::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 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) } } } 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 a3cc781bc1513..be28749367bf5 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 @@ -14,7 +14,7 @@ module 0x8675309::M { let x: u64 = 0; { let f: &mut u64 = x: u64 = Add(x, 1); - Borrow(Mutable)(select M::S.f(x: u64 = Add(x, 1); + Borrow(Mutable)(select M::S.f<&mut M::S>(x: u64 = Add(x, 1); 1; s)); if true { @@ -35,7 +35,7 @@ module 0x8675309::M { } } private fun t1(s: &mut M::S) { - M::bar(Borrow(Mutable)(select M::S.f(s)), select M::S.f(s) = 0; + M::bar(Borrow(Mutable)(select M::S.f<&mut M::S>(s)), select M::S.f<&mut M::S>(s) = 0; 1) } } // end 0x8675309::M diff --git a/third_party/move/move-compiler-v2/transactional-tests/tests/no-v1-comparison/access_control/dynamic.exp b/third_party/move/move-compiler-v2/transactional-tests/tests/no-v1-comparison/access_control/dynamic.exp index 8a5b7fe7e127d..45fc0b41c318d 100644 --- a/third_party/move/move-compiler-v2/transactional-tests/tests/no-v1-comparison/access_control/dynamic.exp +++ b/third_party/move/move-compiler-v2/transactional-tests/tests/no-v1-comparison/access_control/dynamic.exp @@ -13,7 +13,7 @@ Error: Function execution failed with VMError: { sub_status: None, location: 0x42::test, indices: [], - offsets: [(FunctionDefinitionIndex(0), 1)], + offsets: [(FunctionDefinitionIndex(1), 1)], exec_state: Some(ExecutionState { stack_trace: [] }), } @@ -24,6 +24,6 @@ Error: Function execution failed with VMError: { sub_status: None, location: 0x42::test, indices: [], - offsets: [(FunctionDefinitionIndex(1), 3)], + offsets: [(FunctionDefinitionIndex(2), 3)], exec_state: Some(ExecutionState { stack_trace: [] }), } diff --git a/third_party/move/move-compiler-v2/transactional-tests/tests/no-v1-comparison/access_control/generic.exp b/third_party/move/move-compiler-v2/transactional-tests/tests/no-v1-comparison/access_control/generic.exp index a0f1c4c20301a..041671d6c1dfc 100644 --- a/third_party/move/move-compiler-v2/transactional-tests/tests/no-v1-comparison/access_control/generic.exp +++ b/third_party/move/move-compiler-v2/transactional-tests/tests/no-v1-comparison/access_control/generic.exp @@ -13,6 +13,6 @@ Error: Function execution failed with VMError: { sub_status: None, location: 0x42::test, indices: [], - offsets: [(FunctionDefinitionIndex(0), 1)], + offsets: [(FunctionDefinitionIndex(1), 1)], exec_state: Some(ExecutionState { stack_trace: [] }), } diff --git a/third_party/move/move-compiler-v2/transactional-tests/tests/no-v1-comparison/access_control/negation.exp b/third_party/move/move-compiler-v2/transactional-tests/tests/no-v1-comparison/access_control/negation.exp index 3ea63bb986779..83fdf74d58abe 100644 --- a/third_party/move/move-compiler-v2/transactional-tests/tests/no-v1-comparison/access_control/negation.exp +++ b/third_party/move/move-compiler-v2/transactional-tests/tests/no-v1-comparison/access_control/negation.exp @@ -13,7 +13,7 @@ Error: Function execution failed with VMError: { sub_status: None, location: 0x42::test, indices: [], - offsets: [(FunctionDefinitionIndex(0), 1)], + offsets: [(FunctionDefinitionIndex(1), 1)], exec_state: Some(ExecutionState { stack_trace: [] }), } @@ -24,6 +24,6 @@ Error: Function execution failed with VMError: { sub_status: None, location: 0x42::test, indices: [], - offsets: [(FunctionDefinitionIndex(1), 1)], + offsets: [(FunctionDefinitionIndex(2), 1)], exec_state: Some(ExecutionState { stack_trace: [] }), } diff --git a/third_party/move/move-compiler-v2/transactional-tests/tests/no-v1-comparison/access_control/resource.exp b/third_party/move/move-compiler-v2/transactional-tests/tests/no-v1-comparison/access_control/resource.exp index 23d095a57a076..ab23755203d71 100644 --- a/third_party/move/move-compiler-v2/transactional-tests/tests/no-v1-comparison/access_control/resource.exp +++ b/third_party/move/move-compiler-v2/transactional-tests/tests/no-v1-comparison/access_control/resource.exp @@ -22,7 +22,7 @@ Error: Function execution failed with VMError: { sub_status: None, location: 0x42::test, indices: [], - offsets: [(FunctionDefinitionIndex(0), 1)], + offsets: [(FunctionDefinitionIndex(1), 1)], exec_state: Some(ExecutionState { stack_trace: [] }), } @@ -33,7 +33,7 @@ Error: Function execution failed with VMError: { sub_status: None, location: 0x42::test, indices: [], - offsets: [(FunctionDefinitionIndex(1), 1)], + offsets: [(FunctionDefinitionIndex(2), 1)], exec_state: Some(ExecutionState { stack_trace: [] }), } @@ -44,7 +44,7 @@ Error: Function execution failed with VMError: { sub_status: None, location: 0x42::test, indices: [], - offsets: [(FunctionDefinitionIndex(2), 1)], + offsets: [(FunctionDefinitionIndex(3), 1)], exec_state: Some(ExecutionState { stack_trace: [] }), } @@ -55,7 +55,7 @@ Error: Function execution failed with VMError: { sub_status: None, location: 0x42::test, indices: [], - offsets: [(FunctionDefinitionIndex(3), 2)], + offsets: [(FunctionDefinitionIndex(4), 2)], exec_state: Some(ExecutionState { stack_trace: [] }), } diff --git a/third_party/move/move-compiler-v2/transactional-tests/tests/no-v1-comparison/access_control/wildcard.exp b/third_party/move/move-compiler-v2/transactional-tests/tests/no-v1-comparison/access_control/wildcard.exp index 67dda0b118903..aafc7de64f5ef 100644 --- a/third_party/move/move-compiler-v2/transactional-tests/tests/no-v1-comparison/access_control/wildcard.exp +++ b/third_party/move/move-compiler-v2/transactional-tests/tests/no-v1-comparison/access_control/wildcard.exp @@ -19,7 +19,7 @@ Error: Function execution failed with VMError: { sub_status: None, location: 0x42::test, indices: [], - offsets: [(FunctionDefinitionIndex(0), 1)], + offsets: [(FunctionDefinitionIndex(1), 1)], exec_state: Some(ExecutionState { stack_trace: [] }), } @@ -30,6 +30,6 @@ Error: Function execution failed with VMError: { sub_status: None, location: 0x42::test, indices: [], - offsets: [(FunctionDefinitionIndex(1), 1)], + offsets: [(FunctionDefinitionIndex(2), 1)], exec_state: Some(ExecutionState { stack_trace: [] }), } diff --git a/third_party/move/move-model/bytecode/src/borrow_analysis.rs b/third_party/move/move-model/bytecode/src/borrow_analysis.rs index bb44eea1fe26f..9a61cea49ca27 100644 --- a/third_party/move/move-model/bytecode/src/borrow_analysis.rs +++ b/third_party/move/move-model/bytecode/src/borrow_analysis.rs @@ -571,13 +571,14 @@ impl<'a> BorrowAnalysis<'a> { let state_map = self.analyze_function(state, instrs, &cfg); // Summarize the result - let code_map = self.state_per_instruction(state_map, instrs, &cfg, |before, after| { - let mut before = before.clone(); - let mut after = after.clone(); - before.consolidate(); - after.consolidate(); - BorrowInfoAtCodeOffset { before, after } - }); + let code_map = + self.state_per_instruction_with_default(state_map, instrs, &cfg, |before, after| { + let mut before = before.clone(); + let mut after = after.clone(); + before.consolidate(); + after.consolidate(); + BorrowInfoAtCodeOffset { before, after } + }); let mut summary = BorrowInfo::default(); for (offs, code) in instrs.iter().enumerate() { if let Bytecode::Ret(_, temps) = code { @@ -620,15 +621,17 @@ impl<'a> TransferFunctions for BorrowAnalysis<'a> { let src_node = self.borrow_node(*src); match kind { AssignKind::Move | AssignKind::Inferred => { - assert!(!self.func_target.get_local_type(*src).is_reference()); - assert!(!self.func_target.get_local_type(*dest).is_reference()); - state.del_node(&src_node); - }, - AssignKind::Copy => { - assert!(!self.func_target.get_local_type(*src).is_reference()); - assert!(!self.func_target.get_local_type(*dest).is_reference()); + if self.func_target.get_local_type(*src).is_mutable_reference() { + assert!(self + .func_target + .get_local_type(*dest) + .is_mutable_reference()); + state.add_edge(src_node, dest_node, BorrowEdge::Direct); + } else { + state.del_node(&src_node) + } }, - AssignKind::Store => { + AssignKind::Copy | AssignKind::Store => { if self.func_target.get_local_type(*src).is_mutable_reference() { assert!(self .func_target diff --git a/third_party/move/move-model/bytecode/src/stackless_bytecode.rs b/third_party/move/move-model/bytecode/src/stackless_bytecode.rs index 35c4add089bc2..da05660714ec7 100644 --- a/third_party/move/move-model/bytecode/src/stackless_bytecode.rs +++ b/third_party/move/move-model/bytecode/src/stackless_bytecode.rs @@ -9,7 +9,7 @@ use move_binary_format::file_format::CodeOffset; use move_core_types::{u256, value::MoveValue}; use move_model::{ ast, - ast::{Address, Exp, ExpData, MemoryLabel, TempIndex, TraceKind}, + ast::{Address, Exp, ExpData, MemoryLabel, Spec, TempIndex, TraceKind}, exp_rewriter::{ExpRewriter, ExpRewriterFunctions, RewriteTarget}, model::{FunId, GlobalEnv, ModuleId, NodeId, QualifiedInstId, SpecVarId, StructId}, ty::{Type, TypeDisplayContext}, @@ -417,8 +417,9 @@ pub enum Bytecode { Label(AttrId, Label), Abort(AttrId, TempIndex), Nop(AttrId), + SpecBlock(AttrId, Spec), - // Extended bytecode: spec-only. + // Extended bytecode: spec-instrumentation only. SaveMem(AttrId, MemoryLabel, QualifiedInstId), SaveSpecVar(AttrId, MemoryLabel, QualifiedInstId), Prop(AttrId, PropKind, Exp), @@ -437,6 +438,7 @@ impl Bytecode { | Label(id, ..) | Abort(id, ..) | Nop(id) + | SpecBlock(id, ..) | SaveMem(id, ..) | SaveSpecVar(id, ..) | Prop(id, ..) => *id, @@ -455,6 +457,7 @@ impl Bytecode { | Label(id, ..) | Abort(id, ..) | Nop(id) + | SpecBlock(id, ..) | SaveMem(id, ..) | SaveSpecVar(id, ..) | Prop(id, ..) => id, @@ -519,6 +522,10 @@ impl Bytecode { | Bytecode::Nop(_) => { vec![] }, + Bytecode::SpecBlock(_, _) => { + // Specifications are not contributing to read variables + vec![] + }, // Note that for all spec-only instructions, we currently return no sources. Bytecode::SaveMem(_, _, _) | Bytecode::SaveSpecVar(_, _, _) @@ -552,6 +559,7 @@ impl Bytecode { | Bytecode::Nop(_) | Bytecode::SaveMem(_, _, _) | Bytecode::SaveSpecVar(_, _, _) + | Bytecode::SpecBlock(..) | Bytecode::Prop(_, _, _) => Vec::new(), } } @@ -969,6 +977,9 @@ impl<'env> fmt::Display for BytecodeDisplay<'env> { Nop(_) => { write!(f, "nop")?; }, + SpecBlock(_, spec) => { + write!(f, "{}", self.func_target.global_env().display(spec))?; + }, SaveMem(_, label, qid) => { let env = self.func_target.global_env(); write!(f, "@{} := save_mem({})", label.as_usize(), env.display(qid))?; diff --git a/third_party/move/move-model/bytecode/src/stackless_bytecode_generator.rs b/third_party/move/move-model/bytecode/src/stackless_bytecode_generator.rs index 298e1dde35f1f..2706ec5d855be 100644 --- a/third_party/move/move-model/bytecode/src/stackless_bytecode_generator.rs +++ b/third_party/move/move-model/bytecode/src/stackless_bytecode_generator.rs @@ -240,7 +240,12 @@ impl<'a> StacklessBytecodeGenerator<'a> { )); global_env .find_module(&vec_module) - .expect("unexpected reference to module not found in global env") + .unwrap_or_else(|| { + panic!( + "unexpected reference to module: `{}` not found in global env", + vec_module.display_full(global_env) + ) + }) .get_id() }); diff --git a/third_party/move/move-model/src/ast.rs b/third_party/move/move-model/src/ast.rs index c5cbf02d93e2a..ed3e495e12dc0 100644 --- a/third_party/move/move-model/src/ast.rs +++ b/third_party/move/move-model/src/ast.rs @@ -353,6 +353,25 @@ impl Spec { } result } + + pub fn visit_positions(&self, visitor: &mut F) + where + F: FnMut(VisitorPosition, &ExpData) -> Option<()>, + { + let _ = ExpData::visit_positions_spec_impl(self, visitor); + } + + pub fn visit_post_order(&self, visitor: &mut F) + where + F: FnMut(&ExpData), + { + self.visit_positions(&mut |pos, exp| { + if matches!(pos, VisitorPosition::Post) { + visitor(exp); + } + Some(()) + }); + } } /// Information about a specification block in the source. This is used for documentation @@ -1193,6 +1212,9 @@ impl ExpData { for cond in spec.update_map.values() { Self::visit_positions_cond_impl(cond, visitor)?; } + for update in spec.update_map.values() { + Self::visit_positions_cond_impl(update, visitor)?; + } Some(()) } diff --git a/third_party/move/move-model/src/builder/exp_builder.rs b/third_party/move/move-model/src/builder/exp_builder.rs index 6d4f2a9c34d1b..a3365b53fa770 100644 --- a/third_party/move/move-model/src/builder/exp_builder.rs +++ b/third_party/move/move-model/src/builder/exp_builder.rs @@ -2561,6 +2561,7 @@ impl<'env, 'translator, 'module_translator> ExpTranslator<'env, 'translator, 'mo self.fresh_type_var_constr(loc.clone(), WideningOrder::RightToLeft, constraint); let exp = self.translate_dotted(e.as_ref(), &ty, &ErrorMessageContext::General); let id = self.new_node_id_with_type_loc(expected_type, &loc); + self.set_node_instantiation(id, vec![ty.clone()]); let oper = if let Type::Struct(mid, sid, _inst) = self.subs.specialize(&ty) { // Struct known at this point Operation::Select(mid, sid, FieldId::new(field_name)) diff --git a/third_party/move/move-model/src/exp_rewriter.rs b/third_party/move/move-model/src/exp_rewriter.rs index 9c7c5c417dc8e..616a24b3bdc46 100644 --- a/third_party/move/move-model/src/exp_rewriter.rs +++ b/third_party/move/move-model/src/exp_rewriter.rs @@ -14,7 +14,6 @@ use crate::{ use codespan_reporting::diagnostic::Severity; use itertools::Itertools; use log::trace; -use move_binary_format::file_format::CodeOffset; use std::collections::{BTreeMap, BTreeSet}; /// Rewriter for expressions, allowing to substitute locals by expressions as well as instantiate @@ -261,10 +260,6 @@ pub trait ExpRewriterFunctions { ) -> Option { None } - // Might only be useful with V1-compiled code - fn rewrite_offset_spec(&mut self, offset: CodeOffset, spec: &Spec) -> Option { - None - } // Core traversal functions, not intended to be re-implemented // ----------------------------------------------------------- @@ -604,69 +599,6 @@ pub trait ExpRewriterFunctions { } } - fn internal_rewrite_spec_conditions( - &mut self, - conditions: Vec, - ) -> (bool, Vec) { - let (tests, rewritten_conds): (Vec, Vec) = conditions - .into_iter() - .map(|cond| self.internal_rewrite_spec_condition(cond)) - .unzip(); - let summary_bool = tests.into_iter().any(|x| x); - (summary_bool, rewritten_conds) - } - - // Might only be used with v1 compile chain. - fn internal_rewrite_spec_on_impl( - &mut self, - mut on_impl: BTreeMap, - ) -> (bool, BTreeMap) { - let mut changed = false; - for (key, value) in on_impl.iter_mut() { - let old_value = std::mem::take(value); - let (changed_value, new_spec) = self.internal_rewrite_offset_spec(*key, old_value); - *value = new_spec; - changed = changed || changed_value; - } - (changed, on_impl) - } - - fn rewrite_spec_update_map( - &mut self, - mut update_map: BTreeMap, - ) -> (bool, BTreeMap) { - let (changed_vec, new_map): (Vec, BTreeMap) = update_map - .into_iter() - .map(|(id, cond)| { - let (changed, new_cond) = self.internal_rewrite_spec_condition(cond); - (changed, (id, new_cond)) - }) - .unzip(); - let changed = changed_vec.into_iter().any(|x| x); - (changed, new_map) - } - - fn internal_rewrite_offset_spec(&mut self, offset: CodeOffset, spec: Spec) -> (bool, Spec) { - let (conditions_changed, new_conditions) = - self.internal_rewrite_spec_conditions(spec.conditions); - let (on_impl_changed, new_on_impl) = self.internal_rewrite_spec_on_impl(spec.on_impl); - let (update_map_changed, new_update_map) = self.rewrite_spec_update_map(spec.update_map); - let newspec = Spec { - conditions: new_conditions, - on_impl: new_on_impl, - update_map: new_update_map, - ..spec - }; - if let Some(newer_spec) = self.rewrite_offset_spec(offset, &newspec) { - (true, newer_spec) - } else { - ( - conditions_changed || on_impl_changed || update_map_changed, - newspec, - ) - } - } - fn rewrite_spec_descent(&mut self, target: &SpecBlockTarget, spec: &Spec) -> (bool, Spec) { let mut changed = false; let mut conditions = vec![]; diff --git a/third_party/move/move-model/src/lib.rs b/third_party/move/move-model/src/lib.rs index 4f81c5285cdbc..3d6bbc00e8f3d 100644 --- a/third_party/move/move-model/src/lib.rs +++ b/third_party/move/move-model/src/lib.rs @@ -275,7 +275,12 @@ pub fn run_model_builder_with_options_and_compilation_flags< let mut expansion_ast = { let E::Program { modules, scripts } = expansion_ast; let modules = modules.filter_map(|mident, mut mdef| { - visited_modules.contains(&mident.value).then(|| { + // Always need to include the vector module because it can be implicitly used. + // TODO(#12492): we can remove this once this bug is fixed + let is_vector = mident.value.address.into_addr_bytes().into_inner() + == AccountAddress::ONE + && mident.value.module.0.value.as_str() == "vector"; + (is_vector || visited_modules.contains(&mident.value)).then(|| { mdef.is_source_module = true; mdef }) @@ -386,6 +391,13 @@ fn run_move_checker(env: &mut GlobalEnv, program: E::Program) { let module_def = expansion_script_to_module(script_def); module_translator.translate(loc, module_def, None); } + + // Populate GlobalEnv with model-level information + builder.populate_env(); + + // After all specs have been processed, warn about any unused schemas. + builder.warn_unused_schemas(); + // Perform any remaining friend-declaration checks and update friend module id information. check_and_update_friend_info(builder); } @@ -511,7 +523,7 @@ pub fn add_move_lang_diagnostics(env: &mut GlobalEnv, diags: Diagnostics) { } #[allow(deprecated)] -fn script_into_module(compiled_script: CompiledScript) -> CompiledModule { +pub fn script_into_module(compiled_script: CompiledScript, name: &str) -> CompiledModule { let mut script = compiled_script; // Add the "" identifier if it isn't present. @@ -521,14 +533,14 @@ fn script_into_module(compiled_script: CompiledScript) -> CompiledModule { let self_ident_idx = match script .identifiers .iter() - .position(|ident| ident.as_ident_str() == self_module_name()) + .position(|ident| ident.as_ident_str().as_str() == name) { Some(idx) => IdentifierIndex::new(idx as u16), None => { let idx = IdentifierIndex::new(script.identifiers.len() as u16); script .identifiers - .push(Identifier::new(self_module_name().to_string()).unwrap()); + .push(Identifier::new(name.to_string()).unwrap()); idx }, }; @@ -689,7 +701,7 @@ fn run_spec_checker(env: &mut GlobalEnv, units: Vec, mut .unwrap(); let expanded_module = expansion_script_to_module(expanded_script); - let module = script_into_module(script.script); + let module = script_into_module(script.script, self_module_name().as_str()); modules.push(( ident, expanded_module, diff --git a/third_party/move/move-model/src/model.rs b/third_party/move/move-model/src/model.rs index 3a4fcbeb238f0..a7c41d9b89f71 100644 --- a/third_party/move/move-model/src/model.rs +++ b/third_party/move/move-model/src/model.rs @@ -563,6 +563,12 @@ pub struct GlobalEnv { pub(crate) extlib_address: Option
, /// Address alias map pub(crate) address_alias_map: BTreeMap, + /// A flag which allows to indicate that the whole program including + /// dependencies should be built. + pub(crate) everything_is_target: RefCell, + /// Whether the v2 compiler has generated this model. + /// TODO: replace with a proper version number once we have this in file format + pub(crate) generated_by_v2: bool, } /// A helper type for implementing fmt::Display depending on GlobalEnv @@ -621,9 +627,21 @@ impl GlobalEnv { stdlib_address: None, extlib_address: None, address_alias_map: Default::default(), + everything_is_target: Default::default(), + generated_by_v2: false, } } + /// Sets whether this is generated by the v2 compiler. + pub fn set_compiler_v2(&mut self, yes: bool) { + self.generated_by_v2 = yes + } + + /// Returns if this is generated by v2. + pub fn generated_by_v2(&self) -> bool { + self.generated_by_v2 + } + /// Creates a display container for the given value. There must be an implementation /// of fmt::Display for an instance to work in formatting. pub fn display<'a, T>(&'a self, val: &'a T) -> EnvDisplay<'a, T> { @@ -635,6 +653,17 @@ impl GlobalEnv { self.address_alias_map = map } + /// Indicates that all modules in the environment should be treated as + /// target modules, i.e. `module.is_target()` returns true. This can be + /// used to temporarily override the default which distinguishes + /// between dependencies and target modules, and is used for tools like + /// the prover which need to compile all code, while still maintaining + /// the difference between targets and dependencies for verification. + /// Those tools can temporarily set this to true. + pub fn treat_everything_as_target(&self, on: bool) { + *self.everything_is_target.borrow_mut() = on + } + /// Attempts to resolve address alias. pub fn resolve_address_alias(&self, alias: Symbol) -> Option { self.address_alias_map.get(&alias).cloned() @@ -1419,7 +1448,7 @@ impl GlobalEnv { let handle = module.function_handle_at(handle_idx); let view = FunctionHandleView::new(&module, handle); let name_str = view.name().as_str(); - let fun_id = if name_str == SCRIPT_BYTECODE_FUN_NAME { + let fun_id = if name_str.starts_with(SCRIPT_BYTECODE_FUN_NAME) { // This is a pseudo script module, which has exactly one function. Determine // the name of this function. let mod_data = &self.module_data[module_id.0 as usize]; @@ -2300,6 +2329,9 @@ impl GlobalEnv { emitln!(writer, ";"); } } + if module.get_verified_module().is_some() { + emitln!(writer, "// bytecode attached"); + } writer.unindent(); emitln!(writer, "}} // end {}", module.get_full_name_str()) } @@ -2575,7 +2607,7 @@ impl<'env> ModuleEnv<'env> { /// a dependency only but not explicitly requested to process. pub fn is_target(&self) -> bool { let file_id = self.data.loc.file_id; - !self.env.file_id_is_dep.contains(&file_id) + *self.env.everything_is_target.borrow() || !self.env.file_id_is_dep.contains(&file_id) } /// Returns the path to source file of this module. @@ -3055,18 +3087,17 @@ impl<'env> ModuleEnv<'env> { /// Disassemble the module bytecode, if it is available. pub fn disassemble(&self) -> Option { - let disas = Disassembler::new( - SourceMapping::new( - self.data.source_map.clone()?, - BinaryIndexedView::Module(self.get_verified_module()?), - ), - DisassemblerOptions { - only_externally_visible: false, - print_code: true, - print_basic_blocks: true, - print_locals: true, - }, - ); + // TODO(#12541): There seems to be a disassembler bug, or the source map we are generating + // is inconsistent, so we are creating a dummy one until this is fixed. + let view = BinaryIndexedView::Module(self.get_verified_module()?); + let smap = SourceMap::dummy_from_view(&view, self.env.to_ir_loc(&self.get_loc())) + .expect("source map"); + let disas = Disassembler::new(SourceMapping::new(smap, view), DisassemblerOptions { + only_externally_visible: false, + print_code: true, + print_basic_blocks: true, + print_locals: true, + }); Some( disas .disassemble() @@ -3825,7 +3856,8 @@ impl<'env> FunctionEnv<'env> { let source_map = self.module_env.data.source_map.as_ref()?; if let Ok(fmap) = source_map.get_function_source_map(self.data.def_idx?) { if let Some(loc) = fmap.get_code_location(offset) { - return Some(self.module_env.env.to_loc(&loc)); + let loc = self.module_env.env.to_loc(&loc); + return Some(loc); } } Some(self.get_loc()) @@ -3843,8 +3875,8 @@ impl<'env> FunctionEnv<'env> { } /// Returns the value of a boolean pragma for this function. This first looks up a - /// pragma in this function, then the enclosing module, and finally uses the provided default. - /// value + /// pragma in this function, then the enclosing module, and finally uses the provided default + /// value. pub fn is_pragma_true(&self, name: &str, default: impl FnOnce() -> bool) -> bool { let env = self.module_env.env; if let Some(b) = env.is_property_true(&self.get_spec().properties, name) { diff --git a/third_party/move/move-model/src/symbol.rs b/third_party/move/move-model/src/symbol.rs index 9fc2dc1a98f40..0847dd6bf908c 100644 --- a/third_party/move/move-model/src/symbol.rs +++ b/third_party/move/move-model/src/symbol.rs @@ -23,6 +23,12 @@ impl Symbol { } } +impl AsRef for Symbol { + fn as_ref(&self) -> &Symbol { + self + } +} + /// A helper to support symbols in formatting. pub struct SymbolDisplay<'a> { sym: &'a Symbol, diff --git a/third_party/move/move-model/src/well_known.rs b/third_party/move/move-model/src/well_known.rs index 06dc1ff673a5c..b0eaa49cfff29 100644 --- a/third_party/move/move-model/src/well_known.rs +++ b/third_party/move/move-model/src/well_known.rs @@ -10,7 +10,7 @@ /// Function identifying the name of an attribute which declares an /// item to be part of test. pub fn is_test_only_attribute_name(s: &str) -> bool { - s == "test" || s == "test_only " + s == "test" || s == "test_only" } /// Function identifying the name of an attribute which declares an diff --git a/third_party/move/move-prover/boogie-backend/src/bytecode_translator.rs b/third_party/move/move-prover/boogie-backend/src/bytecode_translator.rs index e9fecb33755d6..ca7ac88930b6b 100644 --- a/third_party/move/move-prover/boogie-backend/src/bytecode_translator.rs +++ b/third_party/move/move-prover/boogie-backend/src/bytecode_translator.rs @@ -21,6 +21,7 @@ use crate::{ spec_translator::SpecTranslator, }; use codespan::LineIndex; +use codespan_reporting::diagnostic::Severity; use itertools::Itertools; #[allow(unused_imports)] use log::{debug, info, log, warn, Level}; @@ -49,7 +50,7 @@ use move_stackless_bytecode::{ function_target::FunctionTarget, function_target_pipeline::{FunctionTargetsHolder, FunctionVariant, VerificationFlavor}, stackless_bytecode::{ - AbortAction, BorrowEdge, BorrowNode, Bytecode, Constant, HavocKind, IndexEdgeKind, + AbortAction, AttrId, BorrowEdge, BorrowNode, Bytecode, Constant, HavocKind, IndexEdgeKind, Operation, PropKind, }, }; @@ -268,7 +269,8 @@ impl<'env> BoogieTranslator<'env> { } for ref fun_env in module_env.get_functions() { - if fun_env.is_native_or_intrinsic() || fun_env.is_inline() { + if fun_env.is_native_or_intrinsic() || fun_env.is_inline() || fun_env.is_test_only() + { continue; } for (variant, ref fun_target) in self.targets.get_targets(fun_env) { @@ -1470,6 +1472,7 @@ impl<'env> FunctionTranslator<'env> { let src_str = str_local(srcs[0]); let dest_str = str_local(dests[0]); let struct_env = env.get_module(*mid).into_struct(*sid); + self.check_intrinsic_select(attr_id, &struct_env); let field_env = &struct_env.get_field_by_offset(*field_offset); let field_sel = boogie_field_sel(field_env); emitln!( @@ -1487,6 +1490,7 @@ impl<'env> FunctionTranslator<'env> { let mut src_str = str_local(src); let dest_str = str_local(dests[0]); let struct_env = env.get_module(*mid).into_struct(*sid); + self.check_intrinsic_select(attr_id, &struct_env); let field_env = &struct_env.get_field_by_offset(*field_offset); let field_sel = boogie_field_sel(field_env); if self.get_local_type(src).is_reference() { @@ -2242,6 +2246,11 @@ impl<'env> FunctionTranslator<'env> { emitln!(writer, "return;") }, Nop(..) => {}, + SpecBlock(..) => { + // spec blocks should only appear in bytecode during compilation + // to Move bytecode, so bail out. + panic!("unexpected spec block") + }, } emitln!(writer); } @@ -2311,6 +2320,18 @@ impl<'env> FunctionTranslator<'env> { } } + fn check_intrinsic_select(&self, attr_id: AttrId, struct_env: &StructEnv) { + if struct_env.is_intrinsic() && self.fun_target.global_env().generated_by_v2() { + // There is code in the framework which produces this warning. + // Only report if we are running v2. + self.parent.env.diag( + Severity::Warning, + &self.fun_target.get_bytecode_loc(attr_id), + "cannot select field of intrinsic struct", + ) + } + } + /// Returns read aggregate and write aggregate if fun_env matches one of the native functions /// implementing custom mutable borrow. fn get_borrow_native_aggregate_names(&self, fn_name: &String) -> Option<(String, String)> { diff --git a/third_party/move/move-prover/boogie-backend/src/spec_translator.rs b/third_party/move/move-prover/boogie-backend/src/spec_translator.rs index ae20464a9cd1b..8e1cf0fb205d0 100644 --- a/third_party/move/move-prover/boogie-backend/src/spec_translator.rs +++ b/third_party/move/move-prover/boogie-backend/src/spec_translator.rs @@ -952,7 +952,7 @@ impl<'env> SpecTranslator<'env> { | Operation::Abort | Operation::Vector | Operation::Old => { - panic!("operation unexpected: {:?}", oper) + panic!("operation unexpected: {}", oper.display(self.env, node_id)) }, } } diff --git a/third_party/move/move-prover/bytecode-pipeline/src/verification_analysis.rs b/third_party/move/move-prover/bytecode-pipeline/src/verification_analysis.rs index e540628323405..2546387a611c6 100644 --- a/third_party/move/move-prover/bytecode-pipeline/src/verification_analysis.rs +++ b/third_party/move/move-prover/bytecode-pipeline/src/verification_analysis.rs @@ -349,6 +349,14 @@ impl FunctionTargetProcessor for VerificationAnalysisProcessor { impl VerificationAnalysisProcessor { /// Check whether the function falls within the verification scope given in the options fn is_within_verification_scope(fun_env: &FunctionEnv) -> bool { + if fun_env.is_test_only() + || fun_env.is_intrinsic() + || fun_env.is_native() + || fun_env.is_inline() + { + // do not verify any of these function types + return false; + } let env = fun_env.module_env.env; let options = ProverOptions::get(env); match &options.verify_scope { diff --git a/third_party/move/move-prover/src/cli.rs b/third_party/move/move-prover/src/cli.rs index 5b829fc0f2dca..412a1711b5e7e 100644 --- a/third_party/move/move-prover/src/cli.rs +++ b/third_party/move/move-prover/src/cli.rs @@ -65,6 +65,8 @@ pub struct Options { pub experimental_pipeline: bool, /// Whether to skip checking for unknown attributes pub skip_attribute_checks: bool, + /// Whether to use compiler v2 to compile Move code + pub compiler_v2: bool, /// BEGIN OF STRUCTURED OPTIONS. DO NOT ADD VALUE FIELDS AFTER THIS /// Options for the model builder. @@ -103,6 +105,7 @@ impl Default for Options { errmapgen: ErrmapOptions::default(), experimental_pipeline: false, skip_attribute_checks: false, + compiler_v2: false, } } } @@ -163,6 +166,12 @@ impl Options { .action(SetTrue) .help("configures the prover to use Aptos natives") ) + .arg( + Arg::new("compiler-v2") + .long("compiler-v2") + .action(SetTrue) + .help("whether to use Move compiler v2 to compile to bytecode") + ) .arg( Arg::new("output") .short('o') @@ -785,6 +794,9 @@ impl Options { .move_named_address_values .push("Extensions=0x1".to_string()) } + if matches.get_flag("compiler-v2") { + options.compiler_v2 = true; + } options.backend.derive_options(); @@ -809,7 +821,8 @@ impl Options { .set_time_level(LevelFilter::Debug) .set_level_padding(LevelPadding::Off) .build(); - let logger = if atty::is(atty::Stream::Stderr) && atty::is(atty::Stream::Stdout) { + // Ignore error if logger is already setup + let _logger = if atty::is(atty::Stream::Stderr) && atty::is(atty::Stream::Stdout) { CombinedLogger::init(vec![TermLogger::new( self.verbosity_level, config, @@ -818,7 +831,6 @@ impl Options { } else { CombinedLogger::init(vec![SimpleLogger::new(self.verbosity_level, config)]) }; - logger.expect("Unexpected CombinedLogger init failure"); } pub fn setup_logging_for_test(&self) { @@ -829,8 +841,8 @@ impl Options { return; } TEST_MODE.store(true, Ordering::Relaxed); - SimpleLogger::init(self.verbosity_level, Config::default()) - .expect("UnexpectedSimpleLogger failure"); + // Ignore error if logger is already setup + let _ = SimpleLogger::init(self.verbosity_level, Config::default()); } /// Convenience function to enable debugging (like high verbosity) on this instance. diff --git a/third_party/move/move-prover/src/lib.rs b/third_party/move/move-prover/src/lib.rs index a1298abae70d3..ccb8d15846746 100644 --- a/third_party/move/move-prover/src/lib.rs +++ b/third_party/move/move-prover/src/lib.rs @@ -26,6 +26,7 @@ use move_prover_bytecode_pipeline::{ }; use move_stackless_bytecode::function_target_pipeline::FunctionTargetsHolder; use std::{ + cell::RefCell, fs, path::{Path, PathBuf}, time::Instant, @@ -46,7 +47,6 @@ pub fn run_move_prover( options: Options, ) -> anyhow::Result<()> { let now = Instant::now(); - // Run the model builder. let addrs = parse_addresses_from_options(options.move_named_address_values.clone())?; let mut env = run_model_builder_with_options( vec![PackagePaths { @@ -66,6 +66,29 @@ pub fn run_move_prover( run_move_prover_with_model(&mut env, error_writer, options, Some(now)) } +pub fn run_move_prover_v2( + error_writer: &mut W, + options: Options, +) -> anyhow::Result<()> { + let now = Instant::now(); + let cloned_options = options.clone(); + let compiler_options = move_compiler_v2::Options { + dependencies: cloned_options.move_deps, + named_address_mapping: cloned_options.move_named_address_values, + output_dir: cloned_options.output_path, + skip_attribute_checks: true, + known_attributes: Default::default(), + testing: cloned_options.backend.stable_test_output, + experiments: vec![], + experiment_cache: RefCell::new(Default::default()), + sources: cloned_options.move_sources, + warn_unused: false, + whole_program: false, + }; + let mut env = move_compiler_v2::run_move_compiler_for_analysis(error_writer, compiler_options)?; + run_move_prover_with_model_v2(&mut env, error_writer, options, now) +} + /// Create the initial number operation state for each function and struct pub fn create_init_num_operation_state(env: &GlobalEnv) { let mut global_state: GlobalNumberOperationState = Default::default(); @@ -89,6 +112,7 @@ pub fn run_move_prover_with_model( timer: Option, ) -> anyhow::Result<()> { let now = timer.unwrap_or_else(Instant::now); + debug!("global env before prover run: {}", env.dump_env_all()); // Run the compiler v2 checking and rewriting pipeline let compiler_options = move_compiler_v2::Options::default(); @@ -100,10 +124,18 @@ pub fn run_move_prover_with_model( ); pipeline.add("specification rewriter", spec_rewriter::run_spec_rewriter); pipeline.run(env); + run_move_prover_with_model_v2(env, error_writer, options, now) +} +pub fn run_move_prover_with_model_v2( + env: &mut GlobalEnv, + error_writer: &mut W, + options: Options, + start_time: Instant, +) -> anyhow::Result<()> { debug!("global env before prover run:\n{}", env.dump_env_all()); - let build_duration = now.elapsed(); + let build_duration = start_time.elapsed(); check_errors( env, &options, @@ -121,16 +153,16 @@ pub fn run_move_prover_with_model( // Until this point, prover and docgen have same code. Here we part ways. if options.run_docgen { - return run_docgen(env, &options, error_writer, now); + return run_docgen(env, &options, error_writer, start_time); } // Same for ABI generator. if options.run_abigen { - return run_abigen(env, &options, now); + return run_abigen(env, &options, start_time); } // Same for the error map generator if options.run_errmapgen { return { - run_errmapgen(env, &options, now); + run_errmapgen(env, &options, start_time); Ok(()) }; } diff --git a/third_party/move/move-prover/src/main.rs b/third_party/move/move-prover/src/main.rs index 303736ee41ec5..64341570ed667 100644 --- a/third_party/move/move-prover/src/main.rs +++ b/third_party/move/move-prover/src/main.rs @@ -5,7 +5,7 @@ #![forbid(unsafe_code)] use codespan_reporting::term::termcolor::{ColorChoice, StandardStream}; -use move_prover::{cli::Options, run_move_prover}; +use move_prover::{cli::Options, run_move_prover, run_move_prover_v2}; use std::env; fn main() { @@ -30,5 +30,9 @@ fn run() -> anyhow::Result<()> { }; options.setup_logging(); let mut error_writer = StandardStream::stderr(color); - run_move_prover(&mut error_writer, options) + if options.compiler_v2 { + run_move_prover_v2(&mut error_writer, options) + } else { + run_move_prover(&mut error_writer, options) + } } diff --git a/third_party/move/move-prover/tests/sources/functional/ModifiesErrorTest.v2_exp b/third_party/move/move-prover/tests/sources/functional/ModifiesErrorTest.v2_exp new file mode 100644 index 0000000000000..301952d89b6c8 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/ModifiesErrorTest.v2_exp @@ -0,0 +1,79 @@ +Move prover returns: exiting with verification errors +error: caller does not have permission to modify `B::T` at given address + ┌─ tests/sources/functional/ModifiesErrorTest.move:38:17 + │ +38 │ let t = borrow_global_mut(addr1); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/ModifiesErrorTest.move:36: mutate_at_test_incorrect + = at tests/sources/functional/ModifiesErrorTest.move:47: mutate_at_test_incorrect (spec) + = at tests/sources/functional/ModifiesErrorTest.move:36: mutate_at_test_incorrect + = addr1 = + = addr2 = + = at tests/sources/functional/ModifiesErrorTest.move:37: mutate_at_test_incorrect + = addr1 = + = at tests/sources/functional/ModifiesErrorTest.move:38: mutate_at_test_incorrect + +error: caller does not have permission to modify `B::T` at given address + ┌─ tests/sources/functional/ModifiesErrorTest.move:52:9 + │ +52 │ move_to(account, T{x: 2}); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/ModifiesErrorTest.move:50: move_to_test_incorrect + = at tests/sources/functional/ModifiesErrorTest.move:60: move_to_test_incorrect (spec) + = at tests/sources/functional/ModifiesErrorTest.move:50: move_to_test_incorrect + = account = + = addr2 = + = at tests/sources/functional/ModifiesErrorTest.move:51: move_to_test_incorrect + = account = + = at tests/sources/functional/ModifiesErrorTest.move:52: move_to_test_incorrect + = addr2 = + +error: caller does not have permission to modify `B::T` at given address + ┌─ tests/sources/functional/ModifiesErrorTest.move:65:17 + │ +65 │ let v = move_from(addr1); + │ ^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/ModifiesErrorTest.move:63: move_from_test_incorrect + = at tests/sources/functional/ModifiesErrorTest.move:74: move_from_test_incorrect (spec) + = at tests/sources/functional/ModifiesErrorTest.move:63: move_from_test_incorrect + = addr1 = + = addr2 = + = at tests/sources/functional/ModifiesErrorTest.move:64: move_from_test_incorrect + = addr1 = + = at tests/sources/functional/ModifiesErrorTest.move:65: move_from_test_incorrect + +error: caller does not have permission to modify `A::S` at given address + ┌─ tests/sources/functional/ModifiesErrorTest.move:79:9 + │ +79 │ A::mutate_at(addr1); + │ ^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/ModifiesErrorTest.move:77: mutate_S_test1_incorrect + = at tests/sources/functional/ModifiesErrorTest.move:86: mutate_S_test1_incorrect (spec) + = at tests/sources/functional/ModifiesErrorTest.move:87: mutate_S_test1_incorrect (spec) + = at tests/sources/functional/ModifiesErrorTest.move:77: mutate_S_test1_incorrect + = addr1 = + = addr2 = + = at tests/sources/functional/ModifiesErrorTest.move:78: mutate_S_test1_incorrect + = addr1 = + = at tests/sources/functional/ModifiesErrorTest.move:79: mutate_S_test1_incorrect + +error: unknown assertion failed + ┌─ tests/sources/functional/ModifiesErrorTest.move:95:13 + │ +95 │ assert x0 == x1; + │ ^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/ModifiesErrorTest.move:90: mutate_S_test2_incorrect + = at tests/sources/functional/ModifiesErrorTest.move:99: mutate_S_test2_incorrect (spec) + = at tests/sources/functional/ModifiesErrorTest.move:90: mutate_S_test2_incorrect + = addr = + = at tests/sources/functional/ModifiesErrorTest.move:91: mutate_S_test2_incorrect + = addr = + = at tests/sources/functional/ModifiesErrorTest.move:92: mutate_S_test2_incorrect + = at tests/sources/functional/ModifiesErrorTest.move:93: mutate_S_test2_incorrect + = x0 = + = at tests/sources/functional/ModifiesErrorTest.move:95: mutate_S_test2_incorrect diff --git a/third_party/move/move-prover/tests/sources/functional/ModifiesSchemaTest.v2_exp b/third_party/move/move-prover/tests/sources/functional/ModifiesSchemaTest.v2_exp new file mode 100644 index 0000000000000..3ff81c6079fcd --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/ModifiesSchemaTest.v2_exp @@ -0,0 +1,20 @@ +Move prover returns: exiting with verification errors +error: caller does not have permission to modify `A::S` at given address + ┌─ tests/sources/functional/ModifiesSchemaTest.move:31:9 + │ +31 │ mutate_at(addr2) + │ ^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/ModifiesSchemaTest.move:29: mutate_at_wrapper2 + = at tests/sources/functional/ModifiesSchemaTest.move:9 + = at tests/sources/functional/ModifiesSchemaTest.move:29: mutate_at_wrapper2 + = addr1 = + = addr2 = + = at tests/sources/functional/ModifiesSchemaTest.move:30: mutate_at_wrapper2 + = at tests/sources/functional/ModifiesSchemaTest.move:12: mutate_at + = addr = + = at tests/sources/functional/ModifiesSchemaTest.move:13: mutate_at + = addr = + = at tests/sources/functional/ModifiesSchemaTest.move:14: mutate_at + = at tests/sources/functional/ModifiesSchemaTest.move:15: mutate_at + = at tests/sources/functional/ModifiesSchemaTest.move:31: mutate_at_wrapper2 diff --git a/third_party/move/move-prover/tests/sources/functional/ModifiesTypeTest.v2_exp b/third_party/move/move-prover/tests/sources/functional/ModifiesTypeTest.v2_exp new file mode 100644 index 0000000000000..4c7ef5eaf5390 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/ModifiesTypeTest.v2_exp @@ -0,0 +1,16 @@ +Move prover returns: exiting with bytecode transformation errors +error: function `A::mutate_at` is opaque but its specification does not have a modifies clause for `A::S` + ┌─ tests/sources/functional/ModifiesTypeTest.move:21:5 + │ +21 │ ╭ spec mutate_at { +22 │ │ pragma opaque = true; +23 │ │ } + │ ╰─────^ + +error: caller `B::mutate_S_test1_incorrect` specifies modify targets for `A::S` but callee `A::mutate_at` does not + ┌─ tests/sources/functional/ModifiesTypeTest.move:29:5 + │ +29 │ ╭ public fun mutate_S_test1_incorrect(addr: address) { +30 │ │ A::mutate_at(addr); +31 │ │ } + │ ╰─────^ diff --git a/third_party/move/move-prover/tests/sources/functional/aborts_if.v2_exp b/third_party/move/move-prover/tests/sources/functional/aborts_if.v2_exp new file mode 100644 index 0000000000000..f6c12acd83f2d --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/aborts_if.v2_exp @@ -0,0 +1,159 @@ +Move prover returns: exiting with verification errors +error: function does not abort under this condition + ┌─ tests/sources/functional/aborts_if.move:35:9 + │ +35 │ aborts_if _x <= _y; + │ ^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/aborts_if.move:32: abort2_incorrect + = _x = + = _y = + = at tests/sources/functional/aborts_if.move:33: abort2_incorrect + = at tests/sources/functional/aborts_if.move:35: abort2_incorrect (spec) + +error: function does not abort under this condition + ┌─ tests/sources/functional/aborts_if.move:52:9 + │ +52 │ aborts_if x <= y; + │ ^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/aborts_if.move:47: abort4_incorrect + = x = + = y = + = at tests/sources/functional/aborts_if.move:48: abort4_incorrect + = at tests/sources/functional/aborts_if.move:49: abort4_incorrect + = at tests/sources/functional/aborts_if.move:52: abort4_incorrect (spec) + +error: abort not covered by any of the `aborts_if` clauses + ┌─ tests/sources/functional/aborts_if.move:59:5 + │ +57 │ if (x <= y) abort 1 + │ ------- abort happened here with code 0x1 +58 │ } +59 │ ╭ spec abort5_incorrect { +60 │ │ aborts_if x < y; +61 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/aborts_if.move:56: abort5_incorrect + = x = + = y = + = at tests/sources/functional/aborts_if.move:57: abort5_incorrect + = ABORTED + +error: function does not abort under this condition + ┌─ tests/sources/functional/aborts_if.move:68:9 + │ +68 │ aborts_if x <= y; + │ ^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/aborts_if.move:64: abort6_incorrect + = x = + = y = + = at tests/sources/functional/aborts_if.move:65: abort6_incorrect + = at tests/sources/functional/aborts_if.move:66: abort6_incorrect + = at tests/sources/functional/aborts_if.move:68: abort6_incorrect (spec) + +error: function does not abort under this condition + ┌─ tests/sources/functional/aborts_if.move:91:9 + │ +91 │ aborts_if x == y; + │ ^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/aborts_if.move:86: multi_abort2_incorrect + = x = + = y = + = at tests/sources/functional/aborts_if.move:87: multi_abort2_incorrect + = at tests/sources/functional/aborts_if.move:88: multi_abort2_incorrect + = at tests/sources/functional/aborts_if.move:90: multi_abort2_incorrect (spec) + = at tests/sources/functional/aborts_if.move:91: multi_abort2_incorrect (spec) + +error: abort not covered by any of the `aborts_if` clauses + ┌─ tests/sources/functional/aborts_if.move:98:5 + │ + 96 │ abort 1 + │ ------- abort happened here with code 0x1 + 97 │ } + 98 │ ╭ spec multi_abort3_incorrect { + 99 │ │ aborts_if _x < _y; +100 │ │ aborts_if _x == _y; +101 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/aborts_if.move:95: multi_abort3_incorrect + = _x = + = _y = + = at tests/sources/functional/aborts_if.move:96: multi_abort3_incorrect + = ABORTED + +error: function does not abort under this condition + ┌─ tests/sources/functional/aborts_if.move:119:9 + │ +119 │ aborts_if true; + │ ^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/aborts_if.move:113: multi_abort5_incorrect + = x = + = at tests/sources/functional/aborts_if.move:114: multi_abort5_incorrect + = x = + = at tests/sources/functional/aborts_if.move:117: multi_abort5_incorrect + = at tests/sources/functional/aborts_if.move:119: multi_abort5_incorrect (spec) + +error: abort not covered by any of the `aborts_if` clauses + ┌─ tests/sources/functional/aborts_if.move:139:5 + │ +137 │ if (x == 2 || x == 3) abort 1; + │ ------- abort happened here with code 0x1 +138 │ } +139 │ ╭ spec abort_at_2_or_3_total_incorrect { +140 │ │ // Counter check that we get an error message without the pragma. +141 │ │ // pragma aborts_if_is_partial = false; // default +142 │ │ aborts_if x == 2; +143 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/aborts_if.move:136: abort_at_2_or_3_total_incorrect + = x = + = at tests/sources/functional/aborts_if.move:137: abort_at_2_or_3_total_incorrect + = x = + = at tests/sources/functional/aborts_if.move:137: abort_at_2_or_3_total_incorrect + = = + = at tests/sources/functional/aborts_if.move:137: abort_at_2_or_3_total_incorrect + = ABORTED + +error: function does not abort under this condition + ┌─ tests/sources/functional/aborts_if.move:151:9 + │ +151 │ aborts_if x == 4; + │ ^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/aborts_if.move:145: abort_at_2_or_3_spec_incorrect + = x = + = at tests/sources/functional/aborts_if.move:146: abort_at_2_or_3_spec_incorrect + = x = + = at tests/sources/functional/aborts_if.move:146: abort_at_2_or_3_spec_incorrect + = = + = at tests/sources/functional/aborts_if.move:146: abort_at_2_or_3_spec_incorrect + = at tests/sources/functional/aborts_if.move:147: abort_at_2_or_3_spec_incorrect + = at tests/sources/functional/aborts_if.move:151: abort_at_2_or_3_spec_incorrect (spec) + +error: abort not covered by any of the `aborts_if` clauses + ┌─ tests/sources/functional/aborts_if.move:157:5 + │ +155 │ if (x == 2 || x == 3) abort 1; + │ ------- abort happened here with code 0x1 +156 │ } +157 │ ╭ spec abort_at_2_or_3_strict_incorrect { +158 │ │ // When the strict mode is enabled, no aborts_if clause means aborts_if false. +159 │ │ pragma aborts_if_is_strict = true; +160 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/aborts_if.move:154: abort_at_2_or_3_strict_incorrect + = x = + = at tests/sources/functional/aborts_if.move:155: abort_at_2_or_3_strict_incorrect + = x = + = at tests/sources/functional/aborts_if.move:155: abort_at_2_or_3_strict_incorrect + = = + = at tests/sources/functional/aborts_if.move:155: abort_at_2_or_3_strict_incorrect + = ABORTED diff --git a/third_party/move/move-prover/tests/sources/functional/aborts_if_with_code.v2_exp b/third_party/move/move-prover/tests/sources/functional/aborts_if_with_code.v2_exp new file mode 100644 index 0000000000000..0cf0d4d60be2a --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/aborts_if_with_code.v2_exp @@ -0,0 +1,101 @@ +Move prover returns: exiting with verification errors +error: abort code not covered by any of the `aborts_if` or `aborts_with` clauses + ┌─ tests/sources/functional/aborts_if_with_code.move:38:5 + │ +31 │ abort 2 + │ ------- abort happened here with code 0x2 + · +38 │ ╭ spec conditional_abort_invalid { +39 │ │ aborts_if x == 1 with 1; // wrong code +40 │ │ aborts_if y == 2 with 3; +41 │ │ ensures result == x; +42 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/aborts_if_with_code.move:29: conditional_abort_invalid + = x = + = y = + = at tests/sources/functional/aborts_if_with_code.move:30: conditional_abort_invalid + = x = + = at tests/sources/functional/aborts_if_with_code.move:31: conditional_abort_invalid + = ABORTED + +error: abort code not covered by any of the `aborts_if` or `aborts_with` clauses + ┌─ tests/sources/functional/aborts_if_with_code.move:48:5 + │ +46 │ 10 / x + │ ------ abort happened here with execution failure +47 │ } +48 │ ╭ spec exec_failure_invalid { +49 │ │ aborts_if x == 0 with 1; // wrong code +50 │ │ ensures result == 10 / x; +51 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/aborts_if_with_code.move:45: exec_failure_invalid + = x = + = at tests/sources/functional/aborts_if_with_code.move:46: exec_failure_invalid + = ABORTED + +error: abort code not covered by any of the `aborts_if` or `aborts_with` clauses + ┌─ tests/sources/functional/aborts_if_with_code.move:77:5 + │ +74 │ abort(2) + │ -------- abort happened here with code 0x2 + · +77 │ ╭ spec aborts_if_with_code_mixed_invalid { +78 │ │ aborts_if x == 1; +79 │ │ aborts_if x == 2 with 1; +80 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/aborts_if_with_code.move:69: aborts_if_with_code_mixed_invalid + = x = + = at tests/sources/functional/aborts_if_with_code.move:70: aborts_if_with_code_mixed_invalid + = x = + = at tests/sources/functional/aborts_if_with_code.move:73: aborts_if_with_code_mixed_invalid + = = + = at tests/sources/functional/aborts_if_with_code.move:74: aborts_if_with_code_mixed_invalid + = ABORTED + +error: abort code not covered by any of the `aborts_if` or `aborts_with` clauses + ┌─ tests/sources/functional/aborts_if_with_code.move:105:5 + │ +102 │ abort(2) + │ -------- abort happened here with code 0x2 + · +105 │ ╭ spec aborts_with_invalid { +106 │ │ aborts_with 1,3; +107 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/aborts_if_with_code.move:97: aborts_with_invalid + = x = + = at tests/sources/functional/aborts_if_with_code.move:98: aborts_with_invalid + = x = + = at tests/sources/functional/aborts_if_with_code.move:101: aborts_with_invalid + = = + = at tests/sources/functional/aborts_if_with_code.move:102: aborts_with_invalid + = ABORTED + +error: abort code not covered by any of the `aborts_if` or `aborts_with` clauses + ┌─ tests/sources/functional/aborts_if_with_code.move:131:5 + │ +128 │ abort(1) + │ -------- abort happened here with code 0x1 + · +131 │ ╭ spec aborts_with_mixed_invalid { +132 │ │ pragma aborts_if_is_partial = true; +133 │ │ aborts_if x == 1 with 1; +134 │ │ aborts_with 2; +135 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/aborts_if_with_code.move:123: aborts_with_mixed_invalid + = x = + = at tests/sources/functional/aborts_if_with_code.move:124: aborts_with_mixed_invalid + = x = + = at tests/sources/functional/aborts_if_with_code.move:127: aborts_with_mixed_invalid + = = + = at tests/sources/functional/aborts_if_with_code.move:128: aborts_with_mixed_invalid + = ABORTED diff --git a/third_party/move/move-prover/tests/sources/functional/address_quant.v2_exp b/third_party/move/move-prover/tests/sources/functional/address_quant.v2_exp new file mode 100644 index 0000000000000..4f99862b251ad --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/address_quant.v2_exp @@ -0,0 +1,16 @@ +Move prover returns: exiting with verification errors +error: post-condition does not hold + ┌─ tests/sources/functional/address_quant.move:53:10 + │ +53 │ invariant atMostOne(); + │ ^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/address_quant.move:46: multiple_copy_incorrect + = at tests/sources/functional/address_quant.move:53 + = at tests/sources/functional/address_quant.move:54 + = at tests/sources/functional/address_quant.move:46: multiple_copy_incorrect + = sndr = + = at tests/sources/functional/address_quant.move:47: multiple_copy_incorrect + = sndr = + = at tests/sources/functional/address_quant.move:48: multiple_copy_incorrect + = at tests/sources/functional/address_quant.move:53 diff --git a/third_party/move/move-prover/tests/sources/functional/address_serialization_constant_size.v2_exp b/third_party/move/move-prover/tests/sources/functional/address_serialization_constant_size.v2_exp new file mode 100644 index 0000000000000..f6cdbed854890 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/address_serialization_constant_size.v2_exp @@ -0,0 +1,15 @@ +Move prover returns: exiting with verification errors +error: post-condition does not hold + ┌─ tests/sources/functional/address_serialization_constant_size.move:19:9 + │ +19 │ ensures len(bcs::serialize(mv1)) == len(bcs::serialize(mv2)); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/address_serialization_constant_size.move:15: serialized_move_values_diff_len_incorrect + = mv1 = + = mv2 = + = at tests/sources/functional/address_serialization_constant_size.move:16: serialized_move_values_diff_len_incorrect + = result_1 = + = result_2 = + = at tests/sources/functional/address_serialization_constant_size.move:17: serialized_move_values_diff_len_incorrect + = at tests/sources/functional/address_serialization_constant_size.move:19: serialized_move_values_diff_len_incorrect (spec) diff --git a/third_party/move/move-prover/tests/sources/functional/arithm.v2_exp b/third_party/move/move-prover/tests/sources/functional/arithm.v2_exp new file mode 100644 index 0000000000000..4554410906339 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/arithm.v2_exp @@ -0,0 +1,221 @@ +Move prover returns: exiting with verification errors +error: abort not covered by any of the `aborts_if` clauses + ┌─ tests/sources/functional/arithm.move:128:5 + │ +126 │ x / y + │ ----- abort happened here with execution failure +127 │ } +128 │ ╭ spec div_by_zero_u64_incorrect { +129 │ │ aborts_if false; +130 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/arithm.move:125: div_by_zero_u64_incorrect + = x = + = y = + = at tests/sources/functional/arithm.move:126: div_by_zero_u64_incorrect + = ABORTED + +error: abort not covered by any of the `aborts_if` clauses + ┌─ tests/sources/functional/arithm.move:148:5 + │ +146 │ x + y + │ ----- abort happened here with execution failure +147 │ } +148 │ ╭ spec overflow_u8_add_incorrect { +149 │ │ aborts_if false; +150 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/arithm.move:145: overflow_u8_add_incorrect + = x = + = y = + = at tests/sources/functional/arithm.move:146: overflow_u8_add_incorrect + = ABORTED + +error: abort not covered by any of the `aborts_if` clauses + ┌─ tests/sources/functional/arithm.move:164:5 + │ +162 │ x + y + │ ----- abort happened here with execution failure +163 │ } +164 │ ╭ spec overflow_u16_add_incorrect { +165 │ │ aborts_if false; +166 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/arithm.move:161: overflow_u16_add_incorrect + = x = + = y = + = at tests/sources/functional/arithm.move:162: overflow_u16_add_incorrect + = ABORTED + +error: abort not covered by any of the `aborts_if` clauses + ┌─ tests/sources/functional/arithm.move:180:5 + │ +178 │ x + y + │ ----- abort happened here with execution failure +179 │ } +180 │ ╭ spec overflow_u32_add_incorrect { +181 │ │ aborts_if false; +182 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/arithm.move:177: overflow_u32_add_incorrect + = x = + = y = + = at tests/sources/functional/arithm.move:178: overflow_u32_add_incorrect + = ABORTED + +error: abort not covered by any of the `aborts_if` clauses + ┌─ tests/sources/functional/arithm.move:196:5 + │ +194 │ x + y + │ ----- abort happened here with execution failure +195 │ } +196 │ ╭ spec overflow_u64_add_incorrect { +197 │ │ aborts_if false; +198 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/arithm.move:193: overflow_u64_add_incorrect + = x = + = y = + = at tests/sources/functional/arithm.move:194: overflow_u64_add_incorrect + = ABORTED + +error: abort not covered by any of the `aborts_if` clauses + ┌─ tests/sources/functional/arithm.move:212:5 + │ +210 │ x + y + │ ----- abort happened here with execution failure +211 │ } +212 │ ╭ spec overflow_u128_add_incorrect { +213 │ │ aborts_if false; +214 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/arithm.move:209: overflow_u128_add_incorrect + = x = + = y = + = at tests/sources/functional/arithm.move:210: overflow_u128_add_incorrect + = ABORTED + +error: abort not covered by any of the `aborts_if` clauses + ┌─ tests/sources/functional/arithm.move:228:5 + │ +226 │ x + y + │ ----- abort happened here with execution failure +227 │ } +228 │ ╭ spec overflow_u256_add_incorrect { +229 │ │ aborts_if false; +230 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/arithm.move:225: overflow_u256_add_incorrect + = x = + = y = + = at tests/sources/functional/arithm.move:226: overflow_u256_add_incorrect + = ABORTED + +error: abort not covered by any of the `aborts_if` clauses + ┌─ tests/sources/functional/arithm.move:249:5 + │ +247 │ x * y + │ ----- abort happened here with execution failure +248 │ } +249 │ ╭ spec overflow_u8_mul_incorrect { +250 │ │ aborts_if false; +251 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/arithm.move:246: overflow_u8_mul_incorrect + = x = + = y = + = at tests/sources/functional/arithm.move:247: overflow_u8_mul_incorrect + = ABORTED + +error: abort not covered by any of the `aborts_if` clauses + ┌─ tests/sources/functional/arithm.move:265:5 + │ +263 │ x * y + │ ----- abort happened here with execution failure +264 │ } +265 │ ╭ spec overflow_u16_mul_incorrect { +266 │ │ aborts_if false; +267 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/arithm.move:262: overflow_u16_mul_incorrect + = x = + = y = + = at tests/sources/functional/arithm.move:263: overflow_u16_mul_incorrect + = ABORTED + +error: abort not covered by any of the `aborts_if` clauses + ┌─ tests/sources/functional/arithm.move:281:5 + │ +279 │ x * y + │ ----- abort happened here with execution failure +280 │ } +281 │ ╭ spec overflow_u32_mul_incorrect { +282 │ │ aborts_if false; +283 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/arithm.move:278: overflow_u32_mul_incorrect + = x = + = y = + = at tests/sources/functional/arithm.move:279: overflow_u32_mul_incorrect + = ABORTED + +error: abort not covered by any of the `aborts_if` clauses + ┌─ tests/sources/functional/arithm.move:297:5 + │ +295 │ x * y + │ ----- abort happened here with execution failure +296 │ } +297 │ ╭ spec overflow_u64_mul_incorrect { +298 │ │ aborts_if false; +299 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/arithm.move:294: overflow_u64_mul_incorrect + = x = + = y = + = at tests/sources/functional/arithm.move:295: overflow_u64_mul_incorrect + = ABORTED + +error: abort not covered by any of the `aborts_if` clauses + ┌─ tests/sources/functional/arithm.move:312:5 + │ +310 │ x * y + │ ----- abort happened here with execution failure +311 │ } +312 │ ╭ spec overflow_u128_mul_incorrect { +313 │ │ aborts_if false; +314 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/arithm.move:309: overflow_u128_mul_incorrect + = x = + = y = + = at tests/sources/functional/arithm.move:310: overflow_u128_mul_incorrect + = ABORTED + +error: abort not covered by any of the `aborts_if` clauses + ┌─ tests/sources/functional/arithm.move:327:5 + │ +325 │ x * y + │ ----- abort happened here with execution failure +326 │ } +327 │ ╭ spec overflow_u256_mul_incorrect { +328 │ │ aborts_if false; +329 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/arithm.move:324: overflow_u256_mul_incorrect + = x = + = y = + = at tests/sources/functional/arithm.move:325: overflow_u256_mul_incorrect + = ABORTED diff --git a/third_party/move/move-prover/tests/sources/functional/bitwise_features.move b/third_party/move/move-prover/tests/sources/functional/bitwise_features.move index f3f2d227412a3..96486010cce50 100644 --- a/third_party/move/move-prover/tests/sources/functional/bitwise_features.move +++ b/third_party/move/move-prover/tests/sources/functional/bitwise_features.move @@ -1,4 +1,5 @@ // exclude_for: cvc5 +/* TODO(#12501): this has legit verification failures in v2 which are missing in v1 */ address 0x123 { module TestFeatures { @@ -12,7 +13,7 @@ module TestFeatures { } spec Features { - pragma bv=b"0"; + pragma bv = b"0"; } /// Helper to check whether a feature flag is enabled. @@ -23,7 +24,7 @@ module TestFeatures { } spec contains { - pragma bv=b"0"; + pragma bv = b"0"; pragma opaque; aborts_if false; ensures result == ((feature / 8) < len(features) && spec_contains(features, feature)); @@ -51,7 +52,7 @@ module TestFeatures { let byte_index = feature / 8; let bit_mask = 1 << ((feature % 8) as u8); - while({ + while ({ spec { invariant n == len(features); invariant n >= old_n; @@ -73,7 +74,7 @@ module TestFeatures { } spec set { - pragma bv=b"0"; + pragma bv = b"0"; pragma timeout = 120; aborts_if false; ensures feature / 8 < len(features); @@ -87,7 +88,7 @@ module TestFeatures { acquires Features { assert!(signer::address_of(framework) == @std, error::permission_denied(EFRAMEWORK_SIGNER_NEEDED)); if (!exists(@std)) { - move_to(framework, Features{features: vector[]}) + move_to(framework, Features { features: vector[] }) }; let features = &mut borrow_global_mut(@std).features; let i = 0; @@ -112,7 +113,7 @@ module TestFeatures { spec fun spec_compute_feature_flag(features: vector, feature: u64): u8 { ((int2bv((((1 as u8) << ((feature % (8 as u64)) as u64)) as u8)) as u8) - & features[feature/8] as u8) + & features[feature / 8] as u8) } spec fun spec_contains(features: vector, feature: u64): bool { @@ -176,6 +177,5 @@ module TestFeatures { let post features = global(@std).features; ensures forall i in 0..len(enable): (enable[i] / 8 < len(features) && spec_contains(features, enable[i])); } - } } diff --git a/third_party/move/move-prover/tests/sources/functional/cast.v2_exp b/third_party/move/move-prover/tests/sources/functional/cast.v2_exp new file mode 100644 index 0000000000000..7f6ea2f6f8bb5 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/cast.v2_exp @@ -0,0 +1,64 @@ +Move prover returns: exiting with verification errors +error: abort not covered by any of the `aborts_if` clauses + ┌─ tests/sources/functional/cast.move:53:5 + │ +51 │ (x as u8) + │ --------- abort happened here with execution failure +52 │ } +53 │ ╭ spec aborting_u8_cast_incorrect { +54 │ │ aborts_if false; +55 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/cast.move:50: aborting_u8_cast_incorrect + = x = + = at tests/sources/functional/cast.move:51: aborting_u8_cast_incorrect + = ABORTED + +error: abort not covered by any of the `aborts_if` clauses + ┌─ tests/sources/functional/cast.move:67:5 + │ +65 │ (x as u16) + │ ---------- abort happened here with execution failure +66 │ } +67 │ ╭ spec aborting_u16_cast_incorrect { +68 │ │ aborts_if false; +69 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/cast.move:64: aborting_u16_cast_incorrect + = x = + = at tests/sources/functional/cast.move:65: aborting_u16_cast_incorrect + = ABORTED + +error: abort not covered by any of the `aborts_if` clauses + ┌─ tests/sources/functional/cast.move:81:5 + │ +79 │ (x as u32) + │ ---------- abort happened here with execution failure +80 │ } +81 │ ╭ spec aborting_u32_cast_incorrect { +82 │ │ aborts_if false; +83 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/cast.move:78: aborting_u32_cast_incorrect + = x = + = at tests/sources/functional/cast.move:79: aborting_u32_cast_incorrect + = ABORTED + +error: abort not covered by any of the `aborts_if` clauses + ┌─ tests/sources/functional/cast.move:109:5 + │ + 93 │ (x as u64) + │ ---------- abort happened here with execution failure + · +109 │ ╭ spec aborting_u64_cast_incorrect { +110 │ │ aborts_if false; +111 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/cast.move:92: aborting_u64_cast_incorrect + = x = + = at tests/sources/functional/cast.move:93: aborting_u64_cast_incorrect + = ABORTED diff --git a/third_party/move/move-prover/tests/sources/functional/choice.v2_exp b/third_party/move/move-prover/tests/sources/functional/choice.v2_exp new file mode 100644 index 0000000000000..9f8a12e2a7a11 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/choice.v2_exp @@ -0,0 +1,154 @@ +Move prover returns: exiting with verification errors +error: post-condition does not hold + ┌─ tests/sources/functional/choice.move:22:9 + │ +22 │ ensures result == TRACE(choose x: u64 where x >= 4 && x <= 5); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/choice.move:16: simple_incorrect + = b = + = at tests/sources/functional/choice.move:17: simple_incorrect + = b = + = at tests/sources/functional/choice.move:17: simple_incorrect + = result = + = at tests/sources/functional/choice.move:18: simple_incorrect + = at tests/sources/functional/choice.move:22: simple_incorrect (spec) + = `TRACE(choose x: u64 where x >= 4 && x <= 5)` = + +error: post-condition does not hold + ┌─ tests/sources/functional/choice.move:56:9 + │ +56 │ ensures choice == signer::address_of(s2); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/choice.move:46: populate_R + = at tests/sources/functional/choice.move:51: populate_R (spec) + = at tests/sources/functional/choice.move:52: populate_R (spec) + = at tests/sources/functional/choice.move:55: populate_R (spec) + = at tests/sources/functional/choice.move:54: populate_R (spec) + = at tests/sources/functional/choice.move:46: populate_R + = s1 = + = s2 = + = at tests/sources/functional/choice.move:47: populate_R + = s1 = + = at tests/sources/functional/choice.move:48: populate_R + = s2 = + = at tests/sources/functional/choice.move:49: populate_R + = at tests/sources/functional/choice.move:56: populate_R (spec) + +error: post-condition does not hold + ┌─ tests/sources/functional/choice.move:87:9 + │ +87 │ ensures TRACE(choose i in 0..len(result) where result[i] == 2) == 1; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/choice.move:76: test_not_using_min_incorrect + = v = + = at tests/sources/functional/choice.move:77: test_not_using_min_incorrect + = v_ref = + = at tests/sources/functional/choice.move:78: test_not_using_min_incorrect + = = + = at tests/sources/functional/choice.move:79: test_not_using_min_incorrect + = = + = at tests/sources/functional/choice.move:80: test_not_using_min_incorrect + = = + = at tests/sources/functional/choice.move:81: test_not_using_min_incorrect + = = + = at tests/sources/functional/choice.move:82: test_not_using_min_incorrect + = = + = v = + = at tests/sources/functional/choice.move:83: test_not_using_min_incorrect + = return = + = at tests/sources/functional/choice.move:75: test_not_using_min_incorrect + = result = + = at tests/sources/functional/choice.move:84: test_not_using_min_incorrect + = at tests/sources/functional/choice.move:87: test_not_using_min_incorrect (spec) + = `TRACE(choose i in 0..len(result) where result[i] == 2)` = + +error: post-condition does not hold + ┌─ tests/sources/functional/choice.move:100:9 + │ +100 │ ensures result == TRACE(choose y: u64 where y > x); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/choice.move:95: test_choice_dup_expected_fail + = x = + = at tests/sources/functional/choice.move:96: test_choice_dup_expected_fail + = x = + = result = + = at tests/sources/functional/choice.move:97: test_choice_dup_expected_fail + = at tests/sources/functional/choice.move:100: test_choice_dup_expected_fail (spec) + = `TRACE(choose y: u64 where y > x)` = + +error: post-condition does not hold + ┌─ tests/sources/functional/choice.move:158:9 + │ +158 │ ensures evidence1 == evidence2; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/choice.move:156: test_different_choice_via_let (spec) + = at tests/sources/functional/choice.move:157: test_different_choice_via_let (spec) + = at tests/sources/functional/choice.move:154: test_different_choice_via_let + = at tests/sources/functional/choice.move:158: test_different_choice_via_let (spec) + +error: post-condition does not hold + ┌─ tests/sources/functional/choice.move:182:9 + │ +182 │ ensures choose_some_positive_u64() == choose_another_positive_u64(); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/choice.move:180: test_different_choice_via_spec_fun + = at tests/sources/functional/choice.move:182: test_different_choice_via_spec_fun (spec) + +error: post-condition does not hold + ┌─ tests/sources/functional/choice.move:210:9 + │ +210 │ ensures evidence1 == evidence2; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/choice.move:206: test_same_choice_different_args_via_spec_fun + = at tests/sources/functional/choice.move:208: test_same_choice_different_args_via_spec_fun (spec) + = at tests/sources/functional/choice.move:209: test_same_choice_different_args_via_spec_fun (spec) + = at tests/sources/functional/choice.move:206: test_same_choice_different_args_via_spec_fun + = x = + = y = + = result = + = at tests/sources/functional/choice.move:210: test_same_choice_different_args_via_spec_fun (spec) + +error: post-condition does not hold + ┌─ tests/sources/functional/choice.move:219:9 + │ +219 │ ensures result != (choose i: u64 where i >= k); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/choice.move:236: test_same_choice_different_args_via_schema_2 + = result = + = at tests/sources/functional/choice.move:237: test_same_choice_different_args_via_schema_2 + = at tests/sources/functional/choice.move:219 + +error: post-condition does not hold + ┌─ tests/sources/functional/choice.move:302:9 + │ +302 │ ╭ ensures !(get_ballot(signer::address_of(ballot_account), result).expiration_timestamp_secs +303 │ │ <= 0); + │ ╰──────────────────^ + │ + = at tests/sources/functional/choice.move:280: create_ballot + = ballot_account = + = at tests/sources/functional/choice.move:284: create_ballot + = at tests/sources/functional/choice.move:283: create_ballot + = ballot_account = + = at tests/sources/functional/choice.move:291 + = at tests/sources/functional/choice.move:286: create_ballot + = at tests/sources/functional/choice.move:272: new_ballot_id + = counter = + = at tests/sources/functional/choice.move:275: new_ballot_id + = result = + = at tests/sources/functional/choice.move:278: new_ballot_id + = = + = at tests/sources/functional/choice.move:287: create_ballot + = ballot_id = + = at tests/sources/functional/choice.move:282: create_ballot + = result = + = at tests/sources/functional/choice.move:288: create_ballot + = at tests/sources/functional/choice.move:302: create_ballot (spec) diff --git a/third_party/move/move-prover/tests/sources/functional/consts.v2_exp b/third_party/move/move-prover/tests/sources/functional/consts.v2_exp new file mode 100644 index 0000000000000..36738b49ce085 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/consts.v2_exp @@ -0,0 +1,48 @@ +Move prover returns: exiting with verification errors +error: post-condition does not hold + ┌─ tests/sources/functional/consts.move:32:9 + │ +32 │ ensures !result.b; + │ ^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/consts.move:27: init_incorrect + = result = + = at tests/sources/functional/consts.move:28: init_incorrect + = at tests/sources/functional/consts.move:31: init_incorrect (spec) + = at tests/sources/functional/consts.move:32: init_incorrect (spec) + +error: unknown assertion failed + ┌─ tests/sources/functional/consts.move:45:13 + │ +45 │ assert BYTE_ARRAY[0] == 22; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/consts.move:45: array_1_incorrect + +error: unknown assertion failed + ┌─ tests/sources/functional/consts.move:51:13 + │ +51 │ assert ADDRESS_ARRAY[0] == @0x222; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/consts.move:51: array_2_incorrect + +error: unknown assertion failed + ┌─ tests/sources/functional/consts.move:67:13 + │ +67 │ assert v1[0] == @0x111 && v1[1] == @0x222 && v1[2] == @0x333; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/consts.move:65: array_in_fun_incorrect + = v1 = + = at tests/sources/functional/consts.move:67: array_in_fun_incorrect + +error: unknown assertion failed + ┌─ tests/sources/functional/consts.move:74:13 + │ +74 │ assert v1[0] == false && v1[1] == false && v1[2] == false; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/consts.move:72: array_in_fun_incorrect_bool + = v1 = + = at tests/sources/functional/consts.move:74: array_in_fun_incorrect_bool diff --git a/third_party/move/move-prover/tests/sources/functional/data_invariant_for_mut_ref_arg.v2_exp b/third_party/move/move-prover/tests/sources/functional/data_invariant_for_mut_ref_arg.v2_exp new file mode 100644 index 0000000000000..accf203d9c9c5 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/data_invariant_for_mut_ref_arg.v2_exp @@ -0,0 +1,51 @@ +Move prover returns: exiting with verification errors +error: data invariant does not hold + ┌─ tests/sources/functional/data_invariant_for_mut_ref_arg.move:8:9 + │ +8 │ invariant len(v) == 0; + │ ^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/data_invariant_for_mut_ref_arg.move:15: push_1 + = s = + = at tests/sources/functional/data_invariant_for_mut_ref_arg.move:17: push_1 + = at tests/sources/functional/data_invariant_for_mut_ref_arg.move:19: push_1 + = s = + = at tests/sources/functional/data_invariant_for_mut_ref_arg.move:15: push_1 + = s = + = at tests/sources/functional/data_invariant_for_mut_ref_arg.move:8 + +error: data invariant does not hold + ┌─ tests/sources/functional/data_invariant_for_mut_ref_arg.move:8:9 + │ +8 │ invariant len(v) == 0; + │ ^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/data_invariant_for_mut_ref_arg.move:22: push_2 + = s = + = at tests/sources/functional/data_invariant_for_mut_ref_arg.move:24: push_2 + = at tests/sources/functional/data_invariant_for_mut_ref_arg.move:26: push_2 + = s = + = at tests/sources/functional/data_invariant_for_mut_ref_arg.move:27: push_2 + = s = + = at tests/sources/functional/data_invariant_for_mut_ref_arg.move:28: push_2 + = at tests/sources/functional/data_invariant_for_mut_ref_arg.move:22: push_2 + = s = + = at tests/sources/functional/data_invariant_for_mut_ref_arg.move:8 + +error: data invariant does not hold + ┌─ tests/sources/functional/data_invariant_for_mut_ref_arg.move:8:9 + │ +8 │ invariant len(v) == 0; + │ ^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/data_invariant_for_mut_ref_arg.move:31: push_3 + = s = + = at tests/sources/functional/data_invariant_for_mut_ref_arg.move:33: push_3 + = at tests/sources/functional/data_invariant_for_mut_ref_arg.move:35: push_3 + = s = + = at tests/sources/functional/data_invariant_for_mut_ref_arg.move:36: push_3 + = s = + = at tests/sources/functional/data_invariant_for_mut_ref_arg.move:31: push_3 + = result = + = s = + = at tests/sources/functional/data_invariant_for_mut_ref_arg.move:8 diff --git a/third_party/move/move-prover/tests/sources/functional/data_invariant_in_map.v2_exp b/third_party/move/move-prover/tests/sources/functional/data_invariant_in_map.v2_exp new file mode 100644 index 0000000000000..9fe1cdff33742 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/data_invariant_in_map.v2_exp @@ -0,0 +1,15 @@ +Move prover returns: exiting with verification errors +error: data invariant does not hold + ┌─ tests/sources/functional/data_invariant_in_map.move:8:9 + │ +8 │ invariant value != 0; + │ ^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/data_invariant_in_map.move:20: violation_1 + = at tests/sources/functional/data_invariant_in_map.move:21: violation_1 + = t = + = at tests/sources/functional/data_invariant_in_map.move:22: violation_1 + = = + = s = + = at tests/sources/functional/data_invariant_in_map.move:23: violation_1 + = at tests/sources/functional/data_invariant_in_map.move:8 diff --git a/third_party/move/move-prover/tests/sources/functional/disable_inv.v2_exp b/third_party/move/move-prover/tests/sources/functional/disable_inv.v2_exp new file mode 100644 index 0000000000000..c2ab669acfb0b --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/disable_inv.v2_exp @@ -0,0 +1,29 @@ +Move prover returns: exiting with bytecode transformation errors +error: Public or script functions cannot delegate invariants + ┌─ tests/sources/functional/disable_inv.move:13:5 + │ +13 │ ╭ public fun f1_incorrect(s: &signer) { +14 │ │ move_to(s, R1 {}); +15 │ │ move_to(s, R2 {}); +16 │ │ } + │ ╰─────^ + +error: Functions must not have `pragma disable_invariants_in_body` when invariant checking is turned-off on this function + ┌─ tests/sources/functional/disable_inv.move:34:5 + │ +34 │ ╭ fun f3_incorrect(s: &signer) { +35 │ │ move_to(s, R1 {}); +36 │ │ } + │ ╰─────^ + │ + = disabled by DisableInv::f3_incorrect <- DisableInv::f2 + +error: Functions must not have `pragma disable_invariants_in_body` when invariant checking is turned-off on this function + ┌─ tests/sources/functional/disable_inv.move:50:5 + │ +50 │ ╭ fun f5_incorrect(s: &signer) { +51 │ │ move_to(s, R2 {}); +52 │ │ } + │ ╰─────^ + │ + = disabled by DisableInv::f5_incorrect <- DisableInv::f4 <- DisableInv::f2 diff --git a/third_party/move/move-prover/tests/sources/functional/disable_inv_friends.v2_exp b/third_party/move/move-prover/tests/sources/functional/disable_inv_friends.v2_exp new file mode 100644 index 0000000000000..c5f78409de3a6 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/disable_inv_friends.v2_exp @@ -0,0 +1,15 @@ +Move prover returns: exiting with verification errors +error: global memory invariant does not hold + ┌─ tests/sources/functional/disable_inv_friends.move:25:10 + │ +25 │ invariant [global, suspendable] forall addr: address: exists(addr) <==> exists(addr); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/disable_inv_friends.move:85: f5_incorrect + = at tests/sources/functional/disable_inv_friends.move:91: f5_incorrect (spec) + = at tests/sources/functional/disable_inv_friends.move:92: f5_incorrect (spec) + = at tests/sources/functional/disable_inv_friends.move:85: f5_incorrect + = s = + = at tests/sources/functional/disable_inv_friends.move:86: f5_incorrect + = s = + = at tests/sources/functional/disable_inv_friends.move:25 diff --git a/third_party/move/move-prover/tests/sources/functional/disable_inv_indirect.v2_exp b/third_party/move/move-prover/tests/sources/functional/disable_inv_indirect.v2_exp new file mode 100644 index 0000000000000..ec9176faad884 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/disable_inv_indirect.v2_exp @@ -0,0 +1,20 @@ +Move prover returns: exiting with bytecode transformation errors +error: Public or script functions cannot be transitively called by functions disabling or delegating invariants + ┌─ tests/sources/functional/disable_inv_indirect.move:6:5 + │ +6 │ ╭ public fun f1(s: &signer) { +7 │ │ move_to(s, R {v: 1}); +8 │ │ } + │ ╰─────^ + │ + = disabled by M1::f1 <- M1::f2 <- M1::f_disabled + +error: Public or script functions cannot be transitively called by functions disabling or delegating invariants + ┌─ tests/sources/functional/disable_inv_indirect.move:10:5 + │ +10 │ ╭ public fun f2(s: &signer) { +11 │ │ f1(s); +12 │ │ } + │ ╰─────^ + │ + = disabled by M1::f2 <- M1::f_disabled diff --git a/third_party/move/move-prover/tests/sources/functional/duplicate_function_declarations.v2_exp b/third_party/move/move-prover/tests/sources/functional/duplicate_function_declarations.v2_exp new file mode 100644 index 0000000000000..72a4557bcc0fd --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/duplicate_function_declarations.v2_exp @@ -0,0 +1,8 @@ +Move prover returns: exiting with checking errors +error: name clash between specification and Move function `double` + ┌─ tests/sources/functional/duplicate_function_declarations.move:5:9 + │ +5 │ ╭ fun double(x: u8): u8 { +6 │ │ x * 2 +7 │ │ } + │ ╰─────────^ diff --git a/third_party/move/move-prover/tests/sources/functional/emits.v2_exp b/third_party/move/move-prover/tests/sources/functional/emits.v2_exp new file mode 100644 index 0000000000000..392584382ca2b --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/emits.v2_exp @@ -0,0 +1,266 @@ +Move prover returns: exiting with verification errors +error: function does not emit the expected event + ┌─ tests/sources/functional/emits.move:23:9 + │ +23 │ emits DummyEvent{msg: 1} to handle; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/emits.move:19: simple_wrong_msg_incorrect + = handle = + = at tests/sources/functional/emits.move:20: simple_wrong_msg_incorrect + = handle = + = at tests/sources/functional/emits.move:19: simple_wrong_msg_incorrect + = handle = + = at tests/sources/functional/emits.move:21: simple_wrong_msg_incorrect + = at tests/sources/functional/emits.move:23: simple_wrong_msg_incorrect (spec) + +error: function does not emit the expected event + ┌─ tests/sources/functional/emits.move:30:9 + │ +30 │ emits DummyEvent{msg: 0} to _handle2; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/emits.move:26: simple_wrong_handle_incorrect + = handle = + = _handle2 = + = at tests/sources/functional/emits.move:27: simple_wrong_handle_incorrect + = handle = + = at tests/sources/functional/emits.move:26: simple_wrong_handle_incorrect + = handle = + = _handle2 = + = at tests/sources/functional/emits.move:28: simple_wrong_handle_incorrect + = at tests/sources/functional/emits.move:30: simple_wrong_handle_incorrect (spec) + +error: function does not emit the expected event + ┌─ tests/sources/functional/emits.move:54:9 + │ +54 │ emits DummyEvent{msg: 2} to handle; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/emits.move:47: multiple_incorrect + = handle = + = at tests/sources/functional/emits.move:48: multiple_incorrect + = handle = + = = + = at tests/sources/functional/emits.move:49: multiple_incorrect + = = + = at tests/sources/functional/emits.move:47: multiple_incorrect + = handle = + = at tests/sources/functional/emits.move:50: multiple_incorrect + = at tests/sources/functional/emits.move:52: multiple_incorrect (spec) + = at tests/sources/functional/emits.move:53: multiple_incorrect (spec) + = at tests/sources/functional/emits.move:54: multiple_incorrect (spec) + +error: function does not emit the expected event + ┌─ tests/sources/functional/emits.move:71:9 + │ +71 │ emits DummyEvent{msg: 0} to handle; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/emits.move:66: multiple_same_incorrect + = handle = + = at tests/sources/functional/emits.move:67: multiple_same_incorrect + = handle = + = at tests/sources/functional/emits.move:66: multiple_same_incorrect + = handle = + = at tests/sources/functional/emits.move:68: multiple_same_incorrect + = at tests/sources/functional/emits.move:70: multiple_same_incorrect (spec) + = at tests/sources/functional/emits.move:71: multiple_same_incorrect (spec) + +error: function does not emit the expected event + ┌─ tests/sources/functional/emits.move:111:9 + │ +111 │ emits DummyEvent{msg: 0} to handle if x > 0; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/emits.move:105: conditional_wrong_condition_incorrect + = x = + = handle = + = at tests/sources/functional/emits.move:106: conditional_wrong_condition_incorrect + = x = + = at tests/sources/functional/emits.move:106: conditional_wrong_condition_incorrect + = handle = + = at tests/sources/functional/emits.move:109: conditional_wrong_condition_incorrect + = at tests/sources/functional/emits.move:111: conditional_wrong_condition_incorrect (spec) + +error: function does not emit the expected event + ┌─ tests/sources/functional/emits.move:120:9 + │ +120 │ emits DummyEvent{msg: 0} to handle; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/emits.move:114: conditional_missing_condition_incorrect + = x = + = handle = + = at tests/sources/functional/emits.move:115: conditional_missing_condition_incorrect + = x = + = at tests/sources/functional/emits.move:115: conditional_missing_condition_incorrect + = handle = + = at tests/sources/functional/emits.move:118: conditional_missing_condition_incorrect + = at tests/sources/functional/emits.move:120: conditional_missing_condition_incorrect (spec) + +error: function does not emit the expected event + ┌─ tests/sources/functional/emits.move:159:9 + │ +159 │ emits DummyEvent{msg: 2} to handle; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/emits.move:149: conditional_multiple_incorrect + = b = + = handle = + = at tests/sources/functional/emits.move:150: conditional_multiple_incorrect + = b = + = handle = + = at tests/sources/functional/emits.move:151: conditional_multiple_incorrect + = = + = at tests/sources/functional/emits.move:152: conditional_multiple_incorrect + = at tests/sources/functional/emits.move:149: conditional_multiple_incorrect + = handle = + = at tests/sources/functional/emits.move:155: conditional_multiple_incorrect + = at tests/sources/functional/emits.move:157: conditional_multiple_incorrect (spec) + = at tests/sources/functional/emits.move:158: conditional_multiple_incorrect (spec) + = at tests/sources/functional/emits.move:159: conditional_multiple_incorrect (spec) + +error: function does not emit the expected event + ┌─ tests/sources/functional/emits.move:189:9 + │ +189 │ emits DummyEvent{msg: 0} to handle; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/emits.move:179: conditional_multiple_same_incorrect + = b = + = handle = + = at tests/sources/functional/emits.move:180: conditional_multiple_same_incorrect + = b = + = handle = + = at tests/sources/functional/emits.move:181: conditional_multiple_same_incorrect + = = + = at tests/sources/functional/emits.move:182: conditional_multiple_same_incorrect + = at tests/sources/functional/emits.move:179: conditional_multiple_same_incorrect + = handle = + = at tests/sources/functional/emits.move:185: conditional_multiple_same_incorrect + = at tests/sources/functional/emits.move:187: conditional_multiple_same_incorrect (spec) + = at tests/sources/functional/emits.move:188: conditional_multiple_same_incorrect (spec) + = at tests/sources/functional/emits.move:189: conditional_multiple_same_incorrect (spec) + +error: emitted event not covered by any of the `emits` clauses + ┌─ tests/sources/functional/emits.move:235:5 + │ +235 │ ╭ spec partial_incorrect { +236 │ │ emits DummyEvent{msg: 0} to handle; +237 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/emits.move:231: partial_incorrect + = handle = + = at tests/sources/functional/emits.move:232: partial_incorrect + = handle = + = = + = at tests/sources/functional/emits.move:233: partial_incorrect + = = + = at tests/sources/functional/emits.move:231: partial_incorrect + = handle = + = at tests/sources/functional/emits.move:234: partial_incorrect + = at tests/sources/functional/emits.move:236: partial_incorrect (spec) + = at tests/sources/functional/emits.move:235: partial_incorrect (spec) + +error: emitted event not covered by any of the `emits` clauses + ┌─ tests/sources/functional/emits.move:255:5 + │ +255 │ ╭ spec strict_incorrect { +256 │ │ pragma emits_is_strict; +257 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/emits.move:251: strict_incorrect + = handle = + = at tests/sources/functional/emits.move:252: strict_incorrect + = handle = + = = + = at tests/sources/functional/emits.move:253: strict_incorrect + = = + = at tests/sources/functional/emits.move:251: strict_incorrect + = handle = + = at tests/sources/functional/emits.move:254: strict_incorrect + = at tests/sources/functional/emits.move:255: strict_incorrect (spec) + +error: function does not emit the expected event + ┌─ tests/sources/functional/emits.move:296:9 + │ +296 │ emits DummyEvent{msg: 2} to handle; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/emits.move:286: opaque_incorrect + = handle = + = at tests/sources/functional/emits.move:287: opaque_incorrect + = handle = + = = + = at tests/sources/functional/emits.move:288: opaque_incorrect + = = + = at tests/sources/functional/emits.move:289: opaque_incorrect + = = + = at tests/sources/functional/emits.move:286: opaque_incorrect + = handle = + = at tests/sources/functional/emits.move:290: opaque_incorrect + = at tests/sources/functional/emits.move:292: opaque_incorrect (spec) + = at tests/sources/functional/emits.move:293: opaque_incorrect (spec) + = at tests/sources/functional/emits.move:294: opaque_incorrect (spec) + = at tests/sources/functional/emits.move:295: opaque_incorrect (spec) + = at tests/sources/functional/emits.move:296: opaque_incorrect (spec) + +error: emitted event not covered by any of the `emits` clauses + ┌─ tests/sources/functional/emits.move:314:5 + │ +314 │ ╭ spec opaque_completeness_incorrect { +315 │ │ emits DummyEvent{msg: 0} to handle; +316 │ │ emits DummyEvent{msg: 7} to handle; +317 │ │ emits DummyEvent{msg: 1} to handle; +318 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/emits.move:309: opaque_completeness_incorrect + = handle = + = at tests/sources/functional/emits.move:310: opaque_completeness_incorrect + = handle = + = = + = at tests/sources/functional/emits.move:311: opaque_completeness_incorrect + = = + = at tests/sources/functional/emits.move:312: opaque_completeness_incorrect + = = + = at tests/sources/functional/emits.move:309: opaque_completeness_incorrect + = handle = + = at tests/sources/functional/emits.move:313: opaque_completeness_incorrect + = at tests/sources/functional/emits.move:315: opaque_completeness_incorrect (spec) + = at tests/sources/functional/emits.move:316: opaque_completeness_incorrect (spec) + = at tests/sources/functional/emits.move:317: opaque_completeness_incorrect (spec) + = at tests/sources/functional/emits.move:314: opaque_completeness_incorrect (spec) + +error: emitted event not covered by any of the `emits` clauses + ┌─ tests/sources/functional/emits.move:355:5 + │ +355 │ ╭ spec opaque_partial_incorrect { +356 │ │ emits DummyEvent{msg: 0} to handle; +357 │ │ emits DummyEvent{msg: 7} to handle; +358 │ │ emits DummyEvent{msg: 77} to handle; +359 │ │ emits DummyEvent{msg: 1} to handle; +360 │ │ // The completeness check of the `emits` spec of this function should fail. +361 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/emits.move:350: opaque_partial_incorrect + = handle = + = at tests/sources/functional/emits.move:351: opaque_partial_incorrect + = handle = + = = + = at tests/sources/functional/emits.move:352: opaque_partial_incorrect + = = + = at tests/sources/functional/emits.move:353: opaque_partial_incorrect + = = + = at tests/sources/functional/emits.move:350: opaque_partial_incorrect + = handle = + = at tests/sources/functional/emits.move:354: opaque_partial_incorrect + = at tests/sources/functional/emits.move:356: opaque_partial_incorrect (spec) + = at tests/sources/functional/emits.move:357: opaque_partial_incorrect (spec) + = at tests/sources/functional/emits.move:358: opaque_partial_incorrect (spec) + = at tests/sources/functional/emits.move:359: opaque_partial_incorrect (spec) + = at tests/sources/functional/emits.move:355: opaque_partial_incorrect (spec) diff --git a/third_party/move/move-prover/tests/sources/functional/fixed_point_arithm.v2_exp b/third_party/move/move-prover/tests/sources/functional/fixed_point_arithm.v2_exp new file mode 100644 index 0000000000000..5d5c1903c37af --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/fixed_point_arithm.v2_exp @@ -0,0 +1,156 @@ +Move prover returns: exiting with verification errors +error: post-condition does not hold + ┌─ tests/sources/functional/fixed_point_arithm.move:31:9 + │ +31 │ ensures result == 1; // disproved + │ ^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/fixed_point_arithm.move:26: multiply_0_x_incorrect + = x = + = at tests/sources/functional/fixed_point_arithm.move:27: multiply_0_x_incorrect + = result = + = at tests/sources/functional/fixed_point_arithm.move:28: multiply_0_x_incorrect + = at tests/sources/functional/fixed_point_arithm.move:30: multiply_0_x_incorrect (spec) + = at tests/sources/functional/fixed_point_arithm.move:31: multiply_0_x_incorrect (spec) + +error: post-condition does not hold + ┌─ tests/sources/functional/fixed_point_arithm.move:47:9 + │ +47 │ ensures result == 1; // disproved + │ ^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/fixed_point_arithm.move:42: multiply_x_0_incorrect + = x = + = at tests/sources/functional/fixed_point_arithm.move:43: multiply_x_0_incorrect + = x = + = = + = at tests/sources/functional/fixed_point_arithm.move:43: multiply_x_0_incorrect + = result = + = at tests/sources/functional/fixed_point_arithm.move:44: multiply_x_0_incorrect + = at tests/sources/functional/fixed_point_arithm.move:46: multiply_x_0_incorrect (spec) + = at tests/sources/functional/fixed_point_arithm.move:47: multiply_x_0_incorrect (spec) + +error: post-condition does not hold + ┌─ tests/sources/functional/fixed_point_arithm.move:70:9 + │ +70 │ ensures result != (x.value >> 32); // disproved + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/fixed_point_arithm.move:64: multiply_1_x_incorrect + = x = + = at tests/sources/functional/fixed_point_arithm.move:65: multiply_1_x_incorrect + = result = + = at tests/sources/functional/fixed_point_arithm.move:66: multiply_1_x_incorrect + = at tests/sources/functional/fixed_point_arithm.move:68: multiply_1_x_incorrect (spec) + = at tests/sources/functional/fixed_point_arithm.move:70: multiply_1_x_incorrect (spec) + +error: post-condition does not hold + ┌─ tests/sources/functional/fixed_point_arithm.move:86:9 + │ +86 │ ensures result != x; // disproved + │ ^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/fixed_point_arithm.move:81: multiply_x_1_incorrect + = x = + = at tests/sources/functional/fixed_point_arithm.move:82: multiply_x_1_incorrect + = x = + = at ../move-stdlib/sources/fixed_point32.move:125 + = at ../move-stdlib/sources/fixed_point32.move:126 + = at ../move-stdlib/sources/fixed_point32.move:127 + = at tests/sources/functional/fixed_point_arithm.move:82: multiply_x_1_incorrect + = = + = at tests/sources/functional/fixed_point_arithm.move:82: multiply_x_1_incorrect + = result = + = at tests/sources/functional/fixed_point_arithm.move:83: multiply_x_1_incorrect + = at tests/sources/functional/fixed_point_arithm.move:85: multiply_x_1_incorrect (spec) + = at tests/sources/functional/fixed_point_arithm.move:86: multiply_x_1_incorrect (spec) + +error: post-condition does not hold + ┌─ tests/sources/functional/fixed_point_arithm.move:110:9 + │ +110 │ ensures result >= x; // disproved + │ ^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/fixed_point_arithm.move:104: mul_div_incorrect + = x = + = y = + = at tests/sources/functional/fixed_point_arithm.move:105: mul_div_incorrect + = at ../move-stdlib/sources/fixed_point32.move:149: get_raw_value + = num = + = at ../move-stdlib/sources/fixed_point32.move:150: get_raw_value + = result = + = at ../move-stdlib/sources/fixed_point32.move:151: get_raw_value + = x = + = at tests/sources/functional/fixed_point_arithm.move:106: mul_div_incorrect + = y = + = y_raw_val = + = at tests/sources/functional/fixed_point_arithm.move:106: mul_div_incorrect + = = + = at tests/sources/functional/fixed_point_arithm.move:107: mul_div_incorrect + = = + = z = + = at tests/sources/functional/fixed_point_arithm.move:107: mul_div_incorrect + = result = + = at tests/sources/functional/fixed_point_arithm.move:108: mul_div_incorrect + = at tests/sources/functional/fixed_point_arithm.move:110: mul_div_incorrect (spec) + +error: post-condition does not hold + ┌─ tests/sources/functional/fixed_point_arithm.move:112:9 + │ +112 │ ensures result < x; // disproved + │ ^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/fixed_point_arithm.move:104: mul_div_incorrect + = x = + = y = + = at tests/sources/functional/fixed_point_arithm.move:105: mul_div_incorrect + = at ../move-stdlib/sources/fixed_point32.move:149: get_raw_value + = num = + = at ../move-stdlib/sources/fixed_point32.move:150: get_raw_value + = result = + = at ../move-stdlib/sources/fixed_point32.move:151: get_raw_value + = x = + = at tests/sources/functional/fixed_point_arithm.move:106: mul_div_incorrect + = y = + = y_raw_val = + = at tests/sources/functional/fixed_point_arithm.move:106: mul_div_incorrect + = = + = at tests/sources/functional/fixed_point_arithm.move:107: mul_div_incorrect + = = + = z = + = at tests/sources/functional/fixed_point_arithm.move:107: mul_div_incorrect + = result = + = at tests/sources/functional/fixed_point_arithm.move:108: mul_div_incorrect + = at tests/sources/functional/fixed_point_arithm.move:110: mul_div_incorrect (spec) + = at tests/sources/functional/fixed_point_arithm.move:112: mul_div_incorrect (spec) + +error: post-condition does not hold + ┌─ tests/sources/functional/fixed_point_arithm.move:144:9 + │ +144 │ ensures result != 10; + │ ^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/fixed_point_arithm.move:139: mul_2_times_incorrect + = a = + = b = + = c = + = at tests/sources/functional/fixed_point_arithm.move:140: mul_2_times_incorrect + = result = + = at tests/sources/functional/fixed_point_arithm.move:141: mul_2_times_incorrect + = at tests/sources/functional/fixed_point_arithm.move:144: mul_2_times_incorrect (spec) + +error: post-condition does not hold + ┌─ tests/sources/functional/fixed_point_arithm.move:152:9 + │ +152 │ ensures result != 10; + │ ^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/fixed_point_arithm.move:147: mul_3_times_incorrect + = a = + = b = + = c = + = d = + = at tests/sources/functional/fixed_point_arithm.move:148: mul_3_times_incorrect + = result = + = at tests/sources/functional/fixed_point_arithm.move:149: mul_3_times_incorrect + = at tests/sources/functional/fixed_point_arithm.move:152: mul_3_times_incorrect (spec) diff --git a/third_party/move/move-prover/tests/sources/functional/generic_invariants.v2_exp b/third_party/move/move-prover/tests/sources/functional/generic_invariants.v2_exp new file mode 100644 index 0000000000000..cb1da9ff106cb --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/generic_invariants.v2_exp @@ -0,0 +1,280 @@ +Move prover returns: exiting with verification errors +error: global memory invariant does not hold + ┌─ tests/sources/functional/generic_invariants.move:34:5 + │ +34 │ ╭ invariant +35 │ │ exists>(@0x22) +36 │ │ ==> global>(@0x22).x == 1; + │ ╰────────────────────────────────────────────────────────────^ + │ + = at tests/sources/functional/generic_invariants.move:10: publish_u64_bool + = account = + = x = + = y = + = at tests/sources/functional/generic_invariants.move:11: publish_u64_bool + = account = + = at tests/sources/functional/generic_invariants.move:34 + +error: global memory invariant does not hold + ┌─ tests/sources/functional/generic_invariants.move:34:5 + │ +34 │ ╭ invariant +35 │ │ exists>(@0x22) +36 │ │ ==> global>(@0x22).x == 1; + │ ╰────────────────────────────────────────────────────────────^ + │ + = at tests/sources/functional/generic_invariants.move:15: publish_u64_y + = account = + = x = + = y = + = at tests/sources/functional/generic_invariants.move:16: publish_u64_y + = account = + = at tests/sources/functional/generic_invariants.move:34 + +error: global memory invariant does not hold + ┌─ tests/sources/functional/generic_invariants.move:34:5 + │ +34 │ ╭ invariant +35 │ │ exists>(@0x22) +36 │ │ ==> global>(@0x22).x == 1; + │ ╰────────────────────────────────────────────────────────────^ + │ + = at tests/sources/functional/generic_invariants.move:20: publish_x_bool + = account = + = x = + = y = + = at tests/sources/functional/generic_invariants.move:21: publish_x_bool + = account = + = at tests/sources/functional/generic_invariants.move:34 + +error: global memory invariant does not hold + ┌─ tests/sources/functional/generic_invariants.move:34:5 + │ +34 │ ╭ invariant +35 │ │ exists>(@0x22) +36 │ │ ==> global>(@0x22).x == 1; + │ ╰────────────────────────────────────────────────────────────^ + │ + = at tests/sources/functional/generic_invariants.move:25: publish_x_y + = account = + = x = + = y = + = at tests/sources/functional/generic_invariants.move:26: publish_x_y + = account = + = at tests/sources/functional/generic_invariants.move:34 + +error: global memory invariant does not hold + ┌─ tests/sources/functional/generic_invariants.move:39:5 + │ +39 │ ╭ invariant +40 │ │ exists>(@0x23) +41 │ │ ==> global>(@0x23).x > 0; + │ ╰────────────────────────────────────────────────────────^ + │ + = at tests/sources/functional/generic_invariants.move:10: publish_u64_bool + = account = + = x = + = y = + = at tests/sources/functional/generic_invariants.move:11: publish_u64_bool + = account = + = at tests/sources/functional/generic_invariants.move:34 + = at tests/sources/functional/generic_invariants.move:39 + +error: global memory invariant does not hold + ┌─ tests/sources/functional/generic_invariants.move:39:5 + │ +39 │ ╭ invariant +40 │ │ exists>(@0x23) +41 │ │ ==> global>(@0x23).x > 0; + │ ╰────────────────────────────────────────────────────────^ + │ + = at tests/sources/functional/generic_invariants.move:15: publish_u64_y + = account = + = x = + = y = + = at tests/sources/functional/generic_invariants.move:16: publish_u64_y + = account = + = at tests/sources/functional/generic_invariants.move:34 + = at tests/sources/functional/generic_invariants.move:39 + +error: global memory invariant does not hold + ┌─ tests/sources/functional/generic_invariants.move:39:5 + │ +39 │ ╭ invariant +40 │ │ exists>(@0x23) +41 │ │ ==> global>(@0x23).x > 0; + │ ╰────────────────────────────────────────────────────────^ + │ + = at tests/sources/functional/generic_invariants.move:20: publish_x_bool + = account = + = x = + = y = + = at tests/sources/functional/generic_invariants.move:21: publish_x_bool + = account = + = at tests/sources/functional/generic_invariants.move:34 + = at tests/sources/functional/generic_invariants.move:39 + +error: global memory invariant does not hold + ┌─ tests/sources/functional/generic_invariants.move:39:5 + │ +39 │ ╭ invariant +40 │ │ exists>(@0x23) +41 │ │ ==> global>(@0x23).x > 0; + │ ╰────────────────────────────────────────────────────────^ + │ + = at tests/sources/functional/generic_invariants.move:25: publish_x_y + = account = + = x = + = y = + = at tests/sources/functional/generic_invariants.move:26: publish_x_y + = account = + = at tests/sources/functional/generic_invariants.move:34 + = at tests/sources/functional/generic_invariants.move:39 + +error: global memory invariant does not hold + ┌─ tests/sources/functional/generic_invariants.move:44:5 + │ +44 │ ╭ invariant +45 │ │ exists>(@0x24) +46 │ │ ==> global>(@0x24).y; + │ ╰─────────────────────────────────────────────────────^ + │ + = at tests/sources/functional/generic_invariants.move:10: publish_u64_bool + = account = + = x = + = y = + = at tests/sources/functional/generic_invariants.move:11: publish_u64_bool + = account = + = at tests/sources/functional/generic_invariants.move:34 + = at tests/sources/functional/generic_invariants.move:39 + = at tests/sources/functional/generic_invariants.move:44 + +error: global memory invariant does not hold + ┌─ tests/sources/functional/generic_invariants.move:44:5 + │ +44 │ ╭ invariant +45 │ │ exists>(@0x24) +46 │ │ ==> global>(@0x24).y; + │ ╰─────────────────────────────────────────────────────^ + │ + = at tests/sources/functional/generic_invariants.move:15: publish_u64_y + = account = + = x = + = y = + = at tests/sources/functional/generic_invariants.move:16: publish_u64_y + = account = + = at tests/sources/functional/generic_invariants.move:34 + = at tests/sources/functional/generic_invariants.move:39 + = at tests/sources/functional/generic_invariants.move:44 + +error: global memory invariant does not hold + ┌─ tests/sources/functional/generic_invariants.move:44:5 + │ +44 │ ╭ invariant +45 │ │ exists>(@0x24) +46 │ │ ==> global>(@0x24).y; + │ ╰─────────────────────────────────────────────────────^ + │ + = at tests/sources/functional/generic_invariants.move:20: publish_x_bool + = account = + = x = + = y = + = at tests/sources/functional/generic_invariants.move:21: publish_x_bool + = account = + = at tests/sources/functional/generic_invariants.move:34 + = at tests/sources/functional/generic_invariants.move:39 + = at tests/sources/functional/generic_invariants.move:44 + +error: global memory invariant does not hold + ┌─ tests/sources/functional/generic_invariants.move:44:5 + │ +44 │ ╭ invariant +45 │ │ exists>(@0x24) +46 │ │ ==> global>(@0x24).y; + │ ╰─────────────────────────────────────────────────────^ + │ + = at tests/sources/functional/generic_invariants.move:25: publish_x_y + = account = + = x = + = y = + = at tests/sources/functional/generic_invariants.move:26: publish_x_y + = account = + = at tests/sources/functional/generic_invariants.move:34 + = at tests/sources/functional/generic_invariants.move:39 + = at tests/sources/functional/generic_invariants.move:44 + +error: global memory invariant does not hold + ┌─ tests/sources/functional/generic_invariants.move:49:5 + │ +49 │ ╭ invariant +50 │ │ (exists>(@0x25) && exists>(@0x26)) +51 │ │ ==> global>(@0x25) == global>(@0x26); + │ ╰───────────────────────────────────────────────────────────────────────────────────^ + │ + = at tests/sources/functional/generic_invariants.move:10: publish_u64_bool + = account = + = x = + = y = + = at tests/sources/functional/generic_invariants.move:11: publish_u64_bool + = account = + = at tests/sources/functional/generic_invariants.move:34 + = at tests/sources/functional/generic_invariants.move:39 + = at tests/sources/functional/generic_invariants.move:44 + = at tests/sources/functional/generic_invariants.move:49 + +error: global memory invariant does not hold + ┌─ tests/sources/functional/generic_invariants.move:49:5 + │ +49 │ ╭ invariant +50 │ │ (exists>(@0x25) && exists>(@0x26)) +51 │ │ ==> global>(@0x25) == global>(@0x26); + │ ╰───────────────────────────────────────────────────────────────────────────────────^ + │ + = at tests/sources/functional/generic_invariants.move:15: publish_u64_y + = account = + = x = + = y = + = at tests/sources/functional/generic_invariants.move:16: publish_u64_y + = account = + = at tests/sources/functional/generic_invariants.move:34 + = at tests/sources/functional/generic_invariants.move:39 + = at tests/sources/functional/generic_invariants.move:44 + = at tests/sources/functional/generic_invariants.move:49 + +error: global memory invariant does not hold + ┌─ tests/sources/functional/generic_invariants.move:49:5 + │ +49 │ ╭ invariant +50 │ │ (exists>(@0x25) && exists>(@0x26)) +51 │ │ ==> global>(@0x25) == global>(@0x26); + │ ╰───────────────────────────────────────────────────────────────────────────────────^ + │ + = at tests/sources/functional/generic_invariants.move:20: publish_x_bool + = account = + = x = + = y = + = at tests/sources/functional/generic_invariants.move:21: publish_x_bool + = account = + = at tests/sources/functional/generic_invariants.move:34 + = at tests/sources/functional/generic_invariants.move:39 + = at tests/sources/functional/generic_invariants.move:44 + = at tests/sources/functional/generic_invariants.move:49 + +error: global memory invariant does not hold + ┌─ tests/sources/functional/generic_invariants.move:49:5 + │ +49 │ ╭ invariant +50 │ │ (exists>(@0x25) && exists>(@0x26)) +51 │ │ ==> global>(@0x25) == global>(@0x26); + │ ╰───────────────────────────────────────────────────────────────────────────────────^ + │ + = at tests/sources/functional/generic_invariants.move:25: publish_x_y + = account = + = x = + = y = + = at tests/sources/functional/generic_invariants.move:26: publish_x_y + = account = + = at tests/sources/functional/generic_invariants.move:34 + = at tests/sources/functional/generic_invariants.move:39 + = at tests/sources/functional/generic_invariants.move:44 + = at tests/sources/functional/generic_invariants.move:49 diff --git a/third_party/move/move-prover/tests/sources/functional/global_invariants.v2_exp b/third_party/move/move-prover/tests/sources/functional/global_invariants.v2_exp new file mode 100644 index 0000000000000..732c46881ea71 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/global_invariants.v2_exp @@ -0,0 +1,65 @@ +Move prover returns: exiting with verification errors +error: global memory invariant does not hold + ┌─ tests/sources/functional/global_invariants.move:18:9 + │ +18 │ invariant [global] forall a: address where exists(a): exists(a); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/global_invariants.move:38: create_R_invalid + = account = + = at tests/sources/functional/global_invariants.move:40: create_R_invalid + = account = + = at tests/sources/functional/global_invariants.move:38: create_R_invalid + = at tests/sources/functional/global_invariants.move:40: create_R_invalid + = at tests/sources/functional/global_invariants.move:18 + +error: global memory invariant does not hold + ┌─ tests/sources/functional/global_invariants.move:18:9 + │ +18 │ invariant [global] forall a: address where exists(a): exists(a); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/global_invariants.move:53: remove_S_invalid + = account = + = at tests/sources/functional/global_invariants.move:55: remove_S_invalid + = account = + = at ../move-stdlib/sources/signer.move:12: address_of + = s = + = at ../move-stdlib/sources/signer.move:13: address_of + = result = + = at ../move-stdlib/sources/signer.move:14: address_of + = at tests/sources/functional/global_invariants.move:55: remove_S_invalid + = at tests/sources/functional/global_invariants.move:56: remove_S_invalid + = at ../move-stdlib/sources/signer.move:12: address_of + = s = + = at ../move-stdlib/sources/signer.move:13: address_of + = result = + = at ../move-stdlib/sources/signer.move:14: address_of + = at tests/sources/functional/global_invariants.move:18 + +error: global memory invariant does not hold + ┌─ tests/sources/functional/global_invariants.move:20:9 + │ +20 │ invariant update [global] forall a: address where old(exists_R(a)): exists(a); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/global_invariants.move:62: remove_R_invalid + = account = + = at tests/sources/functional/global_invariants.move:64: remove_R_invalid + = account = + = at ../move-stdlib/sources/signer.move:12: address_of + = s = + = at ../move-stdlib/sources/signer.move:13: address_of + = result = + = at ../move-stdlib/sources/signer.move:14: address_of + = at tests/sources/functional/global_invariants.move:64: remove_R_invalid + = at tests/sources/functional/global_invariants.move:65: remove_R_invalid + = at ../move-stdlib/sources/signer.move:12: address_of + = s = + = at ../move-stdlib/sources/signer.move:13: address_of + = result = + = at ../move-stdlib/sources/signer.move:14: address_of + = at tests/sources/functional/global_invariants.move:62: remove_R_invalid + = at tests/sources/functional/global_invariants.move:65: remove_R_invalid + = at tests/sources/functional/global_invariants.move:18 + = at tests/sources/functional/global_invariants.move:20 diff --git a/third_party/move/move-prover/tests/sources/functional/global_vars.v2_exp b/third_party/move/move-prover/tests/sources/functional/global_vars.v2_exp new file mode 100644 index 0000000000000..45a0535e03fb1 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/global_vars.v2_exp @@ -0,0 +1,79 @@ +Move prover returns: exiting with verification errors +error: post-condition does not hold + ┌─ tests/sources/functional/global_vars.move:120:9 + │ +120 │ ensures sum_of_T2 == 2; + │ ^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/global_vars.move:116: opaque_call_add_sub_invalid + = at tests/sources/functional/global_vars.move:117: opaque_call_add_sub_invalid + = at tests/sources/functional/global_vars.move:96: opaque_add (spec) + = at tests/sources/functional/global_vars.move:117: opaque_call_add_sub_invalid + = at tests/sources/functional/global_vars.move:106: opaque_sub (spec) + = at tests/sources/functional/global_vars.move:117: opaque_call_add_sub_invalid + = at tests/sources/functional/global_vars.move:96: opaque_add (spec) + = at tests/sources/functional/global_vars.move:118: opaque_call_add_sub_invalid + = at tests/sources/functional/global_vars.move:120: opaque_call_add_sub_invalid (spec) + +error: precondition does not hold at this call + ┌─ tests/sources/functional/global_vars.move:145:9 + │ +145 │ requires access_verified; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/global_vars.move:153: do_privileged_invalid + = _s = + = at tests/sources/functional/global_vars.move:145: requires_access (spec) + +error: post-condition does not hold + ┌─ tests/sources/functional/global_vars.move:181:9 + │ +181 │ ensures type_has_property; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/global_vars.move:177: expect_property_of_u64_invalid + = at tests/sources/functional/global_vars.move:178: expect_property_of_u64_invalid + = at tests/sources/functional/global_vars.move:165: give_property_to + = at tests/sources/functional/global_vars.move:167: give_property_to (spec) + = at tests/sources/functional/global_vars.move:179: expect_property_of_u64_invalid + = at tests/sources/functional/global_vars.move:181: expect_property_of_u64_invalid (spec) + +error: post-condition does not hold + ┌─ tests/sources/functional/global_vars.move:205:9 + │ +205 │ ensures type_has_property; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/global_vars.move:201: opaque_expect_property_of_u64_invalid + = at tests/sources/functional/global_vars.move:202: opaque_expect_property_of_u64_invalid + = at tests/sources/functional/global_vars.move:191: opaque_give_property_to (spec) + = at tests/sources/functional/global_vars.move:203: opaque_expect_property_of_u64_invalid + = at tests/sources/functional/global_vars.move:205: opaque_expect_property_of_u64_invalid (spec) + +error: global memory invariant does not hold + ┌─ tests/sources/functional/global_vars.move:218:5 + │ +218 │ invariant global(@0).v <= limit; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/global_vars.move:228: limit_change_invalid + = s = + = at tests/sources/functional/global_vars.move:229: limit_change_invalid + = at tests/sources/functional/global_vars.move:220: publish + = s = + = at tests/sources/functional/global_vars.move:221: publish + = s = + = at tests/sources/functional/global_vars.move:222: publish + = at tests/sources/functional/global_vars.move:230: limit_change_invalid + = at tests/sources/functional/global_vars.move:232: limit_change_invalid (spec) + = at tests/sources/functional/global_vars.move:218 + +error: global memory invariant does not hold + ┌─ tests/sources/functional/global_vars.move:218:5 + │ +218 │ invariant global(@0).v <= limit; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/global_vars.move:224: update_invalid + = at tests/sources/functional/global_vars.move:225: update_invalid + = at tests/sources/functional/global_vars.move:218 diff --git a/third_party/move/move-prover/tests/sources/functional/hash_model.v2_exp b/third_party/move/move-prover/tests/sources/functional/hash_model.v2_exp new file mode 100644 index 0000000000000..b000e569c87f0 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/hash_model.v2_exp @@ -0,0 +1,44 @@ +Move prover returns: exiting with verification errors +error: post-condition does not hold + ┌─ tests/sources/functional/hash_model.move:48:9 + │ +48 │ ensures len(result_1) > 0 ==> result_1[0] < max_u8(); // should be <= + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/hash_model.move:39: hash_test1_incorrect + = v1 = + = v2 = + = at tests/sources/functional/hash_model.move:41: hash_test1_incorrect + = v1 = + = at tests/sources/functional/hash_model.move:42: hash_test1_incorrect + = v2 = + = at tests/sources/functional/hash_model.move:43: hash_test1_incorrect + = h1 = + = h2 = + = result_1 = + = result_2 = + = at tests/sources/functional/hash_model.move:44: hash_test1_incorrect + = at tests/sources/functional/hash_model.move:46: hash_test1_incorrect (spec) + = at tests/sources/functional/hash_model.move:48: hash_test1_incorrect (spec) + +error: post-condition does not hold + ┌─ tests/sources/functional/hash_model.move:91:9 + │ +91 │ ensures len(result_1) > 0 ==> result_1[0] < max_u8(); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/hash_model.move:82: hash_test2_incorrect + = v1 = + = v2 = + = at tests/sources/functional/hash_model.move:84: hash_test2_incorrect + = v1 = + = at tests/sources/functional/hash_model.move:85: hash_test2_incorrect + = v2 = + = at tests/sources/functional/hash_model.move:86: hash_test2_incorrect + = h1 = + = h2 = + = result_1 = + = result_2 = + = at tests/sources/functional/hash_model.move:87: hash_test2_incorrect + = at tests/sources/functional/hash_model.move:89: hash_test2_incorrect (spec) + = at tests/sources/functional/hash_model.move:91: hash_test2_incorrect (spec) diff --git a/third_party/move/move-prover/tests/sources/functional/hash_model_invalid.v2_exp b/third_party/move/move-prover/tests/sources/functional/hash_model_invalid.v2_exp new file mode 100644 index 0000000000000..edb74b494f9d8 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/hash_model_invalid.v2_exp @@ -0,0 +1,44 @@ +Move prover returns: exiting with verification errors +error: post-condition does not hold + ┌─ tests/sources/functional/hash_model_invalid.move:22:9 + │ +22 │ ensures len(result_1) > 0 ==> result_1[0] < max_u8(); // should be <= + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/hash_model_invalid.move:11: hash_test1 + = v1 = + = v2 = + = at tests/sources/functional/hash_model_invalid.move:13: hash_test1 + = v1 = + = at tests/sources/functional/hash_model_invalid.move:14: hash_test1 + = v2 = + = at tests/sources/functional/hash_model_invalid.move:15: hash_test1 + = h1 = + = h2 = + = result_1 = + = result_2 = + = at tests/sources/functional/hash_model_invalid.move:16: hash_test1 + = at tests/sources/functional/hash_model_invalid.move:18: hash_test1 (spec) + = at tests/sources/functional/hash_model_invalid.move:22: hash_test1 (spec) + +error: post-condition does not hold + ┌─ tests/sources/functional/hash_model_invalid.move:35:9 + │ +35 │ ensures len(result_1) > 0 ==> result_1[0] < max_u8(); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/hash_model_invalid.move:26: hash_test2 + = v1 = + = v2 = + = at tests/sources/functional/hash_model_invalid.move:28: hash_test2 + = v1 = + = at tests/sources/functional/hash_model_invalid.move:29: hash_test2 + = v2 = + = at tests/sources/functional/hash_model_invalid.move:30: hash_test2 + = h1 = + = h2 = + = result_1 = + = result_2 = + = at tests/sources/functional/hash_model_invalid.move:31: hash_test2 + = at tests/sources/functional/hash_model_invalid.move:33: hash_test2 (spec) + = at tests/sources/functional/hash_model_invalid.move:35: hash_test2 (spec) diff --git a/third_party/move/move-prover/tests/sources/functional/inconsistency.v2_exp b/third_party/move/move-prover/tests/sources/functional/inconsistency.v2_exp new file mode 100644 index 0000000000000..ec1727a9c4ba7 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/inconsistency.v2_exp @@ -0,0 +1,11 @@ +Move prover returns: exiting with verification errors +error: there is an inconsistent assumption in the function, which may allow any post-condition (including false) to be proven + ┌─ tests/sources/functional/inconsistency.move:17:5 + │ +17 │ ╭ fun assume_false(x: u64): u64 { +18 │ │ spec { +19 │ │ assume false; +20 │ │ }; +21 │ │ dec(x) +22 │ │ } + │ ╰─────^ diff --git a/third_party/move/move-prover/tests/sources/functional/inconsistency_always_abort.v2_exp b/third_party/move/move-prover/tests/sources/functional/inconsistency_always_abort.v2_exp new file mode 100644 index 0000000000000..87bd17bdc2ff6 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/inconsistency_always_abort.v2_exp @@ -0,0 +1,20 @@ +Move prover returns: exiting with verification errors +error: there is an inconsistent assumption in the function, which may allow any post-condition (including false) to be proven + ┌─ tests/sources/functional/inconsistency_always_abort.move:6:5 + │ +6 │ ╭ fun always_abort() { +7 │ │ abort 0 +8 │ │ } + │ ╰─────^ + +error: there is an inconsistent assumption in the function, which may allow any post-condition (including false) to be proven + ┌─ tests/sources/functional/inconsistency_always_abort.move:14:5 + │ +14 │ ╭ fun always_abort_if_else(x: u64): bool { +15 │ │ if (x == x) { +16 │ │ abort 0 +17 │ │ } else { +18 │ │ return true +19 │ │ } +20 │ │ } + │ ╰─────^ diff --git a/third_party/move/move-prover/tests/sources/functional/inline-lambda.v2_exp b/third_party/move/move-prover/tests/sources/functional/inline-lambda.v2_exp new file mode 100644 index 0000000000000..fdc5fb6936bc2 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/inline-lambda.v2_exp @@ -0,0 +1,37 @@ +Move prover returns: exiting with verification errors +error: unknown assertion failed + ┌─ tests/sources/functional/inline-lambda.move:5:13 + │ +5 │ assert predicate(v); + │ ^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/inline-lambda.move:10: test_apply + = a1 = + = a2 = + = at tests/sources/functional/inline-lambda.move:4 + = at tests/sources/functional/inline-lambda.move:5 + = at tests/sources/functional/inline-lambda.move:11: test_apply + = a1 = + = at tests/sources/functional/inline-lambda.move:13: test_apply + = at tests/sources/functional/inline-lambda.move:4 + = at tests/sources/functional/inline-lambda.move:5 + +error: unknown assertion failed + ┌─ tests/sources/functional/inline-lambda.move:18:13 + │ +18 │ assert !r2; + │ ^^^^^^^^^^^ + │ + = at tests/sources/functional/inline-lambda.move:10: test_apply + = a1 = + = a2 = + = at tests/sources/functional/inline-lambda.move:4 + = at tests/sources/functional/inline-lambda.move:5 + = at tests/sources/functional/inline-lambda.move:11: test_apply + = a1 = + = at tests/sources/functional/inline-lambda.move:13: test_apply + = at tests/sources/functional/inline-lambda.move:4 + = at tests/sources/functional/inline-lambda.move:5 + = at tests/sources/functional/inline-lambda.move:16: test_apply + = a2 = + = at tests/sources/functional/inline-lambda.move:18: test_apply diff --git a/third_party/move/move-prover/tests/sources/functional/inline_fun_simple.v2_exp b/third_party/move/move-prover/tests/sources/functional/inline_fun_simple.v2_exp new file mode 100644 index 0000000000000..5434f650336cd --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/inline_fun_simple.v2_exp @@ -0,0 +1,12 @@ +Move prover returns: exiting with verification errors +error: unknown assertion failed + ┌─ tests/sources/functional/inline_fun_simple.move:4:13 + │ +4 │ assert v >= 42; + │ ^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/inline_fun_simple.move:4 + = at tests/sources/functional/inline_fun_simple.move:22: test_apply_error + = r1 = + = at tests/sources/functional/inline_fun_simple.move:24: test_apply_error + = at tests/sources/functional/inline_fun_simple.move:4 diff --git a/third_party/move/move-prover/tests/sources/functional/invariants.v2_exp b/third_party/move/move-prover/tests/sources/functional/invariants.v2_exp new file mode 100644 index 0000000000000..051e51eed97f5 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/invariants.v2_exp @@ -0,0 +1,57 @@ +Move prover returns: exiting with verification errors +error: data invariant does not hold + ┌─ tests/sources/functional/invariants.move:15:9 + │ +15 │ invariant greater_one(x); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/invariants.move:42: invalid_R_pack + = at tests/sources/functional/invariants.move:15 + +error: data invariant does not hold + ┌─ tests/sources/functional/invariants.move:15:9 + │ +15 │ invariant greater_one(x); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/invariants.move:113: lifetime_invalid_R + = at tests/sources/functional/invariants.move:15 + = at tests/sources/functional/invariants.move:113: lifetime_invalid_R + = r = + = at tests/sources/functional/invariants.move:114: lifetime_invalid_R + = r_ref = + = at tests/sources/functional/invariants.move:115: lifetime_invalid_R + = x_ref = + = at tests/sources/functional/invariants.move:116: lifetime_invalid_R + = at tests/sources/functional/invariants.move:15 + +error: data invariant does not hold + ┌─ tests/sources/functional/invariants.move:150:9 + │ +150 │ invariant y > 1; + │ ^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/invariants.move:153: lifetime_invalid_S_branching + = cond = + = at tests/sources/functional/invariants.move:154: lifetime_invalid_S_branching + = at tests/sources/functional/invariants.move:143 + = at tests/sources/functional/invariants.move:154: lifetime_invalid_S_branching + = cond = + = at tests/sources/functional/invariants.move:155: lifetime_invalid_S_branching + = at tests/sources/functional/invariants.move:150 + = at tests/sources/functional/invariants.move:155: lifetime_invalid_S_branching + = a = + = at tests/sources/functional/invariants.move:156: lifetime_invalid_S_branching + = b = + = at tests/sources/functional/invariants.move:157: lifetime_invalid_S_branching + = a_ref = + = at tests/sources/functional/invariants.move:158: lifetime_invalid_S_branching + = at tests/sources/functional/invariants.move:143 + = at tests/sources/functional/invariants.move:158: lifetime_invalid_S_branching + = cond = + = b_ref = + = at tests/sources/functional/invariants.move:158: lifetime_invalid_S_branching + = = + = at tests/sources/functional/invariants.move:160: lifetime_invalid_S_branching + = at tests/sources/functional/invariants.move:163: lifetime_invalid_S_branching + = at tests/sources/functional/invariants.move:150 diff --git a/third_party/move/move-prover/tests/sources/functional/invariants_resources.v2_exp b/third_party/move/move-prover/tests/sources/functional/invariants_resources.v2_exp new file mode 100644 index 0000000000000..d6a6eae2ac755 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/invariants_resources.v2_exp @@ -0,0 +1,13 @@ +Move prover returns: exiting with verification errors +error: post-condition does not hold + ┌─ tests/sources/functional/invariants_resources.move:31:9 + │ +31 │ ensures result < 1; + │ ^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/invariants_resources.move:27: get_invalid + = a = + = at tests/sources/functional/invariants_resources.move:28: get_invalid + = result = + = at tests/sources/functional/invariants_resources.move:29: get_invalid + = at tests/sources/functional/invariants_resources.move:31: get_invalid (spec) diff --git a/third_party/move/move-prover/tests/sources/functional/is_txn_signer.v2_exp b/third_party/move/move-prover/tests/sources/functional/is_txn_signer.v2_exp new file mode 100644 index 0000000000000..bb76d1302b97e --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/is_txn_signer.v2_exp @@ -0,0 +1,62 @@ +Move prover returns: exiting with verification errors +error: unknown assertion failed + ┌─ tests/sources/functional/is_txn_signer.move:17:16 + │ +17 │ spec { assert signer::is_txn_signer_addr(@0x7); } // This is unprovable because it is not true in general. + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/is_txn_signer.move:17: f1_incorrect + +error: unknown assertion failed + ┌─ tests/sources/functional/is_txn_signer.move:21:16 + │ +21 │ spec { assert signer::is_txn_signer_addr(@0x7); } // This is unprovable because it is not true in general. + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/is_txn_signer.move:20: f2_incorrect + = _account = + = at tests/sources/functional/is_txn_signer.move:21: f2_incorrect + +error: unknown assertion failed + ┌─ tests/sources/functional/is_txn_signer.move:31:16 + │ +31 │ spec { assert signer::is_txn_signer_addr(@0x7); } // This is unprovable because it is not true in general. + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/is_txn_signer.move:29: f4_incorrect + = account = + = at tests/sources/functional/is_txn_signer.move:30: f4_incorrect + = at ../move-stdlib/sources/signer.move:12: address_of + = s = + = at ../move-stdlib/sources/signer.move:13: address_of + = result = + = at ../move-stdlib/sources/signer.move:14: address_of + = at tests/sources/functional/is_txn_signer.move:30: f4_incorrect + = at tests/sources/functional/is_txn_signer.move:31: f4_incorrect + +error: precondition does not hold at this call + ┌─ tests/sources/functional/is_txn_signer.move:38:9 + │ +38 │ requires signer::is_txn_signer_addr(@0x7); // f5 requires this to be true at its callers' sites + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/is_txn_signer.move:38: f5 (spec) + +error: global memory invariant does not hold + ┌─ tests/sources/functional/is_txn_signer.move:90:9 + │ +90 │ ╭ invariant update (old(exists(ADMIN_ADDRESS())) && global(ADMIN_ADDRESS()).i != old(global(ADMIN_ADDRESS()).i)) +91 │ │ ==> signer::is_txn_signer_addr(ADMIN_ADDRESS()); + │ ╰────────────────────────────────────────────────────────────^ + │ + = at tests/sources/functional/is_txn_signer.move:83: increment_incorrect + = _account = + = at tests/sources/functional/is_txn_signer.move:84: increment_incorrect + = at tests/sources/functional/is_txn_signer.move:60: ADMIN_ADDRESS + = result = + = at tests/sources/functional/is_txn_signer.move:61: ADMIN_ADDRESS + = _account = + = at tests/sources/functional/is_txn_signer.move:85: increment_incorrect + = at tests/sources/functional/is_txn_signer.move:83: increment_incorrect + = at tests/sources/functional/is_txn_signer.move:85: increment_incorrect + = at tests/sources/functional/is_txn_signer.move:90 diff --git a/third_party/move/move-prover/tests/sources/functional/let.v2_exp b/third_party/move/move-prover/tests/sources/functional/let.v2_exp new file mode 100644 index 0000000000000..eded3c5280a35 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/let.v2_exp @@ -0,0 +1,69 @@ +Move prover returns: exiting with verification errors +error: function does not abort under this condition + ┌─ tests/sources/functional/let.move:77:9 + │ +77 │ aborts_if sum != 0; + │ ^^^^^^^^^^^^^^^^^^^ + │ + = Related Bindings: + = sum = + = Execution Trace: + = at tests/sources/functional/let.move:69: spec_let_with_abort_incorrect + = at tests/sources/functional/let.move:75: spec_let_with_abort_incorrect (spec) + = `let sum = a + b;` = + = at tests/sources/functional/let.move:76: spec_let_with_abort_incorrect (spec) + = `let product = a * b;` = + = at tests/sources/functional/let.move:69: spec_let_with_abort_incorrect + = a = + = b = + = at tests/sources/functional/let.move:70: spec_let_with_abort_incorrect + = a = + = at tests/sources/functional/let.move:71: spec_let_with_abort_incorrect + = at tests/sources/functional/let.move:72: spec_let_with_abort_incorrect + = b = + = at tests/sources/functional/let.move:69: spec_let_with_abort_incorrect + = a = + = b = + = at tests/sources/functional/let.move:73: spec_let_with_abort_incorrect + = at tests/sources/functional/let.move:80: spec_let_with_abort_incorrect (spec) + = `let post new_a = old(a) / sum;` = + = at tests/sources/functional/let.move:77: spec_let_with_abort_incorrect (spec) + = `aborts_if sum != 0;` = + +error: abort not covered by any of the `aborts_if` clauses + ┌─ tests/sources/functional/let.move:74:5 + │ +71 │ *a = *a / (*a + *b); + │ -------------- abort happened here with execution failure + · +74 │ ╭ spec spec_let_with_abort_incorrect { +75 │ │ let sum = a + b; +76 │ │ let product = a * b; +77 │ │ aborts_if sum != 0; + · │ +82 │ │ ensures b == product; +83 │ │ } + │ ╰─────^ + │ + = Related Bindings: + = a = + = b = + = Execution Trace: + = at tests/sources/functional/let.move:69: spec_let_with_abort_incorrect + = at tests/sources/functional/let.move:75: spec_let_with_abort_incorrect (spec) + = `let sum = a + b;` = + = at tests/sources/functional/let.move:76: spec_let_with_abort_incorrect (spec) + = `let product = a * b;` = + = at tests/sources/functional/let.move:69: spec_let_with_abort_incorrect + = a = + = b = + = at tests/sources/functional/let.move:70: spec_let_with_abort_incorrect + = a = + = at tests/sources/functional/let.move:71: spec_let_with_abort_incorrect + = ABORTED + = at tests/sources/functional/let.move:77: spec_let_with_abort_incorrect (spec) + = `aborts_if sum != 0;` = + = at tests/sources/functional/let.move:78: spec_let_with_abort_incorrect (spec) + = `aborts_if sum >= MAX_U64;` = + = at tests/sources/functional/let.move:79: spec_let_with_abort_incorrect (spec) + = `aborts_if product >= MAX_U64;` = diff --git a/third_party/move/move-prover/tests/sources/functional/loop_invariant_invalid.v2_exp b/third_party/move/move-prover/tests/sources/functional/loop_invariant_invalid.v2_exp new file mode 100644 index 0000000000000..aa6c9f22101a4 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/loop_invariant_invalid.v2_exp @@ -0,0 +1,24 @@ +Move prover returns: exiting with bytecode transformation errors +error: Loop invariants must be declared at the beginning of the loop header in a consecutive sequence + ┌─ tests/sources/functional/loop_invariant_invalid.move:6:17 + │ +6 │ invariant i <= 10; // invalid - not in header block + │ ^^^^^^^^^^^^^^^^^^ + +error: Loop invariants must be declared at the beginning of the loop header in a consecutive sequence + ┌─ tests/sources/functional/loop_invariant_invalid.move:21:17 + │ +21 │ invariant k == j; // invalid - not consecutive + │ ^^^^^^^^^^^^^^^^^ + +error: Loop invariants must be declared at the beginning of the loop header in a consecutive sequence + ┌─ tests/sources/functional/loop_invariant_invalid.move:36:17 + │ +36 │ invariant i <= 11; // invalid - not at top + │ ^^^^^^^^^^^^^^^^^^ + +error: Loop invariants must be declared at the beginning of the loop header in a consecutive sequence + ┌─ tests/sources/functional/loop_invariant_invalid.move:51:17 + │ +51 │ invariant i <= 11; // invalid - not at top + │ ^^^^^^^^^^^^^^^^^^ diff --git a/third_party/move/move-prover/tests/sources/functional/loop_unroll.v2_exp b/third_party/move/move-prover/tests/sources/functional/loop_unroll.v2_exp new file mode 100644 index 0000000000000..4b791fe4c927f --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/loop_unroll.v2_exp @@ -0,0 +1,122 @@ +Move prover returns: exiting with verification errors +error: abort not covered by any of the `aborts_if` clauses + ┌─ tests/sources/functional/loop_unroll.move:101:5 + │ + 97 │ assert!(i != 5, 0); + │ ------ abort happened here with code 0x0 + · +101 │ ╭ spec t6_failure { +102 │ │ // this will not hold when we increase the unroll count +103 │ │ aborts_if false; +104 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/loop_unroll.move:88: t6_failure + = n = + = at tests/sources/functional/loop_unroll.move:89: t6_failure + = n = + = at tests/sources/functional/loop_unroll.move:91: t6_failure + = at tests/sources/functional/loop_unroll.move:94: t6_failure + = at tests/sources/functional/loop_unroll.move:90: t6_failure + = at tests/sources/functional/loop_unroll.move:96: t6_failure + = i = + = n = + = at tests/sources/functional/loop_unroll.move:97: t6_failure + = = + = at tests/sources/functional/loop_unroll.move:97: t6_failure + = at tests/sources/functional/loop_unroll.move:95: t6_failure + = at tests/sources/functional/loop_unroll.move:90: t6_failure + = at tests/sources/functional/loop_unroll.move:92: t6_failure + = at tests/sources/functional/loop_unroll.move:94: t6_failure + = at tests/sources/functional/loop_unroll.move:90: t6_failure + = at tests/sources/functional/loop_unroll.move:96: t6_failure + = i = + = n = + = at tests/sources/functional/loop_unroll.move:97: t6_failure + = = + = at tests/sources/functional/loop_unroll.move:95: t6_failure + = at tests/sources/functional/loop_unroll.move:90: t6_failure + = at tests/sources/functional/loop_unroll.move:91: t6_failure + = at tests/sources/functional/loop_unroll.move:92: t6_failure + = at tests/sources/functional/loop_unroll.move:94: t6_failure + = at tests/sources/functional/loop_unroll.move:90: t6_failure + = at tests/sources/functional/loop_unroll.move:96: t6_failure + = i = + = n = + = at tests/sources/functional/loop_unroll.move:97: t6_failure + = = + = at tests/sources/functional/loop_unroll.move:95: t6_failure + = at tests/sources/functional/loop_unroll.move:90: t6_failure + = at tests/sources/functional/loop_unroll.move:91: t6_failure + = at tests/sources/functional/loop_unroll.move:92: t6_failure + = at tests/sources/functional/loop_unroll.move:94: t6_failure + = at tests/sources/functional/loop_unroll.move:90: t6_failure + = at tests/sources/functional/loop_unroll.move:96: t6_failure + = i = + = n = + = at tests/sources/functional/loop_unroll.move:97: t6_failure + = = + = at tests/sources/functional/loop_unroll.move:95: t6_failure + = at tests/sources/functional/loop_unroll.move:90: t6_failure + = at tests/sources/functional/loop_unroll.move:91: t6_failure + = at tests/sources/functional/loop_unroll.move:92: t6_failure + = at tests/sources/functional/loop_unroll.move:94: t6_failure + = at tests/sources/functional/loop_unroll.move:90: t6_failure + = at tests/sources/functional/loop_unroll.move:96: t6_failure + = i = + = n = + = at tests/sources/functional/loop_unroll.move:97: t6_failure + = = + = at tests/sources/functional/loop_unroll.move:97: t6_failure + = ABORTED + +error: abort not covered by any of the `aborts_if` clauses + ┌─ tests/sources/functional/loop_unroll.move:128:5 + │ +124 │ assert!(i != 5, 0); + │ ------ abort happened here with code 0x0 + · +128 │ ╭ spec t7_failure { +129 │ │ pragma unroll = 6; +130 │ │ // this will not hold when we increase the unroll count +131 │ │ aborts_if false; +132 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/loop_unroll.move:120: t7_failure + = n = + = at tests/sources/functional/loop_unroll.move:121: t7_failure + = n = + = at tests/sources/functional/loop_unroll.move:122: t7_failure + = at tests/sources/functional/loop_unroll.move:123: t7_failure + = i = + = n = + = at tests/sources/functional/loop_unroll.move:124: t7_failure + = = + = at tests/sources/functional/loop_unroll.move:124: t7_failure + = at tests/sources/functional/loop_unroll.move:122: t7_failure + = at tests/sources/functional/loop_unroll.move:123: t7_failure + = i = + = n = + = at tests/sources/functional/loop_unroll.move:124: t7_failure + = = + = at tests/sources/functional/loop_unroll.move:122: t7_failure + = at tests/sources/functional/loop_unroll.move:123: t7_failure + = i = + = n = + = at tests/sources/functional/loop_unroll.move:124: t7_failure + = = + = at tests/sources/functional/loop_unroll.move:122: t7_failure + = at tests/sources/functional/loop_unroll.move:123: t7_failure + = i = + = n = + = at tests/sources/functional/loop_unroll.move:124: t7_failure + = = + = at tests/sources/functional/loop_unroll.move:122: t7_failure + = at tests/sources/functional/loop_unroll.move:123: t7_failure + = i = + = n = + = at tests/sources/functional/loop_unroll.move:124: t7_failure + = = + = at tests/sources/functional/loop_unroll.move:124: t7_failure + = ABORTED diff --git a/third_party/move/move-prover/tests/sources/functional/loops.v2_exp b/third_party/move/move-prover/tests/sources/functional/loops.v2_exp new file mode 100644 index 0000000000000..7106ede7ae26d --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/loops.v2_exp @@ -0,0 +1,166 @@ +Move prover returns: exiting with verification errors +error: function does not abort under this condition + ┌─ tests/sources/functional/loops.move:58:9 + │ +58 │ aborts_if true; + │ ^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/loops.move:48: iter10_no_abort_incorrect + = i = + = at tests/sources/functional/loops.move:50: iter10_no_abort_incorrect + = enter loop, variable(s) i havocked and reassigned + = i = + = loop invariant holds at current state + = at tests/sources/functional/loops.move:51: iter10_no_abort_incorrect + = = + = at tests/sources/functional/loops.move:49: iter10_no_abort_incorrect + = at tests/sources/functional/loops.move:58: iter10_no_abort_incorrect (spec) + +error: abort not covered by any of the `aborts_if` clauses + ┌─ tests/sources/functional/loops.move:86:5 + │ +82 │ if (i == 7) abort 7; + │ ------- abort happened here with code 0x7 + · +86 │ ╭ spec iter10_abort_incorrect { // Disproved. Abort always happens. +87 │ │ pragma verify=true; +88 │ │ aborts_if false; +89 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/loops.move:77: iter10_abort_incorrect + = i = + = at tests/sources/functional/loops.move:79: iter10_abort_incorrect + = enter loop, variable(s) i havocked and reassigned + = i = + = loop invariant holds at current state + = at tests/sources/functional/loops.move:80: iter10_abort_incorrect + = = + = at tests/sources/functional/loops.move:78: iter10_abort_incorrect + = at tests/sources/functional/loops.move:82: iter10_abort_incorrect + = = + = at tests/sources/functional/loops.move:82: iter10_abort_incorrect + = ABORTED + +error: induction case of the loop invariant does not hold + ┌─ tests/sources/functional/loops.move:119:17 + │ +119 │ invariant x != y; + │ ^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/loops.move:113: nested_loop_outer_invariant_incorrect + = x = + = y = + = at tests/sources/functional/loops.move:115: nested_loop_outer_invariant_incorrect + = at tests/sources/functional/loops.move:118: nested_loop_outer_invariant_incorrect + = at tests/sources/functional/loops.move:119: nested_loop_outer_invariant_incorrect + = enter loop, variable(s) x, y havocked and reassigned + = x = + = y = + = loop invariant holds at current state + = at tests/sources/functional/loops.move:122: nested_loop_outer_invariant_incorrect + = enter loop, variable(s) y havocked and reassigned + = y = + = at tests/sources/functional/loops.move:123: nested_loop_outer_invariant_incorrect + = at tests/sources/functional/loops.move:128: nested_loop_outer_invariant_incorrect + = at tests/sources/functional/loops.move:131: nested_loop_outer_invariant_incorrect + = y = + = x = + = at tests/sources/functional/loops.move:117: nested_loop_outer_invariant_incorrect + = at tests/sources/functional/loops.move:119: nested_loop_outer_invariant_incorrect + +error: induction case of the loop invariant does not hold + ┌─ tests/sources/functional/loops.move:145:21 + │ +145 │ invariant x != y; + │ ^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/loops.move:138: nested_loop_inner_invariant_incorrect + = x = + = y = + = at tests/sources/functional/loops.move:140: nested_loop_inner_invariant_incorrect + = at tests/sources/functional/loops.move:144: nested_loop_inner_invariant_incorrect + = at tests/sources/functional/loops.move:145: nested_loop_inner_invariant_incorrect + = enter loop, variable(s) x, y havocked and reassigned + = x = + = y = + = loop invariant holds at current state + = at tests/sources/functional/loops.move:147: nested_loop_inner_invariant_incorrect + = at tests/sources/functional/loops.move:150: nested_loop_inner_invariant_incorrect + = x = + = y = + = at tests/sources/functional/loops.move:143: nested_loop_inner_invariant_incorrect + = at tests/sources/functional/loops.move:145: nested_loop_inner_invariant_incorrect + +error: induction case of the loop invariant does not hold + ┌─ tests/sources/functional/loops.move:189:17 + │ +189 │ invariant x < y; + │ ^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/loops.move:183: loop_with_two_back_edges_incorrect + = x = + = y = + = at tests/sources/functional/loops.move:185: loop_with_two_back_edges_incorrect + = at tests/sources/functional/loops.move:188: loop_with_two_back_edges_incorrect + = at tests/sources/functional/loops.move:189: loop_with_two_back_edges_incorrect + = enter loop, variable(s) x, y havocked and reassigned + = x = + = y = + = loop invariant holds at current state + = at tests/sources/functional/loops.move:191: loop_with_two_back_edges_incorrect + = at tests/sources/functional/loops.move:195: loop_with_two_back_edges_incorrect + = at tests/sources/functional/loops.move:196: loop_with_two_back_edges_incorrect + = y = + = x = + = at tests/sources/functional/loops.move:197: loop_with_two_back_edges_incorrect + = at tests/sources/functional/loops.move:189: loop_with_two_back_edges_incorrect + +error: base case of the loop invariant does not hold + ┌─ tests/sources/functional/loops.move:210:17 + │ +210 │ invariant x != 0; + │ ^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/loops.move:206: loop_invariant_base_invalid + = n = + = at tests/sources/functional/loops.move:207: loop_invariant_base_invalid + = n = + = at tests/sources/functional/loops.move:209: loop_invariant_base_invalid + = at tests/sources/functional/loops.move:210: loop_invariant_base_invalid + +error: induction case of the loop invariant does not hold + ┌─ tests/sources/functional/loops.move:223:17 + │ +223 │ invariant x == 0; + │ ^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/loops.move:219: loop_invariant_induction_invalid + = n = + = at tests/sources/functional/loops.move:220: loop_invariant_induction_invalid + = n = + = at tests/sources/functional/loops.move:222: loop_invariant_induction_invalid + = at tests/sources/functional/loops.move:223: loop_invariant_induction_invalid + = enter loop, variable(s) n havocked and reassigned + = n = + = loop invariant holds at current state + = at tests/sources/functional/loops.move:225: loop_invariant_induction_invalid + = at tests/sources/functional/loops.move:221: loop_invariant_induction_invalid + = at tests/sources/functional/loops.move:227: loop_invariant_induction_invalid + = x = + = n = + = at tests/sources/functional/loops.move:226: loop_invariant_induction_invalid + = at tests/sources/functional/loops.move:221: loop_invariant_induction_invalid + = at tests/sources/functional/loops.move:223: loop_invariant_induction_invalid + +error: unknown assertion failed + ┌─ tests/sources/functional/loops.move:235:20 + │ +235 │ spec { assert i <= 11; }; // expect to fail, `i` is havoc-ed + │ ^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/loops.move:233: iter10_assert_instead_of_invariant + = i = + = at tests/sources/functional/loops.move:235: iter10_assert_instead_of_invariant + = enter loop, variable(s) i havocked and reassigned + = i = diff --git a/third_party/move/move-prover/tests/sources/functional/loops_with_memory_ops.v2_exp b/third_party/move/move-prover/tests/sources/functional/loops_with_memory_ops.v2_exp new file mode 100644 index 0000000000000..eb9119dee9861 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/loops_with_memory_ops.v2_exp @@ -0,0 +1,115 @@ +Move prover returns: exiting with verification errors +error: induction case of the loop invariant does not hold + ┌─ tests/sources/functional/loops_with_memory_ops.move:70:17 + │ +70 │ invariant forall n in 0..i: a[n] == b[n]; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/loops_with_memory_ops.move:56: nested_loop2 + = a = + = b = + = at tests/sources/functional/loops_with_memory_ops.move:57: nested_loop2 + = a = + = at tests/sources/functional/loops_with_memory_ops.move:59: nested_loop2 + = at tests/sources/functional/loops_with_memory_ops.move:60: nested_loop2 + = at tests/sources/functional/loops_with_memory_ops.move:62: nested_loop2 + = b = + = at tests/sources/functional/loops_with_memory_ops.move:63: nested_loop2 + = length = + = i = + = at tests/sources/functional/loops_with_memory_ops.move:64: nested_loop2 + = = + = x = + = at tests/sources/functional/loops_with_memory_ops.move:66: nested_loop2 + = at tests/sources/functional/loops_with_memory_ops.move:67: nested_loop2 + = at tests/sources/functional/loops_with_memory_ops.move:68: nested_loop2 + = at tests/sources/functional/loops_with_memory_ops.move:69: nested_loop2 + = at tests/sources/functional/loops_with_memory_ops.move:70: nested_loop2 + = enter loop, variable(s) a, b, b, i, x havocked and reassigned + = a = + = b = + = i = + = x = + = loop invariant holds at current state + = at tests/sources/functional/loops_with_memory_ops.move:67: nested_loop2 + = at tests/sources/functional/loops_with_memory_ops.move:68: nested_loop2 + = at tests/sources/functional/loops_with_memory_ops.move:69: nested_loop2 + = at tests/sources/functional/loops_with_memory_ops.move:70: nested_loop2 + = at tests/sources/functional/loops_with_memory_ops.move:74: nested_loop2 + = enter loop, variable(s) i, x havocked and reassigned + = i = + = x = + = at tests/sources/functional/loops_with_memory_ops.move:75: nested_loop2 + = at tests/sources/functional/loops_with_memory_ops.move:80: nested_loop2 + = at tests/sources/functional/loops_with_memory_ops.move:81: nested_loop2 + = a = + = at tests/sources/functional/loops_with_memory_ops.move:81: nested_loop2 + = b = + = at tests/sources/functional/loops_with_memory_ops.move:85: nested_loop2 + = = + = b = + = at tests/sources/functional/loops_with_memory_ops.move:86: nested_loop2 + = at tests/sources/functional/loops_with_memory_ops.move:89: nested_loop2 + = y = + = i = + = at tests/sources/functional/loops_with_memory_ops.move:90: nested_loop2 + = = + = x = + = at tests/sources/functional/loops_with_memory_ops.move:65: nested_loop2 + = at tests/sources/functional/loops_with_memory_ops.move:67: nested_loop2 + = at tests/sources/functional/loops_with_memory_ops.move:68: nested_loop2 + = at tests/sources/functional/loops_with_memory_ops.move:69: nested_loop2 + = at tests/sources/functional/loops_with_memory_ops.move:70: nested_loop2 + +error: unknown assertion failed + ┌─ tests/sources/functional/loops_with_memory_ops.move:93:13 + │ +93 │ assert forall m in 0..length: a[m] == b[m]; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/loops_with_memory_ops.move:56: nested_loop2 + = a = + = b = + = at tests/sources/functional/loops_with_memory_ops.move:57: nested_loop2 + = a = + = at tests/sources/functional/loops_with_memory_ops.move:59: nested_loop2 + = at tests/sources/functional/loops_with_memory_ops.move:60: nested_loop2 + = at tests/sources/functional/loops_with_memory_ops.move:62: nested_loop2 + = b = + = at tests/sources/functional/loops_with_memory_ops.move:63: nested_loop2 + = length = + = i = + = at tests/sources/functional/loops_with_memory_ops.move:64: nested_loop2 + = = + = x = + = at tests/sources/functional/loops_with_memory_ops.move:66: nested_loop2 + = at tests/sources/functional/loops_with_memory_ops.move:67: nested_loop2 + = at tests/sources/functional/loops_with_memory_ops.move:68: nested_loop2 + = at tests/sources/functional/loops_with_memory_ops.move:69: nested_loop2 + = at tests/sources/functional/loops_with_memory_ops.move:70: nested_loop2 + = enter loop, variable(s) a, b, b, i, x havocked and reassigned + = a = + = b = + = i = + = x = + = loop invariant holds at current state + = at tests/sources/functional/loops_with_memory_ops.move:67: nested_loop2 + = at tests/sources/functional/loops_with_memory_ops.move:68: nested_loop2 + = at tests/sources/functional/loops_with_memory_ops.move:69: nested_loop2 + = at tests/sources/functional/loops_with_memory_ops.move:70: nested_loop2 + = at tests/sources/functional/loops_with_memory_ops.move:74: nested_loop2 + = enter loop, variable(s) i, x havocked and reassigned + = i = + = x = + = at tests/sources/functional/loops_with_memory_ops.move:75: nested_loop2 + = at tests/sources/functional/loops_with_memory_ops.move:80: nested_loop2 + = at tests/sources/functional/loops_with_memory_ops.move:81: nested_loop2 + = a = + = b = + = at tests/sources/functional/loops_with_memory_ops.move:81: nested_loop2 + = at tests/sources/functional/loops_with_memory_ops.move:85: nested_loop2 + = = + = b = + = at tests/sources/functional/loops_with_memory_ops.move:86: nested_loop2 + = at tests/sources/functional/loops_with_memory_ops.move:87: nested_loop2 + = at tests/sources/functional/loops_with_memory_ops.move:93: nested_loop2 diff --git a/third_party/move/move-prover/tests/sources/functional/macro_verification.v2_exp b/third_party/move/move-prover/tests/sources/functional/macro_verification.v2_exp new file mode 100644 index 0000000000000..2b81e23977501 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/macro_verification.v2_exp @@ -0,0 +1,148 @@ +Move prover returns: exiting with verification errors +error: post-condition does not hold + ┌─ tests/sources/functional/macro_verification.move:32:9 + │ +32 │ ensures forall i in range(v): v[i] == old(v)[i] + 2; // fails + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = Related Bindings: + = old(v) = + = v = + = Execution Trace: + = at tests/sources/functional/macro_verification.move:15: foreach + = v = + = at tests/sources/functional/macro_verification.move:16: foreach + = v = + = at tests/sources/functional/macro_verification.move:22: foreach + = at tests/sources/functional/macro_verification.move:23: foreach + = `invariant i >= 0 && i <= len(v);` = + = at tests/sources/functional/macro_verification.move:24: foreach + = `invariant len(v) == len(old(v));` = + = at tests/sources/functional/macro_verification.move:25: foreach + = `invariant forall j in 0..i: v[j] == old(v)[j] + 1;` = + = at tests/sources/functional/macro_verification.move:26: foreach + = `invariant forall j in i..len(v): v[j] == old(v)[j];` = + = enter loop, variable(s) v, v havocked and reassigned + = v = + = `invariant forall j in i..len(v): v[j] == old(v)[j];` = + = loop invariant holds at current state + = at tests/sources/functional/macro_verification.move:23: foreach + = `invariant i >= 0 && i <= len(v);` = + = at tests/sources/functional/macro_verification.move:24: foreach + = `invariant len(v) == len(old(v));` = + = at tests/sources/functional/macro_verification.move:25: foreach + = `invariant forall j in 0..i: v[j] == old(v)[j] + 1;` = + = at tests/sources/functional/macro_verification.move:26: foreach + = `invariant forall j in i..len(v): v[j] == old(v)[j];` = + = at tests/sources/functional/macro_verification.move:17: foreach + = i = + = at tests/sources/functional/macro_verification.move:17: foreach + = at tests/sources/functional/macro_verification.move:15: foreach + = v = + = at tests/sources/functional/macro_verification.move:30: foreach (spec) + = `ensures len(v) == len(old(v));` = + = at tests/sources/functional/macro_verification.move:31: foreach (spec) + = `ensures forall i in range(v): v[i] == old(v)[i] + 1;` = + = at tests/sources/functional/macro_verification.move:32: foreach (spec) + = `ensures forall i in range(v): v[i] == old(v)[i] + 2;` = + +error: post-condition does not hold + ┌─ tests/sources/functional/macro_verification.move:57:9 + │ +57 │ ensures len(v) <= 4 ==> result == spec_sum(v, len(v)) + 1; // fails + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = Related Bindings: + = result = + = spec_sum(v, len(v)) = + = v = + = Execution Trace: + = at tests/sources/functional/macro_verification.move:40: reduce + = v = + = at tests/sources/functional/macro_verification.move:41: reduce + = v = + = at tests/sources/functional/macro_verification.move:42: reduce + = i = + = at tests/sources/functional/macro_verification.move:48: reduce + = at tests/sources/functional/macro_verification.move:49: reduce + = `invariant i >= 0 && i <= len(v);` = + = at tests/sources/functional/macro_verification.move:50: reduce + = `invariant sum == spec_sum(v, i);` = + = enter loop, variable(s) v, i havocked and reassigned + = v = + = i = + = `invariant sum == spec_sum(v, i);` = + = loop invariant holds at current state + = at tests/sources/functional/macro_verification.move:49: reduce + = `invariant i >= 0 && i <= len(v);` = + = at tests/sources/functional/macro_verification.move:50: reduce + = `invariant sum == spec_sum(v, i);` = + = at tests/sources/functional/macro_verification.move:43: reduce + = sum = + = = + = at tests/sources/functional/macro_verification.move:43: reduce + = at tests/sources/functional/macro_verification.move:52: reduce + = = + = at tests/sources/functional/macro_verification.move:40: reduce + = result = + = at tests/sources/functional/macro_verification.move:55: reduce (spec) + = `ensures result == spec_sum(v, len(v));` = + = at tests/sources/functional/macro_verification.move:57: reduce (spec) + = `ensures len(v) <= 4 ==> result == spec_sum(v, len(v)) + 1;` = + = + +error: post-condition does not hold + ┌─ tests/sources/functional/macro_verification.move:76:9 + │ +76 │ ensures result == x + y + y; // fails + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = Related Bindings: + = result = + = x = + = y = + = Execution Trace: + = at tests/sources/functional/macro_verification.move:67: reduce_test + = x = + = y = + = z = + = at tests/sources/functional/macro_verification.move:68: reduce_test + = x = + = at tests/sources/functional/macro_verification.move:69: reduce_test + = x = + = at tests/sources/functional/macro_verification.move:70: reduce_test + = x = + = at tests/sources/functional/macro_verification.move:71: reduce_test + = x = + = at tests/sources/functional/macro_verification.move:72: reduce_test + = at tests/sources/functional/macro_verification.move:40: reduce + = v = + = at tests/sources/functional/macro_verification.move:41: reduce + = v = + = at tests/sources/functional/macro_verification.move:42: reduce + = i = + = at tests/sources/functional/macro_verification.move:48: reduce + = at tests/sources/functional/macro_verification.move:49: reduce + = at tests/sources/functional/macro_verification.move:50: reduce + = enter loop, variable(s) v, i havocked and reassigned + = v = + = i = + = loop invariant holds at current state + = at tests/sources/functional/macro_verification.move:49: reduce + = at tests/sources/functional/macro_verification.move:50: reduce + = at tests/sources/functional/macro_verification.move:43: reduce + = sum = + = = + = at tests/sources/functional/macro_verification.move:43: reduce + = at tests/sources/functional/macro_verification.move:52: reduce + = = + = at tests/sources/functional/macro_verification.move:40: reduce + = result = + = at tests/sources/functional/macro_verification.move:53: reduce + = at tests/sources/functional/macro_verification.move:67: reduce_test + = result = + = at tests/sources/functional/macro_verification.move:73: reduce_test + = at tests/sources/functional/macro_verification.move:75: reduce_test (spec) + = `ensures result == x + y + z;` = + = at tests/sources/functional/macro_verification.move:76: reduce_test (spec) + = `ensures result == x + y + y;` = diff --git a/third_party/move/move-prover/tests/sources/functional/module_level_spec.v2_exp b/third_party/move/move-prover/tests/sources/functional/module_level_spec.v2_exp new file mode 100644 index 0000000000000..7b9fe50ae42d6 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/module_level_spec.v2_exp @@ -0,0 +1,15 @@ +Move prover returns: exiting with verification errors +error: global memory invariant does not hold + ┌─ tests/sources/functional/module_level_spec.move:18:5 + │ +18 │ invariant forall addr: address where exists(addr): global(addr).value > 0; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/module_level_spec.move:10: store_incorrect + = at tests/sources/functional/module_level_spec.move:32 + = at tests/sources/functional/module_level_spec.move:10: store_incorrect + = s = + = value = + = at tests/sources/functional/module_level_spec.move:11: store_incorrect + = s = + = at tests/sources/functional/module_level_spec.move:18 diff --git a/third_party/move/move-prover/tests/sources/functional/mono.v2_exp b/third_party/move/move-prover/tests/sources/functional/mono.v2_exp new file mode 100644 index 0000000000000..58c8d24e7a195 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/mono.v2_exp @@ -0,0 +1,70 @@ +Move prover returns: exiting with verification errors +error: post-condition does not hold + ┌─ tests/sources/functional/mono.move:69:20 + │ +69 │ spec vec_int { ensures result[0] != 1; } + │ ^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/mono.move:68: vec_int + = x = + = result = + = at tests/sources/functional/mono.move:69: vec_int (spec) + +error: post-condition does not hold + ┌─ tests/sources/functional/mono.move:71:21 + │ +71 │ spec vec_addr { ensures result[0] != @0x1; } + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/mono.move:70: vec_addr + = x = + = result = + = at tests/sources/functional/mono.move:71: vec_addr (spec) + +error: post-condition does not hold + ┌─ tests/sources/functional/mono.move:73:21 + │ +73 │ spec vec_bool { ensures result[0] != true; } + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/mono.move:72: vec_bool + = x = + = result = + = at tests/sources/functional/mono.move:73: vec_bool (spec) + +error: post-condition does not hold + ┌─ tests/sources/functional/mono.move:75:27 + │ +75 │ spec vec_struct_int { ensures result[0].x != 1; } + │ ^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/mono.move:74: vec_struct_int + = x = + = result = + = at tests/sources/functional/mono.move:75: vec_struct_int (spec) + +error: post-condition does not hold + ┌─ tests/sources/functional/mono.move:77:28 + │ +77 │ spec vec_struct_addr { ensures result[0].x != @0x1; } + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/mono.move:76: vec_struct_addr + = x = + = result = + = at tests/sources/functional/mono.move:77: vec_struct_addr (spec) + +error: post-condition does not hold + ┌─ tests/sources/functional/mono.move:82:20 + │ +82 │ spec vec_vec { ensures len(result[0]) != 0; } + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/mono.move:79: vec_vec + = x = + = at tests/sources/functional/mono.move:80: vec_vec + = x = + = at tests/sources/functional/mono.move:79: vec_vec + = result = + = at tests/sources/functional/mono.move:81: vec_vec + = at tests/sources/functional/mono.move:82: vec_vec (spec) diff --git a/third_party/move/move-prover/tests/sources/functional/mut_ref.v2_exp b/third_party/move/move-prover/tests/sources/functional/mut_ref.v2_exp new file mode 100644 index 0000000000000..968ca06aec16c --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/mut_ref.v2_exp @@ -0,0 +1,45 @@ +Move prover returns: exiting with verification errors +error: data invariant does not hold + ┌─ tests/sources/functional/mut_ref.move:8:14 + │ +8 │ spec T { invariant value > 0; } + │ ^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/mut_ref.move:113: call_return_ref_different_path_vec2_incorrect + = b = + = at tests/sources/functional/mut_ref.move:114: call_return_ref_different_path_vec2_incorrect + = b = + = at tests/sources/functional/mut_ref.move:115: call_return_ref_different_path_vec2_incorrect + = is = + = at tests/sources/functional/mut_ref.move:116: call_return_ref_different_path_vec2_incorrect + = b = + = at tests/sources/functional/mut_ref.move:117: call_return_ref_different_path_vec2_incorrect + = b = + = at tests/sources/functional/mut_ref.move:118: call_return_ref_different_path_vec2_incorrect + = at tests/sources/functional/mut_ref.move:8 + = at tests/sources/functional/mut_ref.move:118: call_return_ref_different_path_vec2_incorrect + = at tests/sources/functional/mut_ref.move:8 + = at tests/sources/functional/mut_ref.move:118: call_return_ref_different_path_vec2_incorrect + = is = + = at tests/sources/functional/mut_ref.move:119: call_return_ref_different_path_vec2_incorrect + = at tests/sources/functional/mut_ref.move:8 + = at tests/sources/functional/mut_ref.move:119: call_return_ref_different_path_vec2_incorrect + = at tests/sources/functional/mut_ref.move:8 + = at tests/sources/functional/mut_ref.move:119: call_return_ref_different_path_vec2_incorrect + = is = + = at tests/sources/functional/mut_ref.move:120: call_return_ref_different_path_vec2_incorrect + = ts = + = at tests/sources/functional/mut_ref.move:121: call_return_ref_different_path_vec2_incorrect + = x = + = at tests/sources/functional/mut_ref.move:90: return_ref_different_path_vec2 + = b = + = x = + = at tests/sources/functional/mut_ref.move:91: return_ref_different_path_vec2 + = b = + = at tests/sources/functional/mut_ref.move:91: return_ref_different_path_vec2 + = result = + = x = + = at tests/sources/functional/mut_ref.move:92: return_ref_different_path_vec2 + = = + = at tests/sources/functional/mut_ref.move:122: call_return_ref_different_path_vec2_incorrect + = at tests/sources/functional/mut_ref.move:8 diff --git a/third_party/move/move-prover/tests/sources/functional/nested_invariants.v2_exp b/third_party/move/move-prover/tests/sources/functional/nested_invariants.v2_exp new file mode 100644 index 0000000000000..b4d83685c0075 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/nested_invariants.v2_exp @@ -0,0 +1,60 @@ +Move prover returns: exiting with verification errors +error: data invariant does not hold + ┌─ tests/sources/functional/nested_invariants.move:16:9 + │ +16 │ invariant x > 0; + │ ^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/nested_invariants.move:64: mutate_inner_data_invariant_invalid + = at tests/sources/functional/nested_invariants.move:16 + = at tests/sources/functional/nested_invariants.move:64: mutate_inner_data_invariant_invalid + = at tests/sources/functional/nested_invariants.move:29 + = at tests/sources/functional/nested_invariants.move:32 + = at tests/sources/functional/nested_invariants.move:64: mutate_inner_data_invariant_invalid + = o = + = at tests/sources/functional/nested_invariants.move:65: mutate_inner_data_invariant_invalid + = r = + = at tests/sources/functional/nested_invariants.move:66: mutate_inner_data_invariant_invalid + = at tests/sources/functional/nested_invariants.move:29 + = at tests/sources/functional/nested_invariants.move:32 + = at tests/sources/functional/nested_invariants.move:16 + +error: data invariant does not hold + ┌─ tests/sources/functional/nested_invariants.move:16:9 + │ +16 │ invariant x > 0; + │ ^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/nested_invariants.move:47: new_inner_data_invariant_invalid + = at tests/sources/functional/nested_invariants.move:16 + +error: data invariant does not hold + ┌─ tests/sources/functional/nested_invariants.move:32:9 + │ +32 │ invariant n.x < y; + │ ^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/nested_invariants.move:58: mutate_outer_data_invariant_invalid + = at tests/sources/functional/nested_invariants.move:16 + = at tests/sources/functional/nested_invariants.move:58: mutate_outer_data_invariant_invalid + = at tests/sources/functional/nested_invariants.move:29 + = at tests/sources/functional/nested_invariants.move:32 + = at tests/sources/functional/nested_invariants.move:58: mutate_outer_data_invariant_invalid + = o = + = at tests/sources/functional/nested_invariants.move:59: mutate_outer_data_invariant_invalid + = r = + = at tests/sources/functional/nested_invariants.move:60: mutate_outer_data_invariant_invalid + = at tests/sources/functional/nested_invariants.move:29 + = at tests/sources/functional/nested_invariants.move:32 + +error: data invariant does not hold + ┌─ tests/sources/functional/nested_invariants.move:32:9 + │ +32 │ invariant n.x < y; + │ ^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/nested_invariants.move:43: new_outer_data_invariant_invalid + = at tests/sources/functional/nested_invariants.move:16 + = at tests/sources/functional/nested_invariants.move:43: new_outer_data_invariant_invalid + = at tests/sources/functional/nested_invariants.move:29 + = at tests/sources/functional/nested_invariants.move:32 diff --git a/third_party/move/move-prover/tests/sources/functional/nonlinear_arithm.v2_exp b/third_party/move/move-prover/tests/sources/functional/nonlinear_arithm.v2_exp new file mode 100644 index 0000000000000..df8ab37977749 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/nonlinear_arithm.v2_exp @@ -0,0 +1,170 @@ +Move prover returns: exiting with verification errors +error: abort not covered by any of the `aborts_if` clauses + ┌─ tests/sources/functional/nonlinear_arithm.move:18:5 + │ +16 │ a * b * c + │ ----- abort happened here with execution failure +17 │ } +18 │ ╭ spec overflow_u8_mul_3_incorrect { +19 │ │ aborts_if false; +20 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/nonlinear_arithm.move:15: overflow_u8_mul_3_incorrect + = a = + = b = + = c = + = at tests/sources/functional/nonlinear_arithm.move:16: overflow_u8_mul_3_incorrect + = ABORTED + +error: abort not covered by any of the `aborts_if` clauses + ┌─ tests/sources/functional/nonlinear_arithm.move:35:5 + │ +33 │ a * b * c + │ ----- abort happened here with execution failure +34 │ } +35 │ ╭ spec overflow_u64_mul_3_incorrect { +36 │ │ aborts_if false; +37 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/nonlinear_arithm.move:32: overflow_u64_mul_3_incorrect + = a = + = b = + = c = + = at tests/sources/functional/nonlinear_arithm.move:33: overflow_u64_mul_3_incorrect + = ABORTED + +error: abort not covered by any of the `aborts_if` clauses + ┌─ tests/sources/functional/nonlinear_arithm.move:51:5 + │ +49 │ a * b * c + │ ----- abort happened here with execution failure +50 │ } +51 │ ╭ spec overflow_u128_mul_3_incorrect { +52 │ │ aborts_if false; +53 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/nonlinear_arithm.move:48: overflow_u128_mul_3_incorrect + = a = + = b = + = c = + = at tests/sources/functional/nonlinear_arithm.move:49: overflow_u128_mul_3_incorrect + = ABORTED + +error: abort not covered by any of the `aborts_if` clauses + ┌─ tests/sources/functional/nonlinear_arithm.move:72:5 + │ +70 │ a * b * c * d + │ ----- abort happened here with execution failure +71 │ } +72 │ ╭ spec overflow_u8_mul_4_incorrect { +73 │ │ aborts_if false; +74 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/nonlinear_arithm.move:69: overflow_u8_mul_4_incorrect + = a = + = b = + = c = + = d = + = at tests/sources/functional/nonlinear_arithm.move:70: overflow_u8_mul_4_incorrect + = ABORTED + +error: abort not covered by any of the `aborts_if` clauses + ┌─ tests/sources/functional/nonlinear_arithm.move:90:5 + │ +88 │ a * b * c * d + │ ----- abort happened here with execution failure +89 │ } +90 │ ╭ spec overflow_u64_mul_4_incorrect { +91 │ │ aborts_if false; +92 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/nonlinear_arithm.move:87: overflow_u64_mul_4_incorrect + = a = + = b = + = c = + = d = + = at tests/sources/functional/nonlinear_arithm.move:88: overflow_u64_mul_4_incorrect + = ABORTED + +error: abort not covered by any of the `aborts_if` clauses + ┌─ tests/sources/functional/nonlinear_arithm.move:131:5 + │ +129 │ a * b * c * d * e + │ ----- abort happened here with execution failure +130 │ } +131 │ ╭ spec overflow_u8_mul_5_incorrect { +132 │ │ aborts_if false; +133 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/nonlinear_arithm.move:128: overflow_u8_mul_5_incorrect + = a = + = b = + = c = + = d = + = e = + = at tests/sources/functional/nonlinear_arithm.move:129: overflow_u8_mul_5_incorrect + = ABORTED + +error: abort not covered by any of the `aborts_if` clauses + ┌─ tests/sources/functional/nonlinear_arithm.move:150:5 + │ +148 │ a * b * c * d * e + │ ----- abort happened here with execution failure +149 │ } +150 │ ╭ spec overflow_u64_mul_5_incorrect { +151 │ │ aborts_if false; +152 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/nonlinear_arithm.move:147: overflow_u64_mul_5_incorrect + = a = + = b = + = c = + = d = + = e = + = at tests/sources/functional/nonlinear_arithm.move:148: overflow_u64_mul_5_incorrect + = ABORTED + +error: post-condition does not hold + ┌─ tests/sources/functional/nonlinear_arithm.move:214:9 + │ +214 │ ensures result != 720; + │ ^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/nonlinear_arithm.move:203: mul5_incorrect + = a = + = b = + = c = + = d = + = e = + = at tests/sources/functional/nonlinear_arithm.move:205: mul5_incorrect + = at tests/sources/functional/nonlinear_arithm.move:206: mul5_incorrect + = at tests/sources/functional/nonlinear_arithm.move:207: mul5_incorrect + = at tests/sources/functional/nonlinear_arithm.move:208: mul5_incorrect + = at tests/sources/functional/nonlinear_arithm.move:210: mul5_incorrect + = at tests/sources/functional/nonlinear_arithm.move:203: mul5_incorrect + = result = + = at tests/sources/functional/nonlinear_arithm.move:211: mul5_incorrect + = at tests/sources/functional/nonlinear_arithm.move:214: mul5_incorrect (spec) + +error: post-condition does not hold + ┌─ tests/sources/functional/nonlinear_arithm.move:228:9 + │ +228 │ ensures result == a*b*c + a*b*d + a*b; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/nonlinear_arithm.move:224: distribution_law_incorrect + = a = + = b = + = c = + = d = + = at tests/sources/functional/nonlinear_arithm.move:225: distribution_law_incorrect + = result = + = at tests/sources/functional/nonlinear_arithm.move:226: distribution_law_incorrect + = at tests/sources/functional/nonlinear_arithm.move:228: distribution_law_incorrect (spec) diff --git a/third_party/move/move-prover/tests/sources/functional/old_param_err.v2_exp b/third_party/move/move-prover/tests/sources/functional/old_param_err.v2_exp new file mode 100644 index 0000000000000..04ddd2998ad31 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/old_param_err.v2_exp @@ -0,0 +1,6 @@ +Move prover returns: exiting with bytecode transformation errors +error: `old(..)` applied to expression which does not depend on state + ┌─ tests/sources/functional/old_param_err.move:16:17 + │ +16 │ ensures old(token.value) == result_1.value + result_2.value; + │ ^^^^^^^^^^^^^^^^ diff --git a/third_party/move/move-prover/tests/sources/functional/opaque.v2_exp b/third_party/move/move-prover/tests/sources/functional/opaque.v2_exp new file mode 100644 index 0000000000000..45066fc0ac53c --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/opaque.v2_exp @@ -0,0 +1,11 @@ +Move prover returns: exiting with verification errors +error: post-condition does not hold + ┌─ tests/sources/functional/opaque.move:14:9 + │ +14 │ ensures result == 2; + │ ^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/opaque.move:10: opaque_incorrect + = result = + = at tests/sources/functional/opaque.move:11: opaque_incorrect + = at tests/sources/functional/opaque.move:14: opaque_incorrect (spec) diff --git a/third_party/move/move-prover/tests/sources/functional/pragma.v2_exp b/third_party/move/move-prover/tests/sources/functional/pragma.v2_exp new file mode 100644 index 0000000000000..6f1d2f49ad231 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/pragma.v2_exp @@ -0,0 +1,17 @@ +Move prover returns: exiting with verification errors +error: abort not covered by any of the `aborts_if` clauses + ┌─ tests/sources/functional/pragma.move:13:5 + │ +11 │ abort(1) + │ -------- abort happened here with code 0x1 +12 │ } +13 │ ╭ spec always_aborts_with_verify_incorrect { +14 │ │ pragma verify=true; +15 │ │ aborts_if _c; +16 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/pragma.move:10: always_aborts_with_verify_incorrect + = _c = + = at tests/sources/functional/pragma.move:11: always_aborts_with_verify_incorrect + = ABORTED diff --git a/third_party/move/move-prover/tests/sources/functional/pure_function_call_incorrect.v2_exp b/third_party/move/move-prover/tests/sources/functional/pure_function_call_incorrect.v2_exp new file mode 100644 index 0000000000000..50eac90834112 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/pure_function_call_incorrect.v2_exp @@ -0,0 +1,15 @@ +Move prover returns: exiting with checking errors +error: specification expression cannot call impure Move function `init` + ┌─ tests/sources/functional/pure_function_call_incorrect.move:32:20 + │ +11 │ return true + │ ----------- in `init`: return not allowed in specifications + · +32 │ aborts_if !init(account); + │ ^^^^^^^^^^^^^ called here + +error: specification expression cannot use impure construct + ┌─ tests/sources/functional/pure_function_call_incorrect.move:56:27 + │ +56 │ ensures result == vector::pop_back(old(v)); + │ ^^^^^^^^^^^^^^^^^^^^^^^^ calls a function which modifies state diff --git a/third_party/move/move-prover/tests/sources/functional/references.v2_exp b/third_party/move/move-prover/tests/sources/functional/references.v2_exp new file mode 100644 index 0000000000000..fbb7171105515 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/references.v2_exp @@ -0,0 +1,25 @@ +Move prover returns: exiting with verification errors +error: function does not abort under this condition + ┌─ tests/sources/functional/references.move:76:9 + │ +76 │ aborts_if true; + │ ^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/references.move:69: mut_ref_incorrect + = b = + = at tests/sources/functional/references.move:70: mut_ref_incorrect + = b_ref = + = at tests/sources/functional/references.move:71: mut_ref_incorrect + = = + = at tests/sources/functional/references.move:50: mut_b + = b = + = at tests/sources/functional/references.move:51: mut_b + = at tests/sources/functional/references.move:50: mut_b + = b = + = at tests/sources/functional/references.move:52: mut_b + = at tests/sources/functional/references.move:72: mut_ref_incorrect + = b = + = at tests/sources/functional/references.move:73: mut_ref_incorrect + = = + = at tests/sources/functional/references.move:74: mut_ref_incorrect + = at tests/sources/functional/references.move:76: mut_ref_incorrect (spec) diff --git a/third_party/move/move-prover/tests/sources/functional/resources.v2_exp b/third_party/move/move-prover/tests/sources/functional/resources.v2_exp new file mode 100644 index 0000000000000..9b6c9c6f3fee3 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/resources.v2_exp @@ -0,0 +1,18 @@ +Move prover returns: exiting with verification errors +error: post-condition does not hold + ┌─ tests/sources/functional/resources.move:39:6 + │ +39 │ ensures exists(signer::address_of(account)); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/resources.move:32: create_resource_incorrect + = account = + = at tests/sources/functional/resources.move:33: create_resource_incorrect + = at ../move-stdlib/sources/signer.move:12: address_of + = s = + = at ../move-stdlib/sources/signer.move:13: address_of + = result = + = at ../move-stdlib/sources/signer.move:14: address_of + = at tests/sources/functional/resources.move:36: create_resource_incorrect + = at tests/sources/functional/resources.move:38: create_resource_incorrect (spec) + = at tests/sources/functional/resources.move:39: create_resource_incorrect (spec) diff --git a/third_party/move/move-prover/tests/sources/functional/restrictions.v2_exp b/third_party/move/move-prover/tests/sources/functional/restrictions.v2_exp new file mode 100644 index 0000000000000..947924207b0ce --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/restrictions.v2_exp @@ -0,0 +1,36 @@ +Move prover returns: exiting with condition generation errors +error: [boogie translator] function or tuple result type not yet supported + ┌─ tests/sources/functional/restrictions.move:9:9 + │ +9 │ fun f1(): (u64, u64) { (1u64, 2u64) } + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: [boogie translator] function or tuple result type not yet supported + ┌─ tests/sources/functional/restrictions.move:12:9 + │ +12 │ fun f2(): | |num { | | 1 } + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: [boogie translator] Invoke not yet supported + ┌─ tests/sources/functional/restrictions.move:16:13 + │ +16 │ f(1u64) + │ ^^^^^^^ + +error: [boogie translator] `|x|e` (lambda) currently only supported as argument for `all` or `any` + ┌─ tests/sources/functional/restrictions.move:21:21 + │ +21 │ let f = |x| x + 1; + │ ^^^^^^^^^ + +error: [boogie translator] `|x|e` (lambda) currently only supported as argument for `all` or `any` + ┌─ tests/sources/functional/restrictions.move:50:20 + │ +50 │ ensures f3(|x|x) == f3(|x|x); + │ ^^^^ + +error: [boogie translator] `|x|e` (lambda) currently only supported as argument for `all` or `any` + ┌─ tests/sources/functional/restrictions.move:50:32 + │ +50 │ ensures f3(|x|x) == f3(|x|x); + │ ^^^^ diff --git a/third_party/move/move-prover/tests/sources/functional/return_values.v2_exp b/third_party/move/move-prover/tests/sources/functional/return_values.v2_exp new file mode 100644 index 0000000000000..c0397c319ce73 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/return_values.v2_exp @@ -0,0 +1,34 @@ +Move prover returns: exiting with verification errors +error: post-condition does not hold + ┌─ tests/sources/functional/return_values.move:17:9 + │ +17 │ ensures result_1 == 2; + │ ^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/return_values.move:31: one_two_wrapper_incorrect + = at tests/sources/functional/return_values.move:4: one_two + = result_1 = + = result_2 = + = at tests/sources/functional/return_values.move:5: one_two + = result_1 = + = result_2 = + = at tests/sources/functional/return_values.move:32: one_two_wrapper_incorrect + = at tests/sources/functional/return_values.move:16 + = at tests/sources/functional/return_values.move:34: one_two_wrapper_incorrect (spec) + = at tests/sources/functional/return_values.move:17 + +error: post-condition does not hold + ┌─ tests/sources/functional/return_values.move:60:9 + │ +60 │ ensures false; + │ ^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/return_values.move:57: true_one_wrapper_incorrect + = at tests/sources/functional/return_values.move:40: true_one + = result_1 = + = result_2 = + = at tests/sources/functional/return_values.move:41: true_one + = result_1 = + = result_2 = + = at tests/sources/functional/return_values.move:58: true_one_wrapper_incorrect + = at tests/sources/functional/return_values.move:60: true_one_wrapper_incorrect (spec) diff --git a/third_party/move/move-prover/tests/sources/functional/schema_apply.v2_exp b/third_party/move/move-prover/tests/sources/functional/schema_apply.v2_exp new file mode 100644 index 0000000000000..226c05ee84a21 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/schema_apply.v2_exp @@ -0,0 +1,8 @@ +Move prover returns: exiting with verification errors +error: precondition does not hold at this call + ┌─ tests/sources/functional/schema_apply.move:16:9 + │ +16 │ requires false; + │ ^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/schema_apply.move:16 diff --git a/third_party/move/move-prover/tests/sources/functional/schema_exp.v2_exp b/third_party/move/move-prover/tests/sources/functional/schema_exp.v2_exp new file mode 100644 index 0000000000000..82961576d468d --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/schema_exp.v2_exp @@ -0,0 +1,33 @@ +Move prover returns: exiting with verification errors +error: abort not covered by any of the `aborts_if` clauses + ┌─ tests/sources/functional/schema_exp.move:29:5 + │ +26 │ if (!c) abort(1); + │ -------- abort happened here with code 0x1 + · +29 │ ╭ spec bar_incorrect { +30 │ │ // Once we include a schema with aborts, even conditionally, we need to provide a full spec of the aborts +31 │ │ // behavior. This is because the below translates to `aborts_if c && false`, which reduces +32 │ │ // to `aborts_if false`. +33 │ │ include c ==> DontAborts; +34 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/schema_exp.move:25: bar_incorrect + = c = + = at tests/sources/functional/schema_exp.move:26: bar_incorrect + = ABORTED + +error: post-condition does not hold + ┌─ tests/sources/functional/schema_exp.move:47:9 + │ +47 │ ensures result == i + 2; + │ ^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/schema_exp.move:53: baz_incorrect + = i = + = at tests/sources/functional/schema_exp.move:54: baz_incorrect + = i = + = result = + = at tests/sources/functional/schema_exp.move:55: baz_incorrect + = at tests/sources/functional/schema_exp.move:47 diff --git a/third_party/move/move-prover/tests/sources/functional/schema_name.v2_exp b/third_party/move/move-prover/tests/sources/functional/schema_name.v2_exp new file mode 100644 index 0000000000000..34fa670ee6150 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/schema_name.v2_exp @@ -0,0 +1,9 @@ +Move prover returns: exiting with checking errors +error: A specification variable in the schema TestSchemaName::TestNameConflict conflicts with... + ┌─ tests/sources/functional/schema_name.move:9:16 + │ + 9 │ x: c + 3 + │ ^^^^^ + · +25 │ let c = x > 3; + │ -------------- ...variable c defined here diff --git a/third_party/move/move-prover/tests/sources/functional/script_incorrect.v2_exp b/third_party/move/move-prover/tests/sources/functional/script_incorrect.v2_exp new file mode 100644 index 0000000000000..a2ca4ac009c78 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/script_incorrect.v2_exp @@ -0,0 +1,32 @@ +Move prover returns: exiting with verification errors +error: abort not covered by any of the `aborts_if` clauses + ┌─ tests/sources/functional/script_incorrect.move:12:5 + │ +12 │ ╭ spec main { +13 │ │ aborts_if false; +14 │ │ } + │ ╰─────^ + │ + ┌─ tests/sources/functional/script_provider.move:10:9 + │ +10 │ move_to(account, Info{}) + │ --------------------------- abort happened here with execution failure + │ + = at tests/sources/functional/script_incorrect.move:6: main + = account = + = at tests/sources/functional/script_incorrect.move:8: main + = at tests/sources/functional/script_incorrect.move:10: main + = at tests/sources/functional/script_provider.move:8: register + = account = + = at tests/sources/functional/script_provider.move:9: register + = account = + = at ../move-stdlib/sources/signer.move:12: address_of + = s = + = at ../move-stdlib/sources/signer.move:13: address_of + = result = + = at ../move-stdlib/sources/signer.move:14: address_of + = at tests/sources/functional/script_provider.move:9: register + = at tests/sources/functional/script_provider.move:10: register + = = + = at tests/sources/functional/script_provider.move:10: register + = ABORTED diff --git a/third_party/move/move-prover/tests/sources/functional/serialize_model.v2_exp b/third_party/move/move-prover/tests/sources/functional/serialize_model.v2_exp new file mode 100644 index 0000000000000..faa9e43030cf1 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/serialize_model.v2_exp @@ -0,0 +1,22 @@ +Move prover returns: exiting with verification errors +error: post-condition does not hold + ┌─ tests/sources/functional/serialize_model.move:34:9 + │ +34 │ ensures result_1 == result_2; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/serialize_model.move:26: bcs_test1_incorrect + = v1 = + = v2 = + = at tests/sources/functional/serialize_model.move:28: bcs_test1_incorrect + = v1 = + = at tests/sources/functional/serialize_model.move:29: bcs_test1_incorrect + = v2 = + = at tests/sources/functional/serialize_model.move:30: bcs_test1_incorrect + = s1 = + = s2 = + = result_1 = + = result_2 = + = at tests/sources/functional/serialize_model.move:31: bcs_test1_incorrect + = at tests/sources/functional/serialize_model.move:33: bcs_test1_incorrect (spec) + = at tests/sources/functional/serialize_model.move:34: bcs_test1_incorrect (spec) diff --git a/third_party/move/move-prover/tests/sources/functional/shift.v2_exp b/third_party/move/move-prover/tests/sources/functional/shift.v2_exp new file mode 100644 index 0000000000000..c5b49806a817e --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/shift.v2_exp @@ -0,0 +1,42 @@ +Move prover returns: exiting with verification errors +error: post-condition does not hold + ┌─ tests/sources/functional/shift.move:38:9 + │ +38 │ ensures result == x * 128 + 1; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/shift.move:33: shiftl_7_incorrect + = x = + = at tests/sources/functional/shift.move:34: shiftl_7_incorrect + = x = + = result = + = at tests/sources/functional/shift.move:35: shiftl_7_incorrect + = at tests/sources/functional/shift.move:38: shiftl_7_incorrect (spec) + +error: post-condition does not hold + ┌─ tests/sources/functional/shift.move:54:9 + │ +54 │ ensures result == x / 128 + 1; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/shift.move:49: shiftr_7_incorrect + = x = + = at tests/sources/functional/shift.move:50: shiftr_7_incorrect + = x = + = result = + = at tests/sources/functional/shift.move:51: shiftr_7_incorrect + = at tests/sources/functional/shift.move:54: shiftr_7_incorrect (spec) + +error: post-condition does not hold + ┌─ tests/sources/functional/shift.move:95:9 + │ +95 │ ensures result == x << 10u8; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/shift.move:65: shift_l_11_incorrect + = x = + = at tests/sources/functional/shift.move:66: shift_l_11_incorrect + = x = + = result = + = at tests/sources/functional/shift.move:67: shift_l_11_incorrect + = at tests/sources/functional/shift.move:95: shift_l_11_incorrect (spec) diff --git a/third_party/move/move-prover/tests/sources/functional/signer_display.v2_exp b/third_party/move/move-prover/tests/sources/functional/signer_display.v2_exp new file mode 100644 index 0000000000000..b0522f52eecae --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/signer_display.v2_exp @@ -0,0 +1,10 @@ +Move prover returns: exiting with verification errors +error: unknown assertion failed + ┌─ tests/sources/functional/signer_display.move:7:13 + │ +7 │ assert signer::address_of(account) == @0x1; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/signer_display.move:5: f_incorrect + = account = + = at tests/sources/functional/signer_display.move:7: f_incorrect diff --git a/third_party/move/move-prover/tests/sources/functional/specs_in_fun.v2_exp b/third_party/move/move-prover/tests/sources/functional/specs_in_fun.v2_exp new file mode 100644 index 0000000000000..a631c33087ebb --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/specs_in_fun.v2_exp @@ -0,0 +1,51 @@ +Move prover returns: exiting with verification errors +error: unknown assertion failed + ┌─ tests/sources/functional/specs_in_fun.move:45:13 + │ +45 │ assert x == y; + │ ^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/specs_in_fun.move:42: simple1_incorrect + = x = + = y = + = at tests/sources/functional/specs_in_fun.move:43: simple1_incorrect + = at tests/sources/functional/specs_in_fun.move:45: simple1_incorrect + +error: unknown assertion failed + ┌─ tests/sources/functional/specs_in_fun.move:53:13 + │ +53 │ assert x == y; + │ ^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/specs_in_fun.move:49: simple2_incorrect + = x = + = at tests/sources/functional/specs_in_fun.move:51: simple2_incorrect + = x = + = = + = at tests/sources/functional/specs_in_fun.move:53: simple2_incorrect + +error: unknown assertion failed + ┌─ tests/sources/functional/specs_in_fun.move:60:13 + │ +60 │ assert x > y; + │ ^^^^^^^^^^^^^ + │ + = at tests/sources/functional/specs_in_fun.move:57: simple3_incorrect + = x = + = y = + = at tests/sources/functional/specs_in_fun.move:59: simple3_incorrect + = at tests/sources/functional/specs_in_fun.move:60: simple3_incorrect + +error: unknown assertion failed + ┌─ tests/sources/functional/specs_in_fun.move:69:13 + │ +69 │ assert z > 2*x; + │ ^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/specs_in_fun.move:64: simple4_incorrect + = x = + = y = + = at tests/sources/functional/specs_in_fun.move:66: simple4_incorrect + = x = + = at tests/sources/functional/specs_in_fun.move:68: simple4_incorrect + = at tests/sources/functional/specs_in_fun.move:69: simple4_incorrect diff --git a/third_party/move/move-prover/tests/sources/functional/strong_edges.v2_exp b/third_party/move/move-prover/tests/sources/functional/strong_edges.v2_exp new file mode 100644 index 0000000000000..cca2f7435587a --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/strong_edges.v2_exp @@ -0,0 +1,31 @@ +Move prover returns: exiting with verification errors +error: post-condition does not hold + ┌─ tests/sources/functional/strong_edges.move:54:9 + │ +54 │ ensures global(addr).x == 3; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/strong_edges.move:47: glob_and_field_edges_incorrect + = at tests/sources/functional/strong_edges.move:56: glob_and_field_edges_incorrect (spec) + = at tests/sources/functional/strong_edges.move:47: glob_and_field_edges_incorrect + = addr = + = at tests/sources/functional/strong_edges.move:48: glob_and_field_edges_incorrect + = addr = + = at tests/sources/functional/strong_edges.move:49: glob_and_field_edges_incorrect + = at tests/sources/functional/strong_edges.move:50: glob_and_field_edges_incorrect + = at tests/sources/functional/strong_edges.move:55: glob_and_field_edges_incorrect (spec) + = at tests/sources/functional/strong_edges.move:54: glob_and_field_edges_incorrect (spec) + +error: unknown assertion failed + ┌─ tests/sources/functional/strong_edges.move:64:13 + │ +64 │ assert r == 5; + │ ^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/strong_edges.move:60: loc__edge_incorrect + = r = + = at tests/sources/functional/strong_edges.move:61: loc__edge_incorrect + = r_ref = + = at tests/sources/functional/strong_edges.move:62: loc__edge_incorrect + = r = + = at tests/sources/functional/strong_edges.move:64: loc__edge_incorrect diff --git a/third_party/move/move-prover/tests/sources/functional/trace.v2_exp b/third_party/move/move-prover/tests/sources/functional/trace.v2_exp new file mode 100644 index 0000000000000..3a03fb8ff1529 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/trace.v2_exp @@ -0,0 +1,89 @@ +Move prover returns: exiting with verification errors +error: post-condition does not hold + ┌─ tests/sources/functional/trace.move:19:9 + │ +19 │ ensures result == a + b; + │ ^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = Related Bindings: + = a = + = b = + = result = + = Execution Trace: + = at tests/sources/functional/trace.move:15: add_invalid + = a = + = b = + = at tests/sources/functional/trace.move:16: add_invalid + = result = + = at tests/sources/functional/trace.move:17: add_invalid + = at tests/sources/functional/trace.move:19: add_invalid (spec) + = `ensures result == a + b;` = + +error: post-condition does not hold + ┌─ tests/sources/functional/trace.move:26:9 + │ +26 │ ensures a == old(a) + b; + │ ^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = Related Bindings: + = a = + = b = + = old(a) = + = Execution Trace: + = at tests/sources/functional/trace.move:22: update_invalid + = a = + = b = + = at tests/sources/functional/trace.move:23: update_invalid + = a = + = at tests/sources/functional/trace.move:24: update_invalid + = at tests/sources/functional/trace.move:26: update_invalid (spec) + = `ensures a == old(a) + b;` = + +error: post-condition does not hold + ┌─ tests/sources/functional/trace.move:34:9 + │ +34 │ ensures exists(addr) ==> global(addr).x == x; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = Related Global Memory: + = Resource name: TestTracing_R + = Values: {Address(18467): , Default: empty} + = Related Bindings: + = addr = + = exists(addr) = + = global(addr) = + = x = + = Execution Trace: + = at tests/sources/functional/trace.move:29: publish_invalid + = at tests/sources/functional/trace.move:33: publish_invalid (spec) + = `let addr = signer::address_of(s);` = + = at tests/sources/functional/trace.move:29: publish_invalid + = s = + = x = + = at tests/sources/functional/trace.move:30: publish_invalid + = s = + = x = + = at tests/sources/functional/trace.move:38 + = at tests/sources/functional/trace.move:31: publish_invalid + = at tests/sources/functional/trace.move:34: publish_invalid (spec) + = `ensures exists(addr) ==> global(addr).x == x;` = + +error: global memory invariant does not hold + ┌─ tests/sources/functional/trace.move:38:5 + │ +38 │ invariant forall addr: address: exists(addr) ==> global(addr).x < 5; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = Related Global Memory: + = Resource name: TestTracing_R + = Values: {Address(0): , Default: empty} + = at tests/sources/functional/trace.move:29: publish_invalid + = at tests/sources/functional/trace.move:33: publish_invalid (spec) + = `let addr = signer::address_of(s);` = + = at tests/sources/functional/trace.move:29: publish_invalid + = s = + = x = + = at tests/sources/functional/trace.move:30: publish_invalid + = s = + = x = + = at tests/sources/functional/trace.move:38 diff --git a/third_party/move/move-prover/tests/sources/functional/type_dependent_code.v2_exp b/third_party/move/move-prover/tests/sources/functional/type_dependent_code.v2_exp new file mode 100644 index 0000000000000..9378f56af2a69 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/type_dependent_code.v2_exp @@ -0,0 +1,90 @@ +Move prover returns: exiting with verification errors +error: abort not covered by any of the `aborts_if` clauses + ┌─ tests/sources/functional/type_dependent_code.move:10:5 + │ + 8 │ move_to>(&account, S { x: 0 }); + │ ------------------------------------ abort happened here with execution failure + 9 │ } +10 │ ╭ spec test1 { +11 │ │ aborts_if exists>(signer::address_of(account)); +12 │ │ aborts_if exists>(signer::address_of(account)); +13 │ │ + · │ +19 │ │ // abort condition. +20 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/type_dependent_code.move:6: test1 + = account = + = x = + = at tests/sources/functional/type_dependent_code.move:7: test1 + = at tests/sources/functional/type_dependent_code.move:8: test1 + = ABORTED + +error: abort not covered by any of the `aborts_if` clauses + ┌─ tests/sources/functional/type_dependent_code.move:26:5 + │ +24 │ move_to>(&account, S { x: t2 }); + │ ------------------------------------- abort happened here with execution failure +25 │ } +26 │ ╭ spec test2 { +27 │ │ aborts_if exists>(signer::address_of(account)); +28 │ │ aborts_if exists>(signer::address_of(account)); +29 │ │ + · │ +35 │ │ // abort condition. +36 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/type_dependent_code.move:22: test2 + = account = + = t1 = + = t2 = + = at tests/sources/functional/type_dependent_code.move:23: test2 + = at tests/sources/functional/type_dependent_code.move:24: test2 + = ABORTED + +error: post-condition does not hold + ┌─ tests/sources/functional/type_dependent_code.move:50:9 + │ +50 │ ensures global>(signer::address_of(account)).x == 0; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/type_dependent_code.move:44: test1 + = account = + = x = + = at tests/sources/functional/type_dependent_code.move:45: test1 + = at tests/sources/functional/type_dependent_code.move:46: test1 + = at ../move-stdlib/sources/signer.move:12: address_of + = s = + = at ../move-stdlib/sources/signer.move:13: address_of + = result = + = at ../move-stdlib/sources/signer.move:14: address_of + = account = + = at tests/sources/functional/type_dependent_code.move:47: test1 + = x = + = at tests/sources/functional/type_dependent_code.move:48: test1 + = at tests/sources/functional/type_dependent_code.move:50: test1 (spec) + +error: post-condition does not hold + ┌─ tests/sources/functional/type_dependent_code.move:66:9 + │ +66 │ ensures global>(signer::address_of(account)).x == t1; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/type_dependent_code.move:58: test2 + = account = + = t1 = + = t2 = + = at tests/sources/functional/type_dependent_code.move:61: test2 + = at tests/sources/functional/type_dependent_code.move:62: test2 + = at ../move-stdlib/sources/signer.move:12: address_of + = s = + = at ../move-stdlib/sources/signer.move:13: address_of + = result = + = at ../move-stdlib/sources/signer.move:14: address_of + = account = + = at tests/sources/functional/type_dependent_code.move:63: test2 + = t1 = + = at tests/sources/functional/type_dependent_code.move:64: test2 + = at tests/sources/functional/type_dependent_code.move:66: test2 (spec) diff --git a/third_party/move/move-prover/tests/sources/functional/type_reflection.v2_exp b/third_party/move/move-prover/tests/sources/functional/type_reflection.v2_exp new file mode 100644 index 0000000000000..ecd3713943b67 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/type_reflection.v2_exp @@ -0,0 +1,15 @@ +Move prover returns: exiting with verification errors +error: abort not covered by any of the `aborts_if` clauses + ┌─ tests/sources/functional/type_reflection.move:86:5 + │ +84 │ type_info::type_of() + │ ----------------------- abort happened here with execution failure +85 │ } +86 │ ╭ spec test_type_info_can_abort { +87 │ │ // this should not pass +88 │ │ aborts_if false; +89 │ │ } + │ ╰─────^ + │ + = at tests/sources/functional/type_reflection.move:84: test_type_info_can_abort + = ABORTED diff --git a/third_party/move/move-prover/tests/sources/functional/uninst_global_invariant.v2_exp b/third_party/move/move-prover/tests/sources/functional/uninst_global_invariant.v2_exp new file mode 100644 index 0000000000000..2c7ed9979cce8 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/uninst_global_invariant.v2_exp @@ -0,0 +1,11 @@ +Move prover returns: exiting with verification errors +error: global memory invariant does not hold + ┌─ tests/sources/functional/uninst_global_invariant.move:33:9 + │ +33 │ invariant exists>(@0x42) ==> exists(@0x42); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/uninst_global_invariant.move:11: test2 + = account = + = at tests/sources/functional/uninst_global_invariant.move:12: test2 + = at tests/sources/functional/uninst_global_invariant.move:33 diff --git a/third_party/move/move-prover/tests/sources/functional/unused_global_invariant.v2_exp b/third_party/move/move-prover/tests/sources/functional/unused_global_invariant.v2_exp new file mode 100644 index 0000000000000..30951e414ba90 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/unused_global_invariant.v2_exp @@ -0,0 +1,29 @@ +warning: Global invariant is not checked anywhere in the code + ┌─ tests/sources/functional/unused_global_invariant.move:41:9 + │ +41 │ invariant exists(@0x2) ==> exists(@0x3); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: Global invariant is not checked anywhere in the code + ┌─ tests/sources/functional/unused_global_invariant.move:46:9 + │ +46 │ invariant exists>(@0x2) ==> exists>(@0x3); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: Global invariant is not checked anywhere in the code + ┌─ tests/sources/functional/unused_global_invariant.move:51:9 + │ +51 │ invariant [suspendable] exists(@0x2) ==> exists(@0x3); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: Global invariant is not checked anywhere in the code + ┌─ tests/sources/functional/unused_global_invariant.move:57:9 + │ +57 │ invariant [suspendable] exists>(@0x2) ==> exists>(@0x3); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: Global invariant is not checked anywhere in the code + ┌─ tests/sources/functional/unused_global_invariant.move:63:9 + │ +63 │ invariant exists(@0x2) ==> exists(@0x3); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/third_party/move/move-prover/tests/sources/functional/unused_schema.v2_exp b/third_party/move/move-prover/tests/sources/functional/unused_schema.v2_exp new file mode 100644 index 0000000000000..ad59d3ec627f5 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/unused_schema.v2_exp @@ -0,0 +1,9 @@ +note: unused schema TestUnusedSchema::AddsThree + ┌─ tests/sources/functional/unused_schema.move:22:5 + │ +22 │ ╭ spec schema AddsThree { +23 │ │ i: num; +24 │ │ result: num; +25 │ │ ensures result == i + 3; +26 │ │ } + │ ╰─────^ diff --git a/third_party/move/move-prover/tests/sources/functional/verify_custom_table.v2_exp b/third_party/move/move-prover/tests/sources/functional/verify_custom_table.v2_exp new file mode 100644 index 0000000000000..868c816071271 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/verify_custom_table.v2_exp @@ -0,0 +1,97 @@ +Move prover returns: exiting with verification errors +error: post-condition does not hold + ┌─ tests/sources/functional/verify_custom_table.move:76:9 + │ +76 │ ensures spec_get(result, 1) == 1; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/verify_custom_table.move:69: add_fail + = t = + = at tests/sources/functional/verify_custom_table.move:70: add_fail + = t = + = at tests/sources/functional/verify_custom_table.move:71: add_fail + = t = + = at tests/sources/functional/verify_custom_table.move:72: add_fail + = t = + = at tests/sources/functional/verify_custom_table.move:73: add_fail + = return = + = at tests/sources/functional/verify_custom_table.move:68: add_fail + = result = + = at tests/sources/functional/verify_custom_table.move:74: add_fail + = at tests/sources/functional/verify_custom_table.move:76: add_fail (spec) + +error: post-condition does not hold + ┌─ tests/sources/functional/verify_custom_table.move:210:9 + │ +210 │ ensures result == spec_set(spec_new(), 1, 2); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/verify_custom_table.move:202: create_and_insert_fail_due_to_typed_key_encoding + = t = + = at tests/sources/functional/verify_custom_table.move:203: create_and_insert_fail_due_to_typed_key_encoding + = t = + = at tests/sources/functional/verify_custom_table.move:204: create_and_insert_fail_due_to_typed_key_encoding + = return = + = at tests/sources/functional/verify_custom_table.move:201: create_and_insert_fail_due_to_typed_key_encoding + = result = + = at tests/sources/functional/verify_custom_table.move:205: create_and_insert_fail_due_to_typed_key_encoding + = at tests/sources/functional/verify_custom_table.move:210: create_and_insert_fail_due_to_typed_key_encoding (spec) + +error: post-condition does not hold + ┌─ tests/sources/functional/verify_custom_table.move:219:9 + │ +219 │ ensures result == spec_new(); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/verify_custom_table.move:214: create_and_insert_fail1 + = t = + = at tests/sources/functional/verify_custom_table.move:215: create_and_insert_fail1 + = t = + = at tests/sources/functional/verify_custom_table.move:216: create_and_insert_fail1 + = return = + = at tests/sources/functional/verify_custom_table.move:213: create_and_insert_fail1 + = result = + = at tests/sources/functional/verify_custom_table.move:217: create_and_insert_fail1 + = at tests/sources/functional/verify_custom_table.move:219: create_and_insert_fail1 (spec) + +error: post-condition does not hold + ┌─ tests/sources/functional/verify_custom_table.move:228:9 + │ +228 │ ensures result == spec_set(spec_new(), 1, 2); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/verify_custom_table.move:223: create_and_insert_fail2 + = t = + = at tests/sources/functional/verify_custom_table.move:224: create_and_insert_fail2 + = t = + = at tests/sources/functional/verify_custom_table.move:225: create_and_insert_fail2 + = return = + = at tests/sources/functional/verify_custom_table.move:222: create_and_insert_fail2 + = result = + = at tests/sources/functional/verify_custom_table.move:226: create_and_insert_fail2 + = at tests/sources/functional/verify_custom_table.move:228: create_and_insert_fail2 (spec) + +error: post-condition does not hold + ┌─ tests/sources/functional/verify_custom_table.move:269:9 + │ +269 │ ensures spec_get(result.t, k1) == 23; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/verify_custom_table.move:265: add_R_fail (spec) + = at tests/sources/functional/verify_custom_table.move:266: add_R_fail (spec) + = at tests/sources/functional/verify_custom_table.move:262: add_R_fail + = at tests/sources/functional/verify_custom_table.move:243: make_R + = t = + = at tests/sources/functional/verify_custom_table.move:244: make_R + = t = + = at tests/sources/functional/verify_custom_table.move:245: make_R + = t = + = at tests/sources/functional/verify_custom_table.move:246: make_R + = at tests/sources/functional/verify_custom_table.move:242: make_R + = result = + = at tests/sources/functional/verify_custom_table.move:247: make_R + = result = + = at tests/sources/functional/verify_custom_table.move:263: add_R_fail + = at tests/sources/functional/verify_custom_table.move:267: add_R_fail (spec) + = at tests/sources/functional/verify_custom_table.move:268: add_R_fail (spec) + = at tests/sources/functional/verify_custom_table.move:269: add_R_fail (spec) diff --git a/third_party/move/move-prover/tests/sources/functional/verify_table.v2_exp b/third_party/move/move-prover/tests/sources/functional/verify_table.v2_exp new file mode 100644 index 0000000000000..6a8a1685a62bb --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/verify_table.v2_exp @@ -0,0 +1,46 @@ +Move prover returns: exiting with verification errors +error: post-condition does not hold + ┌─ tests/sources/functional/verify_table.move:31:9 + │ +31 │ ensures spec_get(result, 1) == 1; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/verify_table.move:24: add_fail + = t = + = at tests/sources/functional/verify_table.move:25: add_fail + = t = + = at tests/sources/functional/verify_table.move:26: add_fail + = t = + = at tests/sources/functional/verify_table.move:27: add_fail + = t = + = at tests/sources/functional/verify_table.move:28: add_fail + = return = + = at tests/sources/functional/verify_table.move:23: add_fail + = result = + = at tests/sources/functional/verify_table.move:29: add_fail + = at tests/sources/functional/verify_table.move:31: add_fail (spec) + +error: post-condition does not hold + ┌─ tests/sources/functional/verify_table.move:133:9 + │ +133 │ ensures spec_get(result.t, k1) == 23; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/functional/verify_table.move:129: add_R_fail (spec) + = at tests/sources/functional/verify_table.move:130: add_R_fail (spec) + = at tests/sources/functional/verify_table.move:126: add_R_fail + = at tests/sources/functional/verify_table.move:107: make_R + = t = + = at tests/sources/functional/verify_table.move:108: make_R + = t = + = at tests/sources/functional/verify_table.move:109: make_R + = t = + = at tests/sources/functional/verify_table.move:110: make_R + = at tests/sources/functional/verify_table.move:106: make_R + = result = + = at tests/sources/functional/verify_table.move:111: make_R + = result = + = at tests/sources/functional/verify_table.move:127: add_R_fail + = at tests/sources/functional/verify_table.move:131: add_R_fail (spec) + = at tests/sources/functional/verify_table.move:132: add_R_fail (spec) + = at tests/sources/functional/verify_table.move:133: add_R_fail (spec) diff --git a/third_party/move/move-prover/tests/sources/regression/Escape.v2_exp b/third_party/move/move-prover/tests/sources/regression/Escape.v2_exp new file mode 100644 index 0000000000000..61c149e842496 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/regression/Escape.v2_exp @@ -0,0 +1,27 @@ +Move prover returns: exiting with verification errors +error: global memory invariant does not hold + ┌─ tests/sources/regression/Escape.move:36:5 + │ +36 │ invariant forall addr: address where exists>(addr): addr == @0x123; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/regression/Escape.move:24: install + = account = + = thing = + = at tests/sources/regression/Escape.move:25: install + = account = + = at tests/sources/regression/Escape.move:36 + +error: global memory invariant does not hold + ┌─ tests/sources/regression/Escape.move:37:5 + │ +37 │ invariant forall addr: address where exists>(addr): addr == @0x123; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/regression/Escape.move:24: install + = account = + = thing = + = at tests/sources/regression/Escape.move:25: install + = account = + = at tests/sources/regression/Escape.move:36 + = at tests/sources/regression/Escape.move:37 diff --git a/third_party/move/move-prover/tests/sources/regression/mono_after_global_invariant.v2_exp b/third_party/move/move-prover/tests/sources/regression/mono_after_global_invariant.v2_exp new file mode 100644 index 0000000000000..3e023f0e52b46 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/regression/mono_after_global_invariant.v2_exp @@ -0,0 +1,23 @@ +Move prover returns: exiting with verification errors +error: global memory invariant does not hold + ┌─ tests/sources/regression/mono_after_global_invariant.move:44:9 + │ +44 │ ╭ invariant update +45 │ │ Base::has_b() ==> (has_r() ==> old(has_r())); + │ ╰───────────────────────────────────────────────────────────────^ + │ + = at tests/sources/regression/mono_after_global_invariant.move:30: put_r + = s = + = v = + = at tests/sources/regression/mono_after_global_invariant.move:31: put_r + = s = + = at tests/sources/regression/mono_after_global_invariant.move:9: put_b + = s = + = at tests/sources/regression/mono_after_global_invariant.move:10: put_b + = s = + = at tests/sources/regression/mono_after_global_invariant.move:14: put_b + = at tests/sources/regression/mono_after_global_invariant.move:32: put_r + = v = + = at tests/sources/regression/mono_after_global_invariant.move:30: put_r + = at tests/sources/regression/mono_after_global_invariant.move:32: put_r + = at tests/sources/regression/mono_after_global_invariant.move:44 diff --git a/third_party/move/move-prover/tests/sources/regression/type_param_bug_121721.v2_exp b/third_party/move/move-prover/tests/sources/regression/type_param_bug_121721.v2_exp new file mode 100644 index 0000000000000..c2252d8dd79a8 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/regression/type_param_bug_121721.v2_exp @@ -0,0 +1,24 @@ +Move prover returns: exiting with verification errors +error: global memory invariant does not hold + ┌─ tests/sources/regression/type_param_bug_121721.move:173:9 + │ +173 │ invariant forall addr: address: existing_ballots_have_small_counters(addr); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/regression/type_param_bug_121721.move:80: create_ballot + = ballot_account = + = proposal = + = at tests/sources/regression/type_param_bug_121721.move:84: create_ballot + = ballot_account = + = at ../move-stdlib/sources/signer.move:12: address_of + = s = + = at ../move-stdlib/sources/signer.move:13: address_of + = result = + = at ../move-stdlib/sources/signer.move:14: address_of + = proposal = + = at tests/sources/regression/type_param_bug_121721.move:86: create_ballot + = at tests/sources/regression/type_param_bug_121721.move:88: create_ballot + = at tests/sources/regression/type_param_bug_121721.move:87: create_ballot + = = + = at tests/sources/regression/type_param_bug_121721.move:167 + = at tests/sources/regression/type_param_bug_121721.move:173 diff --git a/third_party/move/move-prover/tests/sources/regression/type_param_bug_200228.v2_exp b/third_party/move/move-prover/tests/sources/regression/type_param_bug_200228.v2_exp new file mode 100644 index 0000000000000..dbc8cf4e7584a --- /dev/null +++ b/third_party/move/move-prover/tests/sources/regression/type_param_bug_200228.v2_exp @@ -0,0 +1,15 @@ +Move prover returns: exiting with verification errors +error: post-condition does not hold + ┌─ tests/sources/regression/type_param_bug_200228.move:12:5 + │ +12 │ ensures old(exists>(addr)) ==> old(exists>(addr)); // original bug: proved by Prover, but should not be. + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + │ + = at tests/sources/regression/type_param_bug_200228.move:6: type_param_bug + = addr = + = at tests/sources/regression/type_param_bug_200228.move:7: type_param_bug + = addr = + = result = + = at tests/sources/regression/type_param_bug_200228.move:8: type_param_bug + = at tests/sources/regression/type_param_bug_200228.move:11: type_param_bug (spec) + = at tests/sources/regression/type_param_bug_200228.move:12: type_param_bug (spec) diff --git a/third_party/move/move-prover/tests/sources/regression/vector_theory_boogie_array.v2_exp b/third_party/move/move-prover/tests/sources/regression/vector_theory_boogie_array.v2_exp new file mode 100644 index 0000000000000..58ed6825a2ef6 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/regression/vector_theory_boogie_array.v2_exp @@ -0,0 +1,21 @@ +Move prover returns: exiting with verification errors +error: post-condition does not hold + ┌─ tests/sources/regression/vector_theory_boogie_array.move:14:9 + │ +14 │ ╭ ensures forall a: address where a != addr: +15 │ │ old(contains(pool, a)) ==> contains(pool, a); + │ ╰─────────────────────────────────────────────────────────^ + │ + = at tests/sources/regression/vector_theory_boogie_array.move:6: f1 + = at tests/sources/regression/vector_theory_boogie_array.move:11: f1 (spec) + = at tests/sources/regression/vector_theory_boogie_array.move:6: f1 + = pool = + = addr = + = at tests/sources/regression/vector_theory_boogie_array.move:7: f1 + = at tests/sources/regression/vector_theory_boogie_array.move:8: f1 + = pool = + = at tests/sources/regression/vector_theory_boogie_array.move:6: f1 + = pool = + = at tests/sources/regression/vector_theory_boogie_array.move:9: f1 + = at tests/sources/regression/vector_theory_boogie_array.move:11: f1 (spec) + = at tests/sources/regression/vector_theory_boogie_array.move:14: f1 (spec) diff --git a/third_party/move/move-prover/tests/testsuite.rs b/third_party/move/move-prover/tests/testsuite.rs index 609d20b068faf..9f9b9e449c60d 100644 --- a/third_party/move/move-prover/tests/testsuite.rs +++ b/third_party/move/move-prover/tests/testsuite.rs @@ -8,7 +8,7 @@ use datatest_stable::Requirements; use itertools::Itertools; use log::{info, warn}; use move_command_line_common::{env::read_env_var, testing::EXP_EXT}; -use move_prover::{cli::Options, run_move_prover}; +use move_prover::{cli::Options, run_move_prover, run_move_prover_v2}; use move_prover_test_utils::{baseline_test::verify_or_update_baseline, extract_test_directives}; use once_cell::sync::OnceCell; use std::{ @@ -39,6 +39,8 @@ struct Feature { enable_in_ci: bool, /// Whether this feature has as a separate baseline file. separate_baseline: bool, + /// Whether the run the v2 compiler tool chain + v2: bool, /// A static function pointer to the runner to be used for datatest. Since datatest /// does not support function values and closures, we need to have a different runner for /// each feature @@ -71,9 +73,22 @@ fn get_features() -> &'static [Feature] { enable_in_ci: true, only_if_requested: false, separate_baseline: false, + v2: false, runner: |p| test_runner_for_feature(p, get_feature_by_name("default")), enabling_condition: |_, _| true, }, + // Tests the default configuration with the v2 compiler chain + Feature { + name: "v2", + flags: &[], + inclusion_mode: InclusionMode::Implicit, + enable_in_ci: true, + only_if_requested: false, + separate_baseline: true, // different traces in .exp file + v2: true, + runner: |p| test_runner_for_feature(p, get_feature_by_name("v2")), + enabling_condition: |_, _| true, + }, // Tests with cvc5 as a backend for boogie. Feature { name: "cvc5", @@ -82,6 +97,7 @@ fn get_features() -> &'static [Feature] { enable_in_ci: false, // Do not enable in CI until we have more data about stability only_if_requested: true, // Only run if requested separate_baseline: false, + v2: false, runner: |p| test_runner_for_feature(p, get_feature_by_name("cvc5")), enabling_condition: |group, _| group == "unit", }, @@ -150,7 +166,12 @@ fn test_runner_for_feature(path: &Path, feature: &Feature) -> datatest_stable::R options.backend.stable_test_output = true; let mut error_writer = Buffer::no_color(); - let mut diags = match run_move_prover(&mut error_writer, options) { + let result = if feature.v2 { + run_move_prover_v2(&mut error_writer, options) + } else { + run_move_prover(&mut error_writer, options) + }; + let mut diags = match result { Ok(()) => "".to_string(), Err(err) => format!("Move prover returns: {}\n", err), }; diff --git a/third_party/move/tools/move-cli/src/base/docgen.rs b/third_party/move/tools/move-cli/src/base/docgen.rs index 71d5e62cf06a4..d8f18cd47112c 100644 --- a/third_party/move/tools/move-cli/src/base/docgen.rs +++ b/third_party/move/tools/move-cli/src/base/docgen.rs @@ -4,7 +4,7 @@ use super::reroot_path; use clap::*; use move_docgen::DocgenOptions; -use move_package::{BuildConfig, ModelConfig}; +use move_package::{BuildConfig, CompilerVersion, ModelConfig}; use std::{fs, path::PathBuf}; /// Generate javadoc style documentation for Move packages @@ -58,9 +58,14 @@ pub struct Docgen { impl Docgen { /// Calling the Docgen pub fn execute(self, path: Option, config: BuildConfig) -> anyhow::Result<()> { + let compiler_version = config + .compiler_config + .compiler_version + .unwrap_or(CompilerVersion::V1); let model = config.move_model_for_package(&reroot_path(path).unwrap(), ModelConfig { all_files_as_targets: false, target_filter: None, + compiler_version, })?; let mut options = DocgenOptions::default(); diff --git a/third_party/move/tools/move-cli/src/base/errmap.rs b/third_party/move/tools/move-cli/src/base/errmap.rs index 9e67cd899082c..4a1c4b7dffe3d 100644 --- a/third_party/move/tools/move-cli/src/base/errmap.rs +++ b/third_party/move/tools/move-cli/src/base/errmap.rs @@ -3,7 +3,7 @@ use super::reroot_path; use clap::*; -use move_package::{BuildConfig, ModelConfig}; +use move_package::{BuildConfig, CompilerVersion, ModelConfig}; use std::path::PathBuf; /// Generate error map for the package and its dependencies at `path` for use by the Move @@ -38,6 +38,7 @@ impl Errmap { let model = config.move_model_for_package(&rerooted_path, ModelConfig { all_files_as_targets: true, target_filter: None, + compiler_version: CompilerVersion::default(), })?; let mut errmap_gen = move_errmapgen::ErrmapGen::new(&model, &errmap_options); errmap_gen.gen(); diff --git a/third_party/move/tools/move-cli/src/base/prove.rs b/third_party/move/tools/move-cli/src/base/prove.rs index 14703957b4d57..54732e4cf5185 100644 --- a/third_party/move/tools/move-cli/src/base/prove.rs +++ b/third_party/move/tools/move-cli/src/base/prove.rs @@ -190,9 +190,11 @@ pub fn run_move_prover( options.set_quiet(); } let now = Instant::now(); + let compiler_version = config.compiler_config.compiler_version.unwrap_or_default(); let mut model = config.move_model_for_package(path, ModelConfig { all_files_as_targets: false, target_filter: target_filter.clone(), + compiler_version, })?; let _temp_dir_holder = if for_test { // Need to ensure a distinct output.bpl file for concurrent execution. In non-test diff --git a/third_party/move/tools/move-package/Cargo.toml b/third_party/move/tools/move-package/Cargo.toml index 6732376f87cc6..6c9b3b6691347 100644 --- a/third_party/move/tools/move-package/Cargo.toml +++ b/third_party/move/tools/move-package/Cargo.toml @@ -39,6 +39,7 @@ move-core-types = { path = "../../move-core/types" } move-docgen = { path = "../../move-prover/move-docgen" } move-model = { path = "../../move-model" } move-symbol-pool = { path = "../../move-symbol-pool" } +log = "0.4.20" move-to-yul = { path = "../../evm/move-to-yul", optional = true } reqwest = { version = "0.11.1", features = ["blocking", "json"] } diff --git a/third_party/move/tools/move-package/src/compilation/model_builder.rs b/third_party/move/tools/move-package/src/compilation/model_builder.rs index c0ec175029515..924374e4d4b10 100644 --- a/third_party/move/tools/move-package/src/compilation/model_builder.rs +++ b/third_party/move/tools/move-package/src/compilation/model_builder.rs @@ -4,12 +4,14 @@ use crate::{ compilation::compiled_package::make_source_and_deps_for_compiler, - resolution::resolution_graph::ResolvedGraph, ModelConfig, + resolution::resolution_graph::ResolvedGraph, CompilerVersion, ModelConfig, }; use anyhow::Result; use itertools::Itertools; use move_compiler::shared::PackagePaths; +use move_compiler_v2::Options; use move_model::{model::GlobalEnv, options::ModelBuilderOptions, run_model_builder_with_options}; +use termcolor::{ColorChoice, StandardStream}; #[derive(Debug, Clone)] pub struct ModelBuilder { @@ -125,12 +127,46 @@ impl ModelBuilder { .build_options .compiler_config .known_attributes; - run_model_builder_with_options( - all_targets, - all_deps, - ModelBuilderOptions::default(), - skip_attribute_checks, - known_attributes, - ) + match self.model_config.compiler_version { + CompilerVersion::V1 => run_model_builder_with_options( + all_targets, + all_deps, + ModelBuilderOptions::default(), + skip_attribute_checks, + known_attributes, + ), + CompilerVersion::V2 => { + let mut options = make_options_for_v2_compiler(all_targets, all_deps); + options.known_attributes = known_attributes.clone(); + options.skip_attribute_checks = skip_attribute_checks; + let mut error_writer = StandardStream::stderr(ColorChoice::Auto); + move_compiler_v2::run_move_compiler_for_analysis(&mut error_writer, options) + }, + } } } + +fn make_options_for_v2_compiler(targets: Vec, deps: Vec) -> Options { + let mut options = Options { + sources: targets + .iter() + .flat_map(|p| p.paths.iter().map(|s| s.to_string()).collect_vec()) + .collect(), + ..Options::default() + }; + options.dependencies = deps + .iter() + .flat_map(|p| p.paths.iter().map(|s| s.to_string()).collect_vec()) + .collect(); + options.named_address_mapping = targets + .into_iter() + .chain(deps) + .flat_map(|p| { + p.named_address_map + .iter() + .map(|(n, a)| format!("{}={}", n, a.into_inner())) + .collect_vec() + }) + .collect_vec(); + options +} diff --git a/third_party/move/tools/move-package/src/lib.rs b/third_party/move/tools/move-package/src/lib.rs index be259ada53b3b..5b2b42dbf4e97 100644 --- a/third_party/move/tools/move-package/src/lib.rs +++ b/third_party/move/tools/move-package/src/lib.rs @@ -194,6 +194,8 @@ pub struct ModelConfig { /// If set, a string how targets are filtered. A target is included if its file name /// contains this string. This is similar as the `cargo test ` idiom. pub target_filter: Option, + /// The compiler version used to build the model + pub compiler_version: CompilerVersion, } impl BuildConfig { diff --git a/third_party/move/tools/move-package/tests/test_runner.rs b/third_party/move/tools/move-package/tests/test_runner.rs index 72476c490526f..9cf3796e3e374 100644 --- a/third_party/move/tools/move-package/tests/test_runner.rs +++ b/third_party/move/tools/move-package/tests/test_runner.rs @@ -3,12 +3,8 @@ // SPDX-License-Identifier: Apache-2.0 use anyhow::bail; -use move_command_line_common::{ - env::read_bool_env_var, - testing::{ - add_update_baseline_fix, format_diff, read_env_update_baseline, EXP_EXT, EXP_EXT_V2, - MOVE_COMPILER_V2, - }, +use move_command_line_common::testing::{ + add_update_baseline_fix, format_diff, read_env_update_baseline, EXP_EXT, EXP_EXT_V2, }; use move_compiler::shared::known_attributes::KnownAttribute; use move_package::{ @@ -33,14 +29,15 @@ use tempfile::tempdir; const COMPILE_EXT: &str = "compile"; const MODEL_EXT: &str = "model"; -fn run_test_impl(path: &Path, v2_flag: bool) -> datatest_stable::Result { +fn run_test_impl( + path: &Path, + compiler_version: CompilerVersion, +) -> datatest_stable::Result { let mut compiler_config = CompilerConfig { known_attributes: KnownAttribute::get_all_attribute_names().clone(), ..Default::default() }; - if v2_flag { - compiler_config.compiler_version = Some(CompilerVersion::V2); - } + compiler_config.compiler_version = Some(compiler_version); let should_compile = path.with_extension(COMPILE_EXT).is_file(); let should_model = path.with_extension(MODEL_EXT).is_file(); let contents = fs::read_to_string(path)?; @@ -87,6 +84,7 @@ fn run_test_impl(path: &Path, v2_flag: bool) -> datatest_stable::Result (_, true) => match ModelBuilder::create(resolved_package, ModelConfig { all_files_as_targets: false, target_filter: None, + compiler_version, }) .build_model() { @@ -111,9 +109,13 @@ fn check_or_update( path: &Path, output: String, update_baseline: bool, - v2_flag: bool, + compiler_version: CompilerVersion, ) -> datatest_stable::Result<()> { - let exp_ext = if v2_flag { EXP_EXT_V2 } else { EXP_EXT }; + let exp_ext = if compiler_version == CompilerVersion::V2 { + EXP_EXT_V2 + } else { + EXP_EXT + }; let exp_path = path.with_extension(exp_ext); let exp_exists = exp_path.is_file(); if update_baseline { @@ -151,17 +153,14 @@ pub fn run_test(path: &Path) -> datatest_stable::Result<()> { return Ok(()); } - let output_v1 = run_test_impl(path, false)?; + let output_v1 = run_test_impl(path, CompilerVersion::default())?; let update_baseline = read_env_update_baseline(); - let res_v1 = check_or_update(path, output_v1.clone(), update_baseline, false); - if read_bool_env_var(MOVE_COMPILER_V2) { - // Run test against v2 when MOVE_COMPILER_V2 is set - let output_v2 = run_test_impl(path, true)?; - if output_v1 != output_v2 { - // TODO: compare the result between V1 and V2. - } - } - res_v1 + check_or_update( + path, + output_v1.clone(), + update_baseline, + CompilerVersion::default(), + ) } /// Some dummy hooks for testing the hook mechanism diff --git a/third_party/move/tools/move-package/tests/test_sources/compilation/basic_no_deps/Move.exp b/third_party/move/tools/move-package/tests/test_sources/compilation/basic_no_deps/Move.exp index 86d31296ce3bf..816366598aa92 100644 --- a/third_party/move/tools/move-package/tests/test_sources/compilation/basic_no_deps/Move.exp +++ b/third_party/move/tools/move-package/tests/test_sources/compilation/basic_no_deps/Move.exp @@ -31,7 +31,9 @@ CompiledPackageInfo { "verify_only", }, skip_attribute_checks: false, - compiler_version: None, + compiler_version: Some( + V1, + ), }, }, } diff --git a/third_party/move/tools/move-package/tests/test_sources/compilation/basic_no_deps_address_assigned/Move.exp b/third_party/move/tools/move-package/tests/test_sources/compilation/basic_no_deps_address_assigned/Move.exp index a5df230858239..abc4820b4b8d0 100644 --- a/third_party/move/tools/move-package/tests/test_sources/compilation/basic_no_deps_address_assigned/Move.exp +++ b/third_party/move/tools/move-package/tests/test_sources/compilation/basic_no_deps_address_assigned/Move.exp @@ -33,7 +33,9 @@ CompiledPackageInfo { "verify_only", }, skip_attribute_checks: false, - compiler_version: None, + compiler_version: Some( + V1, + ), }, }, } diff --git a/third_party/move/tools/move-package/tests/test_sources/compilation/basic_no_deps_address_not_assigned_with_dev_assignment/Move.exp b/third_party/move/tools/move-package/tests/test_sources/compilation/basic_no_deps_address_not_assigned_with_dev_assignment/Move.exp index 490c804a5d01c..ae656b4055f30 100644 --- a/third_party/move/tools/move-package/tests/test_sources/compilation/basic_no_deps_address_not_assigned_with_dev_assignment/Move.exp +++ b/third_party/move/tools/move-package/tests/test_sources/compilation/basic_no_deps_address_not_assigned_with_dev_assignment/Move.exp @@ -33,7 +33,9 @@ CompiledPackageInfo { "verify_only", }, skip_attribute_checks: false, - compiler_version: None, + compiler_version: Some( + V1, + ), }, }, } diff --git a/third_party/move/tools/move-package/tests/test_sources/compilation/basic_no_deps_test_mode/Move.exp b/third_party/move/tools/move-package/tests/test_sources/compilation/basic_no_deps_test_mode/Move.exp index ee73524c678b9..9757a9749e7b6 100644 --- a/third_party/move/tools/move-package/tests/test_sources/compilation/basic_no_deps_test_mode/Move.exp +++ b/third_party/move/tools/move-package/tests/test_sources/compilation/basic_no_deps_test_mode/Move.exp @@ -33,7 +33,9 @@ CompiledPackageInfo { "verify_only", }, skip_attribute_checks: false, - compiler_version: None, + compiler_version: Some( + V1, + ), }, }, } diff --git a/third_party/move/tools/move-package/tests/test_sources/compilation/diamond_problem_backflow_resolution/Move.exp b/third_party/move/tools/move-package/tests/test_sources/compilation/diamond_problem_backflow_resolution/Move.exp index 7b083900dbbcf..5194ca1a281b1 100644 --- a/third_party/move/tools/move-package/tests/test_sources/compilation/diamond_problem_backflow_resolution/Move.exp +++ b/third_party/move/tools/move-package/tests/test_sources/compilation/diamond_problem_backflow_resolution/Move.exp @@ -34,7 +34,9 @@ CompiledPackageInfo { "verify_only", }, skip_attribute_checks: false, - compiler_version: None, + compiler_version: Some( + V1, + ), }, }, } diff --git a/third_party/move/tools/move-package/tests/test_sources/compilation/diamond_problem_no_conflict/Move.exp b/third_party/move/tools/move-package/tests/test_sources/compilation/diamond_problem_no_conflict/Move.exp index 7b083900dbbcf..5194ca1a281b1 100644 --- a/third_party/move/tools/move-package/tests/test_sources/compilation/diamond_problem_no_conflict/Move.exp +++ b/third_party/move/tools/move-package/tests/test_sources/compilation/diamond_problem_no_conflict/Move.exp @@ -34,7 +34,9 @@ CompiledPackageInfo { "verify_only", }, skip_attribute_checks: false, - compiler_version: None, + compiler_version: Some( + V1, + ), }, }, } diff --git a/third_party/move/tools/move-package/tests/test_sources/compilation/multiple_deps_rename/Move.exp b/third_party/move/tools/move-package/tests/test_sources/compilation/multiple_deps_rename/Move.exp index 73bde9249f822..bb47cd6d05d60 100644 --- a/third_party/move/tools/move-package/tests/test_sources/compilation/multiple_deps_rename/Move.exp +++ b/third_party/move/tools/move-package/tests/test_sources/compilation/multiple_deps_rename/Move.exp @@ -35,7 +35,9 @@ CompiledPackageInfo { "verify_only", }, skip_attribute_checks: false, - compiler_version: None, + compiler_version: Some( + V1, + ), }, }, } diff --git a/third_party/move/tools/move-package/tests/test_sources/compilation/multiple_deps_rename_one/Move.exp b/third_party/move/tools/move-package/tests/test_sources/compilation/multiple_deps_rename_one/Move.exp index 4767b4f36a77b..e50985f2f2724 100644 --- a/third_party/move/tools/move-package/tests/test_sources/compilation/multiple_deps_rename_one/Move.exp +++ b/third_party/move/tools/move-package/tests/test_sources/compilation/multiple_deps_rename_one/Move.exp @@ -35,7 +35,9 @@ CompiledPackageInfo { "verify_only", }, skip_attribute_checks: false, - compiler_version: None, + compiler_version: Some( + V1, + ), }, }, } diff --git a/third_party/move/tools/move-package/tests/test_sources/compilation/one_dep/Move.exp b/third_party/move/tools/move-package/tests/test_sources/compilation/one_dep/Move.exp index 5602ae760590a..67e3d2a1f155e 100644 --- a/third_party/move/tools/move-package/tests/test_sources/compilation/one_dep/Move.exp +++ b/third_party/move/tools/move-package/tests/test_sources/compilation/one_dep/Move.exp @@ -33,7 +33,9 @@ CompiledPackageInfo { "verify_only", }, skip_attribute_checks: false, - compiler_version: None, + compiler_version: Some( + V1, + ), }, }, } diff --git a/third_party/move/tools/move-package/tests/test_sources/compilation/one_dep_assigned_address/Move.exp b/third_party/move/tools/move-package/tests/test_sources/compilation/one_dep_assigned_address/Move.exp index 48c2e39472fc4..e2a79584ebe18 100644 --- a/third_party/move/tools/move-package/tests/test_sources/compilation/one_dep_assigned_address/Move.exp +++ b/third_party/move/tools/move-package/tests/test_sources/compilation/one_dep_assigned_address/Move.exp @@ -33,7 +33,9 @@ CompiledPackageInfo { "verify_only", }, skip_attribute_checks: false, - compiler_version: None, + compiler_version: Some( + V1, + ), }, }, } diff --git a/third_party/move/tools/move-package/tests/test_sources/compilation/one_dep_renamed/Move.exp b/third_party/move/tools/move-package/tests/test_sources/compilation/one_dep_renamed/Move.exp index 5602ae760590a..67e3d2a1f155e 100644 --- a/third_party/move/tools/move-package/tests/test_sources/compilation/one_dep_renamed/Move.exp +++ b/third_party/move/tools/move-package/tests/test_sources/compilation/one_dep_renamed/Move.exp @@ -33,7 +33,9 @@ CompiledPackageInfo { "verify_only", }, skip_attribute_checks: false, - compiler_version: None, + compiler_version: Some( + V1, + ), }, }, } diff --git a/third_party/move/tools/move-package/tests/test_sources/compilation/one_dep_with_scripts/Move.exp b/third_party/move/tools/move-package/tests/test_sources/compilation/one_dep_with_scripts/Move.exp index 5602ae760590a..67e3d2a1f155e 100644 --- a/third_party/move/tools/move-package/tests/test_sources/compilation/one_dep_with_scripts/Move.exp +++ b/third_party/move/tools/move-package/tests/test_sources/compilation/one_dep_with_scripts/Move.exp @@ -33,7 +33,9 @@ CompiledPackageInfo { "verify_only", }, skip_attribute_checks: false, - compiler_version: None, + compiler_version: Some( + V1, + ), }, }, } diff --git a/third_party/move/tools/move-package/tests/test_sources/compilation/test_symlinks/Move.exp b/third_party/move/tools/move-package/tests/test_sources/compilation/test_symlinks/Move.exp index a5df230858239..abc4820b4b8d0 100644 --- a/third_party/move/tools/move-package/tests/test_sources/compilation/test_symlinks/Move.exp +++ b/third_party/move/tools/move-package/tests/test_sources/compilation/test_symlinks/Move.exp @@ -33,7 +33,9 @@ CompiledPackageInfo { "verify_only", }, skip_attribute_checks: false, - compiler_version: None, + compiler_version: Some( + V1, + ), }, }, } diff --git a/third_party/move/tools/move-package/tests/test_sources/parsing/invalid_identifier_package_name/Move.exp b/third_party/move/tools/move-package/tests/test_sources/parsing/invalid_identifier_package_name/Move.exp index 22ecb6d00433c..29dc4156ad3b2 100644 --- a/third_party/move/tools/move-package/tests/test_sources/parsing/invalid_identifier_package_name/Move.exp +++ b/third_party/move/tools/move-package/tests/test_sources/parsing/invalid_identifier_package_name/Move.exp @@ -27,7 +27,9 @@ ResolutionGraph { "verify_only", }, skip_attribute_checks: false, - compiler_version: None, + compiler_version: Some( + V1, + ), }, }, root_package: SourceManifest { diff --git a/third_party/move/tools/move-package/tests/test_sources/parsing/minimal_manifest/Move.exp b/third_party/move/tools/move-package/tests/test_sources/parsing/minimal_manifest/Move.exp index 86076cf75b4fe..606e23cb8fb4c 100644 --- a/third_party/move/tools/move-package/tests/test_sources/parsing/minimal_manifest/Move.exp +++ b/third_party/move/tools/move-package/tests/test_sources/parsing/minimal_manifest/Move.exp @@ -27,7 +27,9 @@ ResolutionGraph { "verify_only", }, skip_attribute_checks: false, - compiler_version: None, + compiler_version: Some( + V1, + ), }, }, root_package: SourceManifest { diff --git a/third_party/move/tools/move-package/tests/test_sources/resolution/basic_no_deps/Move.exp b/third_party/move/tools/move-package/tests/test_sources/resolution/basic_no_deps/Move.exp index 948b9da9f6191..1a4b431008633 100644 --- a/third_party/move/tools/move-package/tests/test_sources/resolution/basic_no_deps/Move.exp +++ b/third_party/move/tools/move-package/tests/test_sources/resolution/basic_no_deps/Move.exp @@ -27,7 +27,9 @@ ResolutionGraph { "verify_only", }, skip_attribute_checks: false, - compiler_version: None, + compiler_version: Some( + V1, + ), }, }, root_package: SourceManifest { diff --git a/third_party/move/tools/move-package/tests/test_sources/resolution/basic_no_deps_address_assigned/Move.exp b/third_party/move/tools/move-package/tests/test_sources/resolution/basic_no_deps_address_assigned/Move.exp index 647ee7dc73383..59dcd290a9bd9 100644 --- a/third_party/move/tools/move-package/tests/test_sources/resolution/basic_no_deps_address_assigned/Move.exp +++ b/third_party/move/tools/move-package/tests/test_sources/resolution/basic_no_deps_address_assigned/Move.exp @@ -27,7 +27,9 @@ ResolutionGraph { "verify_only", }, skip_attribute_checks: false, - compiler_version: None, + compiler_version: Some( + V1, + ), }, }, root_package: SourceManifest { diff --git a/third_party/move/tools/move-package/tests/test_sources/resolution/basic_no_deps_address_not_assigned_with_dev_assignment/Move.exp b/third_party/move/tools/move-package/tests/test_sources/resolution/basic_no_deps_address_not_assigned_with_dev_assignment/Move.exp index 49b7d4cfa69b2..63305bf4697be 100644 --- a/third_party/move/tools/move-package/tests/test_sources/resolution/basic_no_deps_address_not_assigned_with_dev_assignment/Move.exp +++ b/third_party/move/tools/move-package/tests/test_sources/resolution/basic_no_deps_address_not_assigned_with_dev_assignment/Move.exp @@ -27,7 +27,9 @@ ResolutionGraph { "verify_only", }, skip_attribute_checks: false, - compiler_version: None, + compiler_version: Some( + V1, + ), }, }, root_package: SourceManifest { diff --git a/third_party/move/tools/move-package/tests/test_sources/resolution/dep_good_digest/Move.exp b/third_party/move/tools/move-package/tests/test_sources/resolution/dep_good_digest/Move.exp index af4bf37f42e8e..26ff5c843afd9 100644 --- a/third_party/move/tools/move-package/tests/test_sources/resolution/dep_good_digest/Move.exp +++ b/third_party/move/tools/move-package/tests/test_sources/resolution/dep_good_digest/Move.exp @@ -27,7 +27,9 @@ ResolutionGraph { "verify_only", }, skip_attribute_checks: false, - compiler_version: None, + compiler_version: Some( + V1, + ), }, }, root_package: SourceManifest { diff --git a/third_party/move/tools/move-package/tests/test_sources/resolution/diamond_problem_backflow_resolution/Move.exp b/third_party/move/tools/move-package/tests/test_sources/resolution/diamond_problem_backflow_resolution/Move.exp index 39828b5d0308f..c29c1a9f59014 100644 --- a/third_party/move/tools/move-package/tests/test_sources/resolution/diamond_problem_backflow_resolution/Move.exp +++ b/third_party/move/tools/move-package/tests/test_sources/resolution/diamond_problem_backflow_resolution/Move.exp @@ -27,7 +27,9 @@ ResolutionGraph { "verify_only", }, skip_attribute_checks: false, - compiler_version: None, + compiler_version: Some( + V1, + ), }, }, root_package: SourceManifest { diff --git a/third_party/move/tools/move-package/tests/test_sources/resolution/diamond_problem_no_conflict/Move.exp b/third_party/move/tools/move-package/tests/test_sources/resolution/diamond_problem_no_conflict/Move.exp index 198c4b507c4b1..e0d1adf994388 100644 --- a/third_party/move/tools/move-package/tests/test_sources/resolution/diamond_problem_no_conflict/Move.exp +++ b/third_party/move/tools/move-package/tests/test_sources/resolution/diamond_problem_no_conflict/Move.exp @@ -27,7 +27,9 @@ ResolutionGraph { "verify_only", }, skip_attribute_checks: false, - compiler_version: None, + compiler_version: Some( + V1, + ), }, }, root_package: SourceManifest { diff --git a/third_party/move/tools/move-package/tests/test_sources/resolution/multiple_deps_rename/Move.exp b/third_party/move/tools/move-package/tests/test_sources/resolution/multiple_deps_rename/Move.exp index 57118d5aaa909..cfe74d8e285a6 100644 --- a/third_party/move/tools/move-package/tests/test_sources/resolution/multiple_deps_rename/Move.exp +++ b/third_party/move/tools/move-package/tests/test_sources/resolution/multiple_deps_rename/Move.exp @@ -27,7 +27,9 @@ ResolutionGraph { "verify_only", }, skip_attribute_checks: false, - compiler_version: None, + compiler_version: Some( + V1, + ), }, }, root_package: SourceManifest { diff --git a/third_party/move/tools/move-package/tests/test_sources/resolution/one_dep/Move.exp b/third_party/move/tools/move-package/tests/test_sources/resolution/one_dep/Move.exp index afdd7ac5f2aa7..d77da04ad6c9e 100644 --- a/third_party/move/tools/move-package/tests/test_sources/resolution/one_dep/Move.exp +++ b/third_party/move/tools/move-package/tests/test_sources/resolution/one_dep/Move.exp @@ -27,7 +27,9 @@ ResolutionGraph { "verify_only", }, skip_attribute_checks: false, - compiler_version: None, + compiler_version: Some( + V1, + ), }, }, root_package: SourceManifest { diff --git a/third_party/move/tools/move-package/tests/test_sources/resolution/one_dep_assigned_address/Move.exp b/third_party/move/tools/move-package/tests/test_sources/resolution/one_dep_assigned_address/Move.exp index 9e13f696bed1d..3da34c4251071 100644 --- a/third_party/move/tools/move-package/tests/test_sources/resolution/one_dep_assigned_address/Move.exp +++ b/third_party/move/tools/move-package/tests/test_sources/resolution/one_dep_assigned_address/Move.exp @@ -27,7 +27,9 @@ ResolutionGraph { "verify_only", }, skip_attribute_checks: false, - compiler_version: None, + compiler_version: Some( + V1, + ), }, }, root_package: SourceManifest { diff --git a/third_party/move/tools/move-package/tests/test_sources/resolution/one_dep_multiple_of_same_name/Move.exp b/third_party/move/tools/move-package/tests/test_sources/resolution/one_dep_multiple_of_same_name/Move.exp index 1d3364ad68a78..bbd4403872d2f 100644 --- a/third_party/move/tools/move-package/tests/test_sources/resolution/one_dep_multiple_of_same_name/Move.exp +++ b/third_party/move/tools/move-package/tests/test_sources/resolution/one_dep_multiple_of_same_name/Move.exp @@ -27,7 +27,9 @@ ResolutionGraph { "verify_only", }, skip_attribute_checks: false, - compiler_version: None, + compiler_version: Some( + V1, + ), }, }, root_package: SourceManifest { diff --git a/third_party/move/tools/move-package/tests/test_sources/resolution/one_dep_reassigned_address/Move.exp b/third_party/move/tools/move-package/tests/test_sources/resolution/one_dep_reassigned_address/Move.exp index 4fdae610527f5..02cff20f9066d 100644 --- a/third_party/move/tools/move-package/tests/test_sources/resolution/one_dep_reassigned_address/Move.exp +++ b/third_party/move/tools/move-package/tests/test_sources/resolution/one_dep_reassigned_address/Move.exp @@ -27,7 +27,9 @@ ResolutionGraph { "verify_only", }, skip_attribute_checks: false, - compiler_version: None, + compiler_version: Some( + V1, + ), }, }, root_package: SourceManifest { diff --git a/third_party/move/tools/move-package/tests/test_sources/resolution/one_dep_unification_across_local_renamings/Move.exp b/third_party/move/tools/move-package/tests/test_sources/resolution/one_dep_unification_across_local_renamings/Move.exp index e9be580d68da4..c0001f10c414b 100644 --- a/third_party/move/tools/move-package/tests/test_sources/resolution/one_dep_unification_across_local_renamings/Move.exp +++ b/third_party/move/tools/move-package/tests/test_sources/resolution/one_dep_unification_across_local_renamings/Move.exp @@ -27,7 +27,9 @@ ResolutionGraph { "verify_only", }, skip_attribute_checks: false, - compiler_version: None, + compiler_version: Some( + V1, + ), }, }, root_package: SourceManifest { From a14b583e4e9eae694a980fd50bef7d6f54285a12 Mon Sep 17 00:00:00 2001 From: Wolfgang Grieskamp Date: Wed, 20 Mar 2024 12:32:00 -0700 Subject: [PATCH 2/3] Addressing reviewer comments --- .../file_format_generator/function_generator.rs | 7 ++++--- .../src/file_format_generator/module_generator.rs | 5 +---- .../tests/reference-safety/duplicate_use.exp | 7 +++++++ .../tests/reference-safety/duplicate_use.move | 15 +++++++++++++++ 4 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 third_party/move/move-compiler-v2/tests/reference-safety/duplicate_use.exp create mode 100644 third_party/move/move-compiler-v2/tests/reference-safety/duplicate_use.move diff --git a/third_party/move/move-compiler-v2/src/file_format_generator/function_generator.rs b/third_party/move/move-compiler-v2/src/file_format_generator/function_generator.rs index 42132bc41096b..930d449b6aa18 100644 --- a/third_party/move/move-compiler-v2/src/file_format_generator/function_generator.rs +++ b/third_party/move/move-compiler-v2/src/file_format_generator/function_generator.rs @@ -39,7 +39,7 @@ pub struct FunctionGenerator<'a> { locals: Vec, /// A map from branching labels to information about them. label_info: BTreeMap, - /// A mao from code offset to spec blocks associated with them + /// A map from code offset to spec blocks associated with them spec_blocks: BTreeMap, /// The generated code code: Vec, @@ -232,7 +232,8 @@ impl<'a> FunctionGenerator<'a> { } } - /// Compute the set of temporaries which are referenced in borrow instructions. + /// Compute the set of temporaries which are referenced in borrow instructions, or which + /// are used in specification blocks. /// TODO: right now we also pin locals which are parameter of the destroy instruction. /// This is needed since we cannot determine whether the local has been already moved on /// the stack and is not longer available in the associated local. This needs to be reworked @@ -247,7 +248,7 @@ impl<'a> FunctionGenerator<'a> { Bytecode::SpecBlock(_, spec) => { // All Temporaries used in the spec need to be pinned. Notice that // any bound variables inside the spec are LocalVar, so we can just - // unconditionally collect them. + // unconditionally collect all Temporary instances. let mut collect = |exp: &ExpData| { if let ExpData::Temporary(_, temp) = exp { result.insert(*temp); diff --git a/third_party/move/move-compiler-v2/src/file_format_generator/module_generator.rs b/third_party/move/move-compiler-v2/src/file_format_generator/module_generator.rs index 78d56f396b42a..c360effe79004 100644 --- a/third_party/move/move-compiler-v2/src/file_format_generator/module_generator.rs +++ b/third_party/move/move-compiler-v2/src/file_format_generator/module_generator.rs @@ -8,7 +8,6 @@ use crate::file_format_generator::{ MAX_STRUCT_DEF_INST_COUNT, }; use codespan_reporting::diagnostic::Severity; -use itertools::Itertools; use move_binary_format::{ file_format as FF, file_format::{FunctionHandle, ModuleHandle, StructDefinitionIndex, TableIndex}, @@ -184,9 +183,7 @@ impl ModuleGenerator { .expect(SOURCE_MAP_OK); } let struct_handle = self.struct_index(ctx, loc, struct_env); - let fields = struct_env - .get_fields() - .sorted_by(|a, b| a.get_offset().cmp(&b.get_offset())); + let fields = struct_env.get_fields(); let field_information = FF::StructFieldInformation::Declared( fields .map(|f| { diff --git a/third_party/move/move-compiler-v2/tests/reference-safety/duplicate_use.exp b/third_party/move/move-compiler-v2/tests/reference-safety/duplicate_use.exp new file mode 100644 index 0000000000000..fca6dfb9b9abc --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/reference-safety/duplicate_use.exp @@ -0,0 +1,7 @@ + +Diagnostics: +error: same mutable reference in local `x` is used again in argument list + ┌─ tests/reference-safety/duplicate_use.move:8:9 + │ +8 │ mut_ref(x, x) + │ ^^^^^^^^^^^^^ requirement enforced here diff --git a/third_party/move/move-compiler-v2/tests/reference-safety/duplicate_use.move b/third_party/move/move-compiler-v2/tests/reference-safety/duplicate_use.move new file mode 100644 index 0000000000000..d7864ecbdbc7b --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/reference-safety/duplicate_use.move @@ -0,0 +1,15 @@ +module 0x8675309::M { + + fun ok(x: &u64) { + ref(x, x) + } + + fun fail(x: &mut u64) { + mut_ref(x, x) + } + + fun ref(_x: &u64, _y: &u64){} + fun mut_ref(_x: &mut u64, _y: &mut u64){} + + +} From 221845afa301b5f84573e33d6ec11a2998a42b4f Mon Sep 17 00:00:00 2001 From: Wolfgang Grieskamp Date: Wed, 20 Mar 2024 15:15:54 -0700 Subject: [PATCH 3/3] Fixing things after optimization is on by default - Needed to pin temps for variable coalascing. This has been done by making `get_pinned_temps` a shared function between coalascing and function generator - Needed to consider spec temp usages if `track_all_targets` is set in LiveVarAnalysis. This is needed so dead store elimination does not remove assignments used in specs. - Renamed `used_temporaries` to `used_temporaries_with_types` and let the original function work without global env and delivering types, so it can be used in places were no env is available. - Make `MOVE_COMPILER_V2` turn on compiler v2 also for prover runs - Extended `move_pr.sh` with a new option `-2` which makes it run all integration tests v2, as we do on github --- .../src/bytecode_generator.rs | 2 +- .../function_generator.rs | 36 ++--------- .../src/pipeline/avail_copies_analysis.rs | 30 +++++----- .../pipeline/livevar_analysis_processor.rs | 15 +++-- .../src/pipeline/variable_coalescing.rs | 11 ++-- .../bytecode-generator/borrow_invalid.exp | 60 ++----------------- .../bytecode/src/function_target.rs | 36 +++++++---- .../bytecode/src/livevar_analysis.rs | 2 +- third_party/move/move-model/src/ast.rs | 43 ++++++++++++- .../boogie-backend/src/spec_translator.rs | 2 +- .../data_invariant_instrumentation/borrow.exp | 10 ++-- .../data_invariant_instrumentation/pack.exp | 2 +- .../data_invariant_instrumentation/params.exp | 8 +-- .../borrow.exp | 4 +- .../global_invariant_instrumentation/move.exp | 8 +-- .../update.exp | 2 +- .../tests/spec_instrumentation/fun_spec.exp | 50 ++++++++-------- .../tests/spec_instrumentation/modifies.exp | 36 +++++------ .../spec_instrumentation/opaque_call.exp | 44 +++++++------- third_party/move/move-prover/src/cli.rs | 1 + .../functional/ModifiesSchemaTest.v2_exp | 3 +- .../tests/sources/functional/aborts_if.v2_exp | 3 + .../functional/aborts_if_with_code.v2_exp | 6 +- .../tests/sources/functional/choice.v2_exp | 8 +-- .../data_invariant_for_mut_ref_arg.v2_exp | 1 - .../functional/data_invariant_in_map.v2_exp | 4 +- .../tests/sources/functional/emits.v2_exp | 12 ++-- .../functional/fixed_point_arithm.v2_exp | 30 ++++++---- .../sources/functional/hash_model.v2_exp | 8 --- .../functional/hash_model_invalid.v2_exp | 8 --- .../sources/functional/invariants.v2_exp | 7 +-- .../sources/functional/is_txn_signer.v2_exp | 3 +- .../tests/sources/functional/let.v2_exp | 9 ++- .../sources/functional/loop_unroll.v2_exp | 20 +++---- .../tests/sources/functional/loops.v2_exp | 2 - .../functional/loops_with_memory_ops.v2_exp | 29 ++++----- .../tests/sources/functional/mut_ref.v2_exp | 1 + .../functional/nested_invariants.v2_exp | 4 +- .../functional/nonlinear_arithm.v2_exp | 3 + .../sources/functional/references.v2_exp | 1 - .../sources/functional/serialize_model.v2_exp | 4 -- .../sources/functional/specs_in_fun.v2_exp | 1 + .../sources/functional/strong_edges.v2_exp | 5 +- .../tests/sources/functional/trace.v2_exp | 4 ++ .../functional/type_dependent_code.v2_exp | 6 +- .../functional/verify_custom_table.v2_exp | 8 +-- .../sources/functional/verify_table.v2_exp | 2 +- .../regression/type_param_bug_121721.v2_exp | 3 +- .../regression/type_param_bug_200228.v2_exp | 1 - third_party/move/scripts/move_pr.sh | 16 ++++- .../move/tools/move-package/Cargo.toml | 2 +- 51 files changed, 302 insertions(+), 314 deletions(-) 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 b4034adf5d141..3e245a7f2f89d 100644 --- a/third_party/move/move-compiler-v2/src/bytecode_generator.rs +++ b/third_party/move/move-compiler-v2/src/bytecode_generator.rs @@ -1367,7 +1367,7 @@ impl<'env> Generator<'env> { .map(|p| p.0) .collect::>(); let mut rhs_vars = rhs - .used_temporaries(self.env()) + .used_temporaries_with_types(self.env()) .into_iter() .map(|t| param_symbols[t.0]) .collect::>(); diff --git a/third_party/move/move-compiler-v2/src/file_format_generator/function_generator.rs b/third_party/move/move-compiler-v2/src/file_format_generator/function_generator.rs index 930d449b6aa18..4e608d72f2165 100644 --- a/third_party/move/move-compiler-v2/src/file_format_generator/function_generator.rs +++ b/third_party/move/move-compiler-v2/src/file_format_generator/function_generator.rs @@ -171,7 +171,11 @@ impl<'a> FunctionGenerator<'a> { /// Generates code for a function. fn gen_code(&mut self, ctx: &FunctionContext<'_>) -> FF::CodeUnit { // Initialize the abstract virtual machine - self.pinned = Self::pinned_temps(ctx); + // TODO: right now we pin temps which are parameter of the drop instruction. + // This is needed since we cannot determine whether the local has been already moved on + // the stack and is not longer available in the associated local. This needs to be reworked + // to avoid this. + self.pinned = ctx.fun.get_pinned_temps(/*include_drop*/ true); self.temps = (0..ctx.fun.get_parameter_count()) .map(|temp| (temp, TempInfo::new(self.temp_to_local(ctx, None, temp)))) .collect(); @@ -232,36 +236,6 @@ impl<'a> FunctionGenerator<'a> { } } - /// Compute the set of temporaries which are referenced in borrow instructions, or which - /// are used in specification blocks. - /// TODO: right now we also pin locals which are parameter of the destroy instruction. - /// This is needed since we cannot determine whether the local has been already moved on - /// the stack and is not longer available in the associated local. This needs to be reworked - /// to avoid this. - fn pinned_temps(ctx: &FunctionContext) -> BTreeSet { - let mut result = BTreeSet::new(); - for bc in ctx.fun.get_bytecode() { - match bc { - Bytecode::Call(_, _, Operation::BorrowLoc | Operation::Drop, args, _) => { - result.insert(args[0]); - }, - Bytecode::SpecBlock(_, spec) => { - // All Temporaries used in the spec need to be pinned. Notice that - // any bound variables inside the spec are LocalVar, so we can just - // unconditionally collect all Temporary instances. - let mut collect = |exp: &ExpData| { - if let ExpData::Temporary(_, temp) = exp { - result.insert(*temp); - } - }; - spec.visit_post_order(&mut collect) - }, - _ => {}, - } - } - result - } - /// Generate file-format bytecode from a stackless bytecode and an optional next bytecode /// for peephole optimizations. fn gen_bytecode(&mut self, ctx: &BytecodeContext, bc: &Bytecode, next_bc: Option<&Bytecode>) { diff --git a/third_party/move/move-compiler-v2/src/pipeline/avail_copies_analysis.rs b/third_party/move/move-compiler-v2/src/pipeline/avail_copies_analysis.rs index 9dff848a3bdf3..97abf8a71508a 100644 --- a/third_party/move/move-compiler-v2/src/pipeline/avail_copies_analysis.rs +++ b/third_party/move/move-compiler-v2/src/pipeline/avail_copies_analysis.rs @@ -12,9 +12,9 @@ //! along all possible program paths such that neither `a` nor `b` is overwritten along any of these paths. //! That is, `a` and `b` are always available unmodified at `P` after the copy `a := b`, //! making it definitely available. -//! In the current implementation, variables that are borrowed are excluded from being a part of an -//! available copy. We can make this analysis more precise by having more refined rules when it comes -//! to borrowed variables. +//! In the current implementation, variables that are borrowed or which are used in specs ('pinned' +//! variables) are excluded from being a part of an available copy. We can make this analysis more +//! precise by having more refined rules when it comes to borrowed variables. //! //! This is a forward "must" analysis. //! In a forward analysis, we reason about facts at a program point `P` using facts at its predecessors. @@ -46,7 +46,7 @@ impl AvailCopies { } /// Make a copy `dst := src` available. - /// Neither `dst` nor `src` should be borrowed locals. + /// Neither `dst` nor `src` should be pinned. /// To call this method, `dst := x` should not already be available for any `x`. fn make_copy_available(&mut self, dst: TempIndex, src: TempIndex) { if src == dst { @@ -64,7 +64,7 @@ impl AvailCopies { } /// Kill all available copies of the form `x := y` where `x` or `y` is `tmp`. - /// Note that `tmp` should not be a borrowed local. + /// Note that `tmp` should not be a pinned temporary. fn kill_copies_with(&mut self, tmp: TempIndex) { // TODO: consider optimizing the following operation by keeping a two-way map between // `dst -> src` and `src -> set(dst)`. Another optimization to consider is to use im::OrdMap. @@ -149,14 +149,16 @@ impl AvailCopiesAnnotation { /// The definitely available copies analysis for a function. pub struct AvailCopiesAnalysis { - borrowed_locals: BTreeSet, // Locals borrowed in the function being analyzed. + /// Temporaries pinned because they are borrowed or used in specs. + pinned_temps: BTreeSet, } impl AvailCopiesAnalysis { /// Create a new instance of definitely available copies analysis. - /// `borrowed_locals` is the set of locals that have been borrowed in function being analyzed. - pub fn new(borrowed_locals: BTreeSet) -> Self { - Self { borrowed_locals } + /// `pinned_temps` is the set of temporaries that have been borrowed + /// or used in specs in function being analyzed. + pub fn new(pinned_temps: BTreeSet) -> Self { + Self { pinned_temps } } /// Analyze the given function and return the definitely available copies annotation. @@ -184,15 +186,15 @@ impl TransferFunctions for AvailCopiesAnalysis { fn execute(&self, state: &mut Self::State, instr: &Bytecode, _offset: CodeOffset) { use Bytecode::*; instr.dests().iter().for_each(|dst| { - if !self.borrowed_locals.contains(dst) { - // We don't track copies of borrowed locals, so no need to kill them. + if !self.pinned_temps.contains(dst) { + // We don't track copies of pinned temps, so no need to kill them. state.kill_copies_with(*dst); } }); if let Assign(_, dst, src, _) = instr { - if !self.borrowed_locals.contains(dst) && !self.borrowed_locals.contains(src) { + if !self.pinned_temps.contains(dst) && !self.pinned_temps.contains(src) { // Note that we are conservative here for the sake of simplicity, and disallow - // tracking copies when either `dst` or `src` is borrowed. + // tracking copies when either `dst` or `src` is pinned. // We could track more copies as available by using the reference analysis. state.make_copy_available(*dst, *src); } @@ -217,7 +219,7 @@ impl FunctionTargetProcessor for AvailCopiesAnalysisProcessor { return data; } let target = FunctionTarget::new(func_env, &data); - let analysis = AvailCopiesAnalysis::new(target.get_borrowed_locals()); + let analysis = AvailCopiesAnalysis::new(target.get_pinned_temps(false)); let annotation = analysis.analyze(&target); data.annotations.set(annotation, true); data diff --git a/third_party/move/move-compiler-v2/src/pipeline/livevar_analysis_processor.rs b/third_party/move/move-compiler-v2/src/pipeline/livevar_analysis_processor.rs index 4ea1d62f1c83e..009c9aa8dee6b 100644 --- a/third_party/move/move-compiler-v2/src/pipeline/livevar_analysis_processor.rs +++ b/third_party/move/move-compiler-v2/src/pipeline/livevar_analysis_processor.rs @@ -198,7 +198,9 @@ impl FunctionTargetProcessor for LiveVarAnalysisProcessor { impl LiveVarAnalysisProcessor { /// Create a new instance of live variable analysis. /// `track_all_usages` determines whether both primary and secondary usages of a variable are - /// tracked (when true), or only the primary usages (when false). + /// tracked (when true), or only the primary usages (when false). Also, if set, all usages + /// of temporaries in specifications are tracked, which are considered as secondary because + /// they are not part of the execution semantics. /// Unless all usages are needed, it is recommended to set `track_all_usages` to false. pub fn new(track_all_usages: bool) -> Self { Self { track_all_usages } @@ -371,9 +373,14 @@ impl<'a> TransferFunctions for LiveVarAnalysis<'a> { Branch(id, _, _, src) => { state.insert_or_update(*src, self.livevar_info(id, offset), self.track_all_usages); }, - Prop(id, _, exp) => { - for (idx, _) in exp.used_temporaries(self.func_target.global_env()) { - state.livevars.insert(idx, self.livevar_info(id, offset)); + Prop(id, _, exp) if self.track_all_usages => { + for idx in exp.used_temporaries() { + state.insert_or_update(idx, self.livevar_info(id, offset), true); + } + }, + SpecBlock(id, spec) if self.track_all_usages => { + for idx in spec.used_temporaries() { + state.insert_or_update(idx, self.livevar_info(id, offset), true); } }, _ => {}, diff --git a/third_party/move/move-compiler-v2/src/pipeline/variable_coalescing.rs b/third_party/move/move-compiler-v2/src/pipeline/variable_coalescing.rs index 572ab33e2ed78..b11b7bcb85cfb 100644 --- a/third_party/move/move-compiler-v2/src/pipeline/variable_coalescing.rs +++ b/third_party/move/move-compiler-v2/src/pipeline/variable_coalescing.rs @@ -123,9 +123,10 @@ impl VariableCoalescing { .get_annotations() .get::() .expect("live var annotation is a prerequisite"); - // Note: we currently exclude all the variables that are borrowed from participating in this - // transformation, which is safe. However, we could be more precise in this regard. - let borrowed_locals = target.get_borrowed_locals(); + // Note: we currently exclude all the variables that are borrowed or appear in spec blocks + // from participating in this transformation, which is safe. However, we could be more + // precise in this regard. + let pinned_locals = target.get_pinned_temps(false); // Initially, all locals have trivial live intervals. // They are made more precise using live variable analysis. let mut live_intervals = std::iter::repeat_with(|| None) @@ -136,9 +137,9 @@ impl VariableCoalescing { .after .keys() .chain(live_var_info.before.keys()) - .filter(|local| !borrowed_locals.contains(local)) + .filter(|local| !pinned_locals.contains(local)) .for_each(|local| { - // non-borrowed local that is live before and/or after the code offset. + // non-pinned local that is live before and/or after the code offset. let interval = live_intervals[*local].get_or_insert_with(|| LiveInterval::new(*offset)); interval.include(*offset); diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/borrow_invalid.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/borrow_invalid.exp index fe5e732300cb2..6df26e844a8d2 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/borrow_invalid.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/borrow_invalid.exp @@ -1,55 +1,7 @@ -// -- Model dump before bytecode pipeline -module 0x42::borrow { - struct S { - f: u64, - } - private fun mut_expr(x: u64): u64 { - { - let r: &mut u64 = Borrow(Mutable)(Add(x, 1)); - r = 22; - Deref(r) - } - } - private fun mut_field(s: &borrow::S): u64 { - { - let r: &mut u64 = Borrow(Mutable)(select borrow::S.f<&borrow::S>(s)); - r = 22; - Deref(r) - } - } -} // end 0x42::borrow -============ initial bytecode ================ - -[variant baseline] -fun borrow::mut_expr($t0: u64): u64 { - var $t1: u64 - var $t2: &mut u64 - var $t3: &mut u64 - var $t4: u64 - var $t5: u64 - var $t6: u64 - 0: $t5 := 1 - 1: $t4 := +($t0, $t5) - 2: $t3 := borrow_local($t4) - 3: $t2 := infer($t3) - 4: $t6 := 22 - 5: write_ref($t2, $t6) - 6: $t1 := read_ref($t2) - 7: return $t1 -} - - -[variant baseline] -fun borrow::mut_field($t0: &borrow::S): u64 { - var $t1: u64 - var $t2: &mut u64 - var $t3: &mut u64 - var $t4: u64 - 0: $t3 := borrow_field.f($t0) - 1: $t2 := infer($t3) - 2: $t4 := 22 - 3: write_ref($t2, $t4) - 4: $t1 := read_ref($t2) - 5: return $t1 -} +Diagnostics: +error: cannot mutably borrow from an immutable ref + ┌─ tests/bytecode-generator/borrow_invalid.move:8:17 + │ +8 │ let r = &mut s.f; + │ ^^^^^^^^ diff --git a/third_party/move/move-model/bytecode/src/function_target.rs b/third_party/move/move-model/bytecode/src/function_target.rs index c93d416915cd8..49b4f99ed5d1e 100644 --- a/third_party/move/move-model/bytecode/src/function_target.rs +++ b/third_party/move/move-model/bytecode/src/function_target.rs @@ -381,19 +381,29 @@ impl<'env> FunctionTarget<'env> { res } - /// Get the set of locals that have been borrowed in the function. - pub fn get_borrowed_locals(&self) -> BTreeSet { - self.get_bytecode() - .iter() - .filter_map(|bc| { - if let Bytecode::Call(_, _, Operation::BorrowLoc, srcs, _) = bc { - // BorrowLoc should have only one source. - srcs.first().cloned() - } else { - None - } - }) - .collect() + /// Get the set of locals which need to be pinned (cannot be eliminated) as they are borrowed + /// from or used in specs. If `include_drop` is true, we also include temps which are dropped. + pub fn get_pinned_temps(&self, include_drop: bool) -> BTreeSet { + let mut result = BTreeSet::new(); + for bc in self.get_bytecode() { + match bc { + Bytecode::Call(_, _, Operation::BorrowLoc, args, _) => { + result.insert(args[0]); + }, + Bytecode::Call(_, _, Operation::Drop, args, _) if include_drop => { + result.insert(args[0]); + }, + Bytecode::SpecBlock(_, spec) => { + // All Temporaries used in specs need to be pinned. + result.append(&mut spec.used_temporaries()); + }, + Bytecode::Prop(_, _, exp) => { + result.append(&mut exp.used_temporaries()); + }, + _ => {}, + } + } + result } /// Returns all the mentioned locals (in non-spec-only bytecode instructions). diff --git a/third_party/move/move-model/bytecode/src/livevar_analysis.rs b/third_party/move/move-model/bytecode/src/livevar_analysis.rs index 6acb531349e66..9b1b101f1503f 100644 --- a/third_party/move/move-model/bytecode/src/livevar_analysis.rs +++ b/third_party/move/move-model/bytecode/src/livevar_analysis.rs @@ -429,7 +429,7 @@ impl<'a> TransferFunctions for LiveVarAnalysis<'a> { state.insert(&[*src]); }, Prop(_, _, exp) => { - for (idx, _) in exp.used_temporaries(self.func_target.global_env()) { + for (idx, _) in exp.used_temporaries_with_types(self.func_target.global_env()) { state.insert(&[idx]); } }, diff --git a/third_party/move/move-model/src/ast.rs b/third_party/move/move-model/src/ast.rs index ed3e495e12dc0..59eecaef06235 100644 --- a/third_party/move/move-model/src/ast.rs +++ b/third_party/move/move-model/src/ast.rs @@ -372,6 +372,32 @@ impl Spec { Some(()) }); } + + /// Returns the temporaries used in this spec block. Result is ordered by occurrence. + pub fn used_temporaries_with_types(&self, env: &GlobalEnv) -> Vec<(TempIndex, Type)> { + let mut temps = vec![]; + let mut visitor = |e: &ExpData| { + if let ExpData::Temporary(id, idx) = e { + if !temps.iter().any(|(i, _)| i == idx) { + temps.push((*idx, env.get_node_type(*id))); + } + } + }; + self.visit_post_order(&mut visitor); + temps + } + + /// Returns the temporaries used in this spec block. Result is ordered by occurrence. + pub fn used_temporaries(&self) -> BTreeSet { + let mut temps = BTreeSet::new(); + let mut visitor = |e: &ExpData| { + if let ExpData::Temporary(_, idx) = e { + temps.insert(*idx); + } + }; + self.visit_post_order(&mut visitor); + temps + } } /// Information about a specification block in the source. This is used for documentation @@ -876,8 +902,8 @@ impl ExpData { result } - /// Returns the temporaries used in this expression. Result is ordered by occurrence. - pub fn used_temporaries(&self, env: &GlobalEnv) -> Vec<(TempIndex, Type)> { + /// Returns the temporaries used in this expression, with types. Result is ordered by occurrence. + pub fn used_temporaries_with_types(&self, env: &GlobalEnv) -> Vec<(TempIndex, Type)> { let mut temps = vec![]; let mut visitor = |e: &ExpData| { if let ExpData::Temporary(id, idx) = e { @@ -891,6 +917,19 @@ impl ExpData { temps } + /// Returns the temporaries used in this spec block. + pub fn used_temporaries(&self) -> BTreeSet { + let mut temps = BTreeSet::new(); + let mut visitor = |e: &ExpData| { + if let ExpData::Temporary(_, idx) = e { + temps.insert(*idx); + } + true // keep going + }; + self.visit_post_order(&mut visitor); + temps + } + /// Returns the Move functions called by this expression pub fn called_funs(&self) -> BTreeSet> { let mut called = BTreeSet::new(); diff --git a/third_party/move/move-prover/boogie-backend/src/spec_translator.rs b/third_party/move/move-prover/boogie-backend/src/spec_translator.rs index 8e1cf0fb205d0..335401d30a82d 100644 --- a/third_party/move/move-prover/boogie-backend/src/spec_translator.rs +++ b/third_party/move/move-prover/boogie-backend/src/spec_translator.rs @@ -1535,7 +1535,7 @@ impl<'env> SpecTranslator<'env> { .map(|(s, ty)| (s, self.inst(ty.skip_reference()))) .collect_vec(); let used_temps = range_and_body - .used_temporaries(self.env) + .used_temporaries_with_types(self.env) .into_iter() .collect_vec(); let used_memory = range_and_body diff --git a/third_party/move/move-prover/bytecode-pipeline/tests/data_invariant_instrumentation/borrow.exp b/third_party/move/move-prover/bytecode-pipeline/tests/data_invariant_instrumentation/borrow.exp index c4d3ef42d7ad4..544df24772dae 100644 --- a/third_party/move/move-prover/bytecode-pipeline/tests/data_invariant_instrumentation/borrow.exp +++ b/third_party/move/move-prover/bytecode-pipeline/tests/data_invariant_instrumentation/borrow.exp @@ -95,7 +95,7 @@ public fun Test::test_borrow_imm<#0>(): u64 { var $t1: Test::R<#0> var $t2: num var $t3: u64 - 0: assume forall $rsc: Test::R<#0>: ResourceDomain>(): And(WellFormed($rsc), And(Gt(select Test::R.x($rsc), select Test::S.y(select Test::R.s($rsc))), Gt(select Test::S.y(select Test::R.s($rsc)), 0))) + 0: assume forall $rsc: Test::R<#0>: ResourceDomain>(): And(WellFormed($rsc), And(Gt(select Test::R.x($rsc), select Test::S.y(select Test::R.s($rsc))), Gt(select Test::S.y(select Test::R.s($rsc)), 0))) 1: $t0 := 0x1 2: $t1 := get_global>($t0) on_abort goto 6 with $t2 3: $t3 := get_field>.x($t1) @@ -118,7 +118,7 @@ public fun Test::test_borrow_mut<#0>(): u64 { var $t7: u64 var $t8: &mut u64 var $t9: u64 - 0: assume forall $rsc: Test::R<#0>: ResourceDomain>(): And(WellFormed($rsc), And(Gt(select Test::R.x($rsc), select Test::S.y(select Test::R.s($rsc))), Gt(select Test::S.y(select Test::R.s($rsc)), 0))) + 0: assume forall $rsc: Test::R<#0>: ResourceDomain>(): And(WellFormed($rsc), And(Gt(select Test::R.x($rsc), select Test::S.y(select Test::R.s($rsc))), Gt(select Test::S.y(select Test::R.s($rsc)), 0))) 1: $t1 := 0x1 2: $t2 := borrow_global>($t1) on_abort goto 19 with $t3 3: $t4 := 2 @@ -134,7 +134,7 @@ public fun Test::test_borrow_mut<#0>(): u64 { 13: $t9 := get_field>.x($t2) # data invariant at tests/data_invariant_instrumentation/borrow.move:13:9+18 # VC: data invariant does not hold at tests/data_invariant_instrumentation/borrow.move:13:9+18 - 14: assert Gt(select Test::R.x($t2), select Test::S.y(select Test::R.s($t2))) + 14: assert Gt(select Test::R.x($t2), select Test::S.y(select Test::R.s($t2))) # data invariant at tests/data_invariant_instrumentation/borrow.move:17:9+16 # VC: data invariant does not hold at tests/data_invariant_instrumentation/borrow.move:17:9+16 15: assert Gt(select Test::S.y(select Test::R.s($t2)), 0) @@ -171,7 +171,7 @@ public fun Test::test_borrow_mut_local(): Test::R { 5: $t0 := pack Test::R($t2, $t4, $t5) # data invariant at tests/data_invariant_instrumentation/borrow.move:13:9+18 # VC: data invariant does not hold at tests/data_invariant_instrumentation/borrow.move:13:9+18 - 6: assert Gt(select Test::R.x($t0), select Test::S.y(select Test::R.s($t0))) + 6: assert Gt(select Test::R.x($t0), select Test::S.y(select Test::R.s($t0))) 7: $t6 := borrow_local($t0) 8: $t7 := 2 9: $t8 := borrow_field>.s($t6) @@ -185,7 +185,7 @@ public fun Test::test_borrow_mut_local(): Test::R { 17: write_back[Reference($t6).x (u64)]($t11) # data invariant at tests/data_invariant_instrumentation/borrow.move:13:9+18 # VC: data invariant does not hold at tests/data_invariant_instrumentation/borrow.move:13:9+18 - 18: assert Gt(select Test::R.x($t6), select Test::S.y(select Test::R.s($t6))) + 18: assert Gt(select Test::R.x($t6), select Test::S.y(select Test::R.s($t6))) # data invariant at tests/data_invariant_instrumentation/borrow.move:17:9+16 # VC: data invariant does not hold at tests/data_invariant_instrumentation/borrow.move:17:9+16 19: assert Gt(select Test::S.y(select Test::R.s($t6)), 0) diff --git a/third_party/move/move-prover/bytecode-pipeline/tests/data_invariant_instrumentation/pack.exp b/third_party/move/move-prover/bytecode-pipeline/tests/data_invariant_instrumentation/pack.exp index afa97b82616c9..572e482b9d868 100644 --- a/third_party/move/move-prover/bytecode-pipeline/tests/data_invariant_instrumentation/pack.exp +++ b/third_party/move/move-prover/bytecode-pipeline/tests/data_invariant_instrumentation/pack.exp @@ -30,7 +30,7 @@ public fun Test::test_pack(): Test::R { 4: $t3 := pack Test::R($t0, $t2) # data invariant at tests/data_invariant_instrumentation/pack.move:12:9+18 # VC: data invariant does not hold at tests/data_invariant_instrumentation/pack.move:12:9+18 - 5: assert Gt(select Test::R.x($t3), select Test::S.y(select Test::R.s($t3))) + 5: assert Gt(select Test::R.x($t3), select Test::S.y(select Test::R.s($t3))) 6: label L1 7: return $t3 } diff --git a/third_party/move/move-prover/bytecode-pipeline/tests/data_invariant_instrumentation/params.exp b/third_party/move/move-prover/bytecode-pipeline/tests/data_invariant_instrumentation/params.exp index 4ec2addfcbafe..5d342fe5efece 100644 --- a/third_party/move/move-prover/bytecode-pipeline/tests/data_invariant_instrumentation/params.exp +++ b/third_party/move/move-prover/bytecode-pipeline/tests/data_invariant_instrumentation/params.exp @@ -9,14 +9,14 @@ public fun Test::test_param($t0|_simple_R: Test::R, $t1|_ref_R: &Test::R, $t2|_s [variant verification] public fun Test::test_param($t0|_simple_R: Test::R, $t1|_ref_R: Test::R, $t2|_simple_S: Test::S, $t3|_mut_R: &mut Test::R) { - 0: assume And(WellFormed($t0), And(Gt(select Test::R.x($t0), select Test::S.y(select Test::R.s($t0))), Gt(select Test::S.y(select Test::R.s($t0)), 0))) - 1: assume And(WellFormed($t1), And(Gt(select Test::R.x($t1), select Test::S.y(select Test::R.s($t1))), Gt(select Test::S.y(select Test::R.s($t1)), 0))) + 0: assume And(WellFormed($t0), And(Gt(select Test::R.x($t0), select Test::S.y(select Test::R.s($t0))), Gt(select Test::S.y(select Test::R.s($t0)), 0))) + 1: assume And(WellFormed($t1), And(Gt(select Test::R.x($t1), select Test::S.y(select Test::R.s($t1))), Gt(select Test::S.y(select Test::R.s($t1)), 0))) 2: assume And(WellFormed($t2), Gt(select Test::S.y($t2), 0)) - 3: assume And(WellFormed($t3), And(Gt(select Test::R.x($t3), select Test::S.y(select Test::R.s($t3))), Gt(select Test::S.y(select Test::R.s($t3)), 0))) + 3: assume And(WellFormed($t3), And(Gt(select Test::R.x($t3), select Test::S.y(select Test::R.s($t3))), Gt(select Test::S.y(select Test::R.s($t3)), 0))) 4: trace_local[_mut_R]($t3) # data invariant at tests/data_invariant_instrumentation/params.move:12:9+18 # VC: data invariant does not hold at tests/data_invariant_instrumentation/params.move:12:9+18 - 5: assert Gt(select Test::R.x($t3), select Test::S.y(select Test::R.s($t3))) + 5: assert Gt(select Test::R.x($t3), select Test::S.y(select Test::R.s($t3))) # data invariant at tests/data_invariant_instrumentation/params.move:16:9+16 # VC: data invariant does not hold at tests/data_invariant_instrumentation/params.move:16:9+16 6: assert Gt(select Test::S.y(select Test::R.s($t3)), 0) diff --git a/third_party/move/move-prover/bytecode-pipeline/tests/global_invariant_instrumentation/borrow.exp b/third_party/move/move-prover/bytecode-pipeline/tests/global_invariant_instrumentation/borrow.exp index a9ca29d494e6d..1128c066e463a 100644 --- a/third_party/move/move-prover/bytecode-pipeline/tests/global_invariant_instrumentation/borrow.exp +++ b/third_party/move/move-prover/bytecode-pipeline/tests/global_invariant_instrumentation/borrow.exp @@ -38,7 +38,7 @@ public fun Test::borrow($t0|a: address) { var $t6: u64 var $t7: &mut u64 # global invariant at tests/global_invariant_instrumentation/borrow.move:7:9+57 - 0: assume forall a: address: TypeDomain
(): Gt(select Test::R.x(global(a)), 0) + 0: assume forall a: address: TypeDomain
(): Gt(select Test::R.x(global(a)), 0) 1: $t2 := borrow_global($t0) on_abort goto 12 with $t3 2: $t4 := get_field.x($t2) 3: $t5 := 1 @@ -49,7 +49,7 @@ public fun Test::borrow($t0|a: address) { 8: write_back[Test::R@]($t2) # global invariant at tests/global_invariant_instrumentation/borrow.move:7:9+57 # VC: global memory invariant does not hold at tests/global_invariant_instrumentation/borrow.move:7:9+57 - 9: assert forall a: address: TypeDomain
(): Gt(select Test::R.x(global(a)), 0) + 9: assert forall a: address: TypeDomain
(): Gt(select Test::R.x(global(a)), 0) 10: label L1 11: return () 12: label L2 diff --git a/third_party/move/move-prover/bytecode-pipeline/tests/global_invariant_instrumentation/move.exp b/third_party/move/move-prover/bytecode-pipeline/tests/global_invariant_instrumentation/move.exp index aef9288188481..47e7f43c70a29 100644 --- a/third_party/move/move-prover/bytecode-pipeline/tests/global_invariant_instrumentation/move.exp +++ b/third_party/move/move-prover/bytecode-pipeline/tests/global_invariant_instrumentation/move.exp @@ -30,13 +30,13 @@ public fun Test::publish($t0|s: signer) { var $t2: Test::R var $t3: num # global invariant at tests/global_invariant_instrumentation/move.move:7:9+57 - 0: assume forall a: address: TypeDomain
(): Gt(select Test::R.x(global(a)), 0) + 0: assume forall a: address: TypeDomain
(): Gt(select Test::R.x(global(a)), 0) 1: $t1 := 1 2: $t2 := pack Test::R($t1) 3: move_to($t2, $t0) on_abort goto 7 with $t3 # global invariant at tests/global_invariant_instrumentation/move.move:7:9+57 # VC: global memory invariant does not hold at tests/global_invariant_instrumentation/move.move:7:9+57 - 4: assert forall a: address: TypeDomain
(): Gt(select Test::R.x(global(a)), 0) + 4: assert forall a: address: TypeDomain
(): Gt(select Test::R.x(global(a)), 0) 5: label L1 6: return () 7: label L2 @@ -49,11 +49,11 @@ public fun Test::remove($t0|a: address): Test::R { var $t1: Test::R var $t2: num # global invariant at tests/global_invariant_instrumentation/move.move:7:9+57 - 0: assume forall a: address: TypeDomain
(): Gt(select Test::R.x(global(a)), 0) + 0: assume forall a: address: TypeDomain
(): Gt(select Test::R.x(global(a)), 0) 1: $t1 := move_from($t0) on_abort goto 5 with $t2 # global invariant at tests/global_invariant_instrumentation/move.move:7:9+57 # VC: global memory invariant does not hold at tests/global_invariant_instrumentation/move.move:7:9+57 - 2: assert forall a: address: TypeDomain
(): Gt(select Test::R.x(global(a)), 0) + 2: assert forall a: address: TypeDomain
(): Gt(select Test::R.x(global(a)), 0) 3: label L1 4: return $t1 5: label L2 diff --git a/third_party/move/move-prover/bytecode-pipeline/tests/global_invariant_instrumentation/update.exp b/third_party/move/move-prover/bytecode-pipeline/tests/global_invariant_instrumentation/update.exp index 9ff41de639746..be2dd70798ead 100644 --- a/third_party/move/move-prover/bytecode-pipeline/tests/global_invariant_instrumentation/update.exp +++ b/third_party/move/move-prover/bytecode-pipeline/tests/global_invariant_instrumentation/update.exp @@ -49,7 +49,7 @@ public fun Test::incr($t0|a: address) { 8: write_back[Test::R@]($t2) # global invariant at tests/global_invariant_instrumentation/update.move:7:9+82 # VC: global memory invariant does not hold at tests/global_invariant_instrumentation/update.move:7:9+82 - 9: assert forall a: address: TypeDomain
(): Lt(select Test::R.x(global[@1](a)), select Test::R.x(global(a))) + 9: assert forall a: address: TypeDomain
(): Lt(select Test::R.x(global[@1](a)), select Test::R.x(global(a))) 10: label L1 11: return () 12: label L2 diff --git a/third_party/move/move-prover/bytecode-pipeline/tests/spec_instrumentation/fun_spec.exp b/third_party/move/move-prover/bytecode-pipeline/tests/spec_instrumentation/fun_spec.exp index 672fda40c9ade..8b471c086cdd7 100644 --- a/third_party/move/move-prover/bytecode-pipeline/tests/spec_instrumentation/fun_spec.exp +++ b/third_party/move/move-prover/bytecode-pipeline/tests/spec_instrumentation/fun_spec.exp @@ -273,17 +273,17 @@ fun Test::mut_ref_param($t0|r: &mut Test::R): u64 { 9: trace_local[r]($t0) 10: label L1 # VC: function does not abort under this condition at tests/spec_instrumentation/fun_spec.move:67:6+42 - 11: assert Not(Eq(select Test::R.v($t2), 0)) + 11: assert Not(Eq(select Test::R.v($t2), 0)) # VC: post-condition does not hold at tests/spec_instrumentation/fun_spec.move:68:6+27 - 12: assert Eq($t3, select Test::R.v($t2)) + 12: assert Eq($t3, select Test::R.v($t2)) # VC: post-condition does not hold at tests/spec_instrumentation/fun_spec.move:69:6+28 - 13: assert Eq(select Test::R.v($t0), Add(select Test::R.v($t2), 1)) + 13: assert Eq(select Test::R.v($t0), Add(select Test::R.v($t2), 1)) 14: return $t3 15: label L2 # VC: abort not covered by any of the `aborts_if` clauses at tests/spec_instrumentation/fun_spec.move:66:2+138 - 16: assert Eq(select Test::R.v($t2), 0) + 16: assert Eq(select Test::R.v($t2), 0) # VC: abort code not covered by any of the `aborts_if` or `aborts_with` clauses at tests/spec_instrumentation/fun_spec.move:66:2+138 - 17: assert And(Eq(select Test::R.v($t2), 0), Eq(-1, $t7)) + 17: assert And(Eq(select Test::R.v($t2), 0), Eq(-1, $t7)) 18: abort($t7) } @@ -294,7 +294,7 @@ fun Test::ref_param($t0|r: Test::R): u64 { 0: $t1 := get_field.v($t0) 1: label L1 # VC: post-condition does not hold at tests/spec_instrumentation/fun_spec.move:51:6+22 - 2: assert Eq($t1, select Test::R.v($t0)) + 2: assert Eq($t1, select Test::R.v($t0)) 3: return $t1 } @@ -305,7 +305,7 @@ fun Test::ref_param_return_ref($t0|r: Test::R): u64 { 0: $t1 := get_field.v($t0) 1: label L1 # VC: post-condition does not hold at tests/spec_instrumentation/fun_spec.move:58:6+22 - 2: assert Eq($t1, select Test::R.v($t0)) + 2: assert Eq($t1, select Test::R.v($t0)) 3: return $t1 } @@ -349,15 +349,15 @@ fun Test::resource_with_old($t0|val: u64) { # VC: function does not abort under this condition at tests/spec_instrumentation/fun_spec.move:41:6+35 22: assert Not(Not(exists[@0](0x0))) # VC: function does not abort under this condition at tests/spec_instrumentation/fun_spec.move:42:6+58 - 23: assert Not(Ge(Add(select Test::R.v(global[@0](0x0)), $t0), 18446744073709551615)) + 23: assert Not(Ge(Add(select Test::R.v(global[@0](0x0)), $t0), 18446744073709551615)) # VC: post-condition does not hold at tests/spec_instrumentation/fun_spec.move:43:6+58 - 24: assert Eq(select Test::R.v(global(0x0)), Add(select Test::R.v(global[@0](0x0)), $t0)) + 24: assert Eq(select Test::R.v(global(0x0)), Add(select Test::R.v(global[@0](0x0)), $t0)) 25: return () 26: label L3 # VC: abort not covered by any of the `aborts_if` clauses at tests/spec_instrumentation/fun_spec.move:39:2+250 - 27: assert Or(Not(exists[@0](0x0)), Ge(Add(select Test::R.v(global[@0](0x0)), $t0), 18446744073709551615)) + 27: assert Or(Not(exists[@0](0x0)), Ge(Add(select Test::R.v(global[@0](0x0)), $t0), 18446744073709551615)) # VC: abort code not covered by any of the `aborts_if` or `aborts_with` clauses at tests/spec_instrumentation/fun_spec.move:39:2+250 - 28: assert Or(And(Not(exists[@0](0x0)), Eq(33, $t6)), Ge(Add(select Test::R.v(global[@0](0x0)), $t0), 18446744073709551615)) + 28: assert Or(And(Not(exists[@0](0x0)), Eq(33, $t6)), Ge(Add(select Test::R.v(global[@0](0x0)), $t0), 18446744073709551615)) 29: abort($t6) } @@ -409,44 +409,44 @@ spec { fun Test::mut_ref_param[baseline] spec { - aborts_if Eq(select Test::R.v($t0), 0); - ensures Eq(result0(), Old(select Test::R.v($t0))); - ensures Eq(select Test::R.v($t0), Add(Old(select Test::R.v($t0)), 1)); + aborts_if Eq(select Test::R.v($t0), 0); + ensures Eq(result0(), Old(select Test::R.v($t0))); + ensures Eq(select Test::R.v($t0), Add(Old(select Test::R.v($t0)), 1)); } fun Test::mut_ref_param[verification] spec { - aborts_if Eq(select Test::R.v($t0), 0); - ensures Eq(result0(), Old(select Test::R.v($t0))); - ensures Eq(select Test::R.v($t0), Add(Old(select Test::R.v($t0)), 1)); + aborts_if Eq(select Test::R.v($t0), 0); + ensures Eq(result0(), Old(select Test::R.v($t0))); + ensures Eq(select Test::R.v($t0), Add(Old(select Test::R.v($t0)), 1)); } fun Test::ref_param[baseline] spec { - ensures Eq(result0(), select Test::R.v($t0)); + ensures Eq(result0(), select Test::R.v($t0)); } fun Test::ref_param[verification] spec { - ensures Eq(result0(), select Test::R.v($t0)); + ensures Eq(result0(), select Test::R.v($t0)); } fun Test::ref_param_return_ref[baseline] spec { - ensures Eq(result0(), select Test::R.v($t0)); + ensures Eq(result0(), select Test::R.v($t0)); } fun Test::ref_param_return_ref[verification] spec { - ensures Eq(result0(), select Test::R.v($t0)); + ensures Eq(result0(), select Test::R.v($t0)); } fun Test::resource_with_old[baseline] spec { requires Gt($t0, 0); aborts_if Not(exists(0x0)); - aborts_if Ge(Add(select Test::R.v(global(0x0)), $t0), 18446744073709551615); - ensures Eq(select Test::R.v(global(0x0)), Add(select Test::R.v(Old(global(0x0))), $t0)); + aborts_if Ge(Add(select Test::R.v(global(0x0)), $t0), 18446744073709551615); + ensures Eq(select Test::R.v(global(0x0)), Add(select Test::R.v(Old(global(0x0))), $t0)); modifies global(0x0); } @@ -454,7 +454,7 @@ fun Test::resource_with_old[verification] spec { requires Gt($t0, 0); aborts_if Not(exists(0x0)); - aborts_if Ge(Add(select Test::R.v(global(0x0)), $t0), 18446744073709551615); - ensures Eq(select Test::R.v(global(0x0)), Add(select Test::R.v(Old(global(0x0))), $t0)); + aborts_if Ge(Add(select Test::R.v(global(0x0)), $t0), 18446744073709551615); + ensures Eq(select Test::R.v(global(0x0)), Add(select Test::R.v(Old(global(0x0))), $t0)); modifies global(0x0); } diff --git a/third_party/move/move-prover/bytecode-pipeline/tests/spec_instrumentation/modifies.exp b/third_party/move/move-prover/bytecode-pipeline/tests/spec_instrumentation/modifies.exp index 3dcb45393ee96..a1b6c4102f2f2 100644 --- a/third_party/move/move-prover/bytecode-pipeline/tests/spec_instrumentation/modifies.exp +++ b/third_party/move/move-prover/bytecode-pipeline/tests/spec_instrumentation/modifies.exp @@ -184,7 +184,7 @@ public fun A::mutate_at($t0|addr: address) { # VC: function does not abort under this condition at tests/spec_instrumentation/modifies.move:24:9+27 10: assert Not(Not(exists[@0]($t0))) # VC: post-condition does not hold at tests/spec_instrumentation/modifies.move:23:9+31 - 11: assert Eq(select A::S.x(global($t0)), 2) + 11: assert Eq(select A::S.x(global($t0)), 2) 12: return () 13: label L2 # VC: abort not covered by any of the `aborts_if` clauses at tests/spec_instrumentation/modifies.move:21:5+162 @@ -205,7 +205,7 @@ public fun A::read_at($t0|addr: address): u64 { # VC: function does not abort under this condition at tests/spec_instrumentation/modifies.move:13:9+27 4: assert Not(Not(exists[@1]($t0))) # VC: post-condition does not hold at tests/spec_instrumentation/modifies.move:14:9+36 - 5: assert Eq($t3, select A::S.x(global($t0))) + 5: assert Eq($t3, select A::S.x(global($t0))) 6: return $t3 7: label L2 # VC: abort not covered by any of the `aborts_if` clauses at tests/spec_instrumentation/modifies.move:11:5+131 @@ -234,7 +234,7 @@ public fun B::move_from_test_incorrect($t0|addr1: address, $t1|addr2: address): 6: goto 26 7: label L3 8: assume WellFormed($t5) - 9: assume Eq($t5, select A::S.x(global($t1))) + 9: assume Eq($t5, select A::S.x(global($t1))) 10: $t5 := opaque end: A::read_at($t1) # VC: caller does not have permission to modify `B::T` at given address at tests/spec_instrumentation/modifies.move:65:17+9 11: assert CanModify($t0) @@ -247,7 +247,7 @@ public fun B::move_from_test_incorrect($t0|addr1: address, $t1|addr2: address): 18: goto 26 19: label L5 20: assume WellFormed($t9) - 21: assume Eq($t9, select A::S.x(global($t1))) + 21: assume Eq($t9, select A::S.x(global($t1))) 22: $t9 := opaque end: A::read_at($t1) 23: assert Eq($t5, $t9) 24: label L1 @@ -277,7 +277,7 @@ public fun B::move_to_test_incorrect($t0|account: signer, $t1|addr2: address) { 6: goto 28 7: label L3 8: assume WellFormed($t4) - 9: assume Eq($t4, select A::S.x(global($t1))) + 9: assume Eq($t4, select A::S.x(global($t1))) 10: $t4 := opaque end: A::read_at($t1) 11: $t7 := 2 12: $t8 := pack B::T($t7) @@ -292,7 +292,7 @@ public fun B::move_to_test_incorrect($t0|account: signer, $t1|addr2: address) { 20: goto 28 21: label L5 22: assume WellFormed($t9) - 23: assume Eq($t9, select A::S.x(global($t1))) + 23: assume Eq($t9, select A::S.x(global($t1))) 24: $t9 := opaque end: A::read_at($t1) 25: assert Eq($t4, $t9) 26: label L1 @@ -322,7 +322,7 @@ public fun B::mutate_S_test1_incorrect($t0|addr1: address, $t1|addr2: address) { 7: goto 36 8: label L3 9: assume WellFormed($t4) - 10: assume Eq($t4, select A::S.x(global($t1))) + 10: assume Eq($t4, select A::S.x(global($t1))) 11: $t4 := opaque end: A::read_at($t1) # VC: caller does not have permission to modify `A::S` at given address at tests/spec_instrumentation/modifies.move:79:9+19 12: assert CanModify($t0) @@ -334,7 +334,7 @@ public fun B::mutate_S_test1_incorrect($t0|addr1: address, $t1|addr2: address) { 18: goto 36 19: label L5 20: modifies global($t0) - 21: assume Eq(select A::S.x(global($t0)), 2) + 21: assume Eq(select A::S.x(global($t0)), 2) 22: opaque end: A::mutate_at($t0) 23: $t8 := opaque begin: A::read_at($t1) 24: assume Identical($t9, Not(exists($t1))) @@ -344,7 +344,7 @@ public fun B::mutate_S_test1_incorrect($t0|addr1: address, $t1|addr2: address) { 28: goto 36 29: label L7 30: assume WellFormed($t8) - 31: assume Eq($t8, select A::S.x(global($t1))) + 31: assume Eq($t8, select A::S.x(global($t1))) 32: $t8 := opaque end: A::read_at($t1) 33: assert Eq($t4, $t8) 34: label L1 @@ -373,7 +373,7 @@ public fun B::mutate_S_test2_incorrect($t0|addr: address) { 6: goto 35 7: label L3 8: assume WellFormed($t3) - 9: assume Eq($t3, select A::S.x(global($t0))) + 9: assume Eq($t3, select A::S.x(global($t0))) 10: $t3 := opaque end: A::read_at($t0) # VC: caller does not have permission to modify `A::S` at given address at tests/spec_instrumentation/modifies.move:92:9+18 11: assert CanModify($t0) @@ -385,7 +385,7 @@ public fun B::mutate_S_test2_incorrect($t0|addr: address) { 17: goto 35 18: label L5 19: modifies global($t0) - 20: assume Eq(select A::S.x(global($t0)), 2) + 20: assume Eq(select A::S.x(global($t0)), 2) 21: opaque end: A::mutate_at($t0) 22: $t7 := opaque begin: A::read_at($t0) 23: assume Identical($t8, Not(exists($t0))) @@ -395,7 +395,7 @@ public fun B::mutate_S_test2_incorrect($t0|addr: address) { 27: goto 35 28: label L7 29: assume WellFormed($t7) - 30: assume Eq($t7, select A::S.x(global($t0))) + 30: assume Eq($t7, select A::S.x(global($t0))) 31: $t7 := opaque end: A::read_at($t0) 32: assert Eq($t3, $t7) 33: label L1 @@ -427,7 +427,7 @@ public fun B::mutate_at_test_incorrect($t0|addr1: address, $t1|addr2: address) { 6: goto 31 7: label L3 8: assume WellFormed($t5) - 9: assume Eq($t5, select A::S.x(global($t1))) + 9: assume Eq($t5, select A::S.x(global($t1))) 10: $t5 := opaque end: A::read_at($t1) # VC: caller does not have permission to modify `B::T` at given address at tests/spec_instrumentation/modifies.move:38:17+17 11: assert CanModify($t0) @@ -445,7 +445,7 @@ public fun B::mutate_at_test_incorrect($t0|addr1: address, $t1|addr2: address) { 23: goto 31 24: label L5 25: assume WellFormed($t11) - 26: assume Eq($t11, select A::S.x(global($t1))) + 26: assume Eq($t11, select A::S.x(global($t1))) 27: $t11 := opaque end: A::read_at($t1) 28: assert Eq($t5, $t11) 29: label L1 @@ -460,14 +460,14 @@ public fun B::mutate_at_test_incorrect($t0|addr1: address, $t1|addr2: address) { fun A::mutate_at[baseline] spec { - ensures Eq(select A::S.x(global($t0)), 2); + ensures Eq(select A::S.x(global($t0)), 2); aborts_if Not(exists($t0)); modifies global($t0); } fun A::mutate_at[verification] spec { - ensures Eq(select A::S.x(global($t0)), 2); + ensures Eq(select A::S.x(global($t0)), 2); aborts_if Not(exists($t0)); modifies global($t0); } @@ -475,13 +475,13 @@ spec { fun A::read_at[baseline] spec { aborts_if Not(exists($t0)); - ensures Eq(result0(), select A::S.x(global($t0))); + ensures Eq(result0(), select A::S.x(global($t0))); } fun A::read_at[verification] spec { aborts_if Not(exists($t0)); - ensures Eq(result0(), select A::S.x(global($t0))); + ensures Eq(result0(), select A::S.x(global($t0))); } fun B::move_from_test_incorrect[baseline] diff --git a/third_party/move/move-prover/bytecode-pipeline/tests/spec_instrumentation/opaque_call.exp b/third_party/move/move-prover/bytecode-pipeline/tests/spec_instrumentation/opaque_call.exp index b9f7c6dc239c6..4d54e160f9f67 100644 --- a/third_party/move/move-prover/bytecode-pipeline/tests/spec_instrumentation/opaque_call.exp +++ b/third_party/move/move-prover/bytecode-pipeline/tests/spec_instrumentation/opaque_call.exp @@ -106,17 +106,17 @@ fun Test::get_and_incr($t0|addr: address): u64 { # VC: function does not abort under this condition at tests/spec_instrumentation/opaque_call.move:16:6+35 22: assert Not(Not(exists[@0]($t0))) # VC: function does not abort under this condition at tests/spec_instrumentation/opaque_call.move:17:6+56 - 23: assert Not(Ge(Add(select Test::R.v(global[@0]($t0)), 1), 18446744073709551615)) + 23: assert Not(Ge(Add(select Test::R.v(global[@0]($t0)), 1), 18446744073709551615)) # VC: post-condition does not hold at tests/spec_instrumentation/opaque_call.move:19:6+56 - 24: assert Eq(select Test::R.v(global($t0)), Add(select Test::R.v(global[@0]($t0)), 1)) + 24: assert Eq(select Test::R.v(global($t0)), Add(select Test::R.v(global[@0]($t0)), 1)) # VC: post-condition does not hold at tests/spec_instrumentation/opaque_call.move:20:6+36 - 25: assert Eq($t8, select Test::R.v(global($t0))) + 25: assert Eq($t8, select Test::R.v(global($t0))) 26: return $t8 27: label L3 # VC: abort not covered by any of the `aborts_if` clauses at tests/spec_instrumentation/opaque_call.move:13:2+308 - 28: assert Or(Not(exists[@0]($t0)), Ge(Add(select Test::R.v(global[@0]($t0)), 1), 18446744073709551615)) + 28: assert Or(Not(exists[@0]($t0)), Ge(Add(select Test::R.v(global[@0]($t0)), 1), 18446744073709551615)) # VC: abort code not covered by any of the `aborts_if` or `aborts_with` clauses at tests/spec_instrumentation/opaque_call.move:13:2+308 - 29: assert Or(And(Not(exists[@0]($t0)), Eq(33, $t6)), Ge(Add(select Test::R.v(global[@0]($t0)), 1), 18446744073709551615)) + 29: assert Or(And(Not(exists[@0]($t0)), Eq(33, $t6)), Ge(Add(select Test::R.v(global[@0]($t0)), 1), 18446744073709551615)) 30: abort($t6) } @@ -135,43 +135,43 @@ fun Test::incr_twice() { # VC: precondition does not hold at this call at tests/spec_instrumentation/opaque_call.move:15:6+22 2: assert Neq
($t0, 0x0) 3: $t1 := opaque begin: Test::get_and_incr($t0) - 4: assume Identical($t2, Or(Not(exists($t0)), Ge(Add(select Test::R.v(global($t0)), 1), 18446744073709551615))) + 4: assume Identical($t2, Or(Not(exists($t0)), Ge(Add(select Test::R.v(global($t0)), 1), 18446744073709551615))) 5: if ($t2) goto 6 else goto 10 6: label L4 - 7: assume Or(And(Not(exists($t0)), Eq(33, $t3)), Ge(Add(select Test::R.v(global($t0)), 1), 18446744073709551615)) + 7: assume Or(And(Not(exists($t0)), Eq(33, $t3)), Ge(Add(select Test::R.v(global($t0)), 1), 18446744073709551615)) 8: trace_abort($t3) 9: goto 39 10: label L3 11: @2 := save_mem(Test::R) 12: modifies global($t0) 13: assume WellFormed($t1) - 14: assume Eq(select Test::R.v(global($t0)), Add(select Test::R.v(global[@2]($t0)), 1)) - 15: assume Eq($t1, select Test::R.v(global($t0))) + 14: assume Eq(select Test::R.v(global($t0)), Add(select Test::R.v(global[@2]($t0)), 1)) + 15: assume Eq($t1, select Test::R.v(global($t0))) 16: $t1 := opaque end: Test::get_and_incr($t0) 17: drop($t1) 18: $t4 := 0x1 # VC: precondition does not hold at this call at tests/spec_instrumentation/opaque_call.move:15:6+22 19: assert Neq
($t4, 0x0) 20: $t5 := opaque begin: Test::get_and_incr($t4) - 21: assume Identical($t6, Or(Not(exists($t4)), Ge(Add(select Test::R.v(global($t4)), 1), 18446744073709551615))) + 21: assume Identical($t6, Or(Not(exists($t4)), Ge(Add(select Test::R.v(global($t4)), 1), 18446744073709551615))) 22: if ($t6) goto 23 else goto 27 23: label L6 - 24: assume Or(And(Not(exists($t4)), Eq(33, $t3)), Ge(Add(select Test::R.v(global($t4)), 1), 18446744073709551615)) + 24: assume Or(And(Not(exists($t4)), Eq(33, $t3)), Ge(Add(select Test::R.v(global($t4)), 1), 18446744073709551615)) 25: trace_abort($t3) 26: goto 39 27: label L5 28: @3 := save_mem(Test::R) 29: modifies global($t4) 30: assume WellFormed($t5) - 31: assume Eq(select Test::R.v(global($t4)), Add(select Test::R.v(global[@3]($t4)), 1)) - 32: assume Eq($t5, select Test::R.v(global($t4))) + 31: assume Eq(select Test::R.v(global($t4)), Add(select Test::R.v(global[@3]($t4)), 1)) + 32: assume Eq($t5, select Test::R.v(global($t4))) 33: $t5 := opaque end: Test::get_and_incr($t4) 34: drop($t5) 35: label L1 # VC: function does not abort under this condition at tests/spec_instrumentation/opaque_call.move:28:6+35 36: assert Not(Not(exists[@1](0x1))) # VC: post-condition does not hold at tests/spec_instrumentation/opaque_call.move:29:6+56 - 37: assert Eq(select Test::R.v(global(0x1)), Add(select Test::R.v(global[@1](0x1)), 2)) + 37: assert Eq(select Test::R.v(global(0x1)), Add(select Test::R.v(global[@1](0x1)), 2)) 38: return () 39: label L2 # VC: abort not covered by any of the `aborts_if` clauses at tests/spec_instrumentation/opaque_call.move:27:2+123 @@ -189,30 +189,30 @@ fun Test::get_and_incr[baseline] spec { requires Neq
($t0, 0x0); aborts_if Not(exists($t0)); - aborts_if Ge(Add(select Test::R.v(global($t0)), 1), 18446744073709551615); + aborts_if Ge(Add(select Test::R.v(global($t0)), 1), 18446744073709551615); modifies global($t0); - ensures Eq(select Test::R.v(global($t0)), Add(select Test::R.v(Old(global($t0))), 1)); - ensures Eq(result0(), select Test::R.v(global($t0))); + ensures Eq(select Test::R.v(global($t0)), Add(select Test::R.v(Old(global($t0))), 1)); + ensures Eq(result0(), select Test::R.v(global($t0))); } fun Test::get_and_incr[verification] spec { requires Neq
($t0, 0x0); aborts_if Not(exists($t0)); - aborts_if Ge(Add(select Test::R.v(global($t0)), 1), 18446744073709551615); + aborts_if Ge(Add(select Test::R.v(global($t0)), 1), 18446744073709551615); modifies global($t0); - ensures Eq(select Test::R.v(global($t0)), Add(select Test::R.v(Old(global($t0))), 1)); - ensures Eq(result0(), select Test::R.v(global($t0))); + ensures Eq(select Test::R.v(global($t0)), Add(select Test::R.v(Old(global($t0))), 1)); + ensures Eq(result0(), select Test::R.v(global($t0))); } fun Test::incr_twice[baseline] spec { aborts_if Not(exists(0x1)); - ensures Eq(select Test::R.v(global(0x1)), Add(select Test::R.v(Old(global(0x1))), 2)); + ensures Eq(select Test::R.v(global(0x1)), Add(select Test::R.v(Old(global(0x1))), 2)); } fun Test::incr_twice[verification] spec { aborts_if Not(exists(0x1)); - ensures Eq(select Test::R.v(global(0x1)), Add(select Test::R.v(Old(global(0x1))), 2)); + ensures Eq(select Test::R.v(global(0x1)), Add(select Test::R.v(Old(global(0x1))), 2)); } diff --git a/third_party/move/move-prover/src/cli.rs b/third_party/move/move-prover/src/cli.rs index 412a1711b5e7e..70618af31630b 100644 --- a/third_party/move/move-prover/src/cli.rs +++ b/third_party/move/move-prover/src/cli.rs @@ -169,6 +169,7 @@ impl Options { .arg( Arg::new("compiler-v2") .long("compiler-v2") + .env("MOVE_COMPILER_V2") .action(SetTrue) .help("whether to use Move compiler v2 to compile to bytecode") ) diff --git a/third_party/move/move-prover/tests/sources/functional/ModifiesSchemaTest.v2_exp b/third_party/move/move-prover/tests/sources/functional/ModifiesSchemaTest.v2_exp index 3ff81c6079fcd..970ab2ff6d115 100644 --- a/third_party/move/move-prover/tests/sources/functional/ModifiesSchemaTest.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/ModifiesSchemaTest.v2_exp @@ -14,7 +14,8 @@ error: caller does not have permission to modify `A::S` at given address = at tests/sources/functional/ModifiesSchemaTest.move:12: mutate_at = addr = = at tests/sources/functional/ModifiesSchemaTest.move:13: mutate_at - = addr = = at tests/sources/functional/ModifiesSchemaTest.move:14: mutate_at + = addr = + = = = at tests/sources/functional/ModifiesSchemaTest.move:15: mutate_at = at tests/sources/functional/ModifiesSchemaTest.move:31: mutate_at_wrapper2 diff --git a/third_party/move/move-prover/tests/sources/functional/aborts_if.v2_exp b/third_party/move/move-prover/tests/sources/functional/aborts_if.v2_exp index f6c12acd83f2d..5a41f1ca570ee 100644 --- a/third_party/move/move-prover/tests/sources/functional/aborts_if.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/aborts_if.v2_exp @@ -117,6 +117,7 @@ error: abort not covered by any of the `aborts_if` clauses = at tests/sources/functional/aborts_if.move:137: abort_at_2_or_3_total_incorrect = x = = at tests/sources/functional/aborts_if.move:137: abort_at_2_or_3_total_incorrect + = x = = = = at tests/sources/functional/aborts_if.move:137: abort_at_2_or_3_total_incorrect = ABORTED @@ -132,6 +133,7 @@ error: function does not abort under this condition = at tests/sources/functional/aborts_if.move:146: abort_at_2_or_3_spec_incorrect = x = = at tests/sources/functional/aborts_if.move:146: abort_at_2_or_3_spec_incorrect + = x = = = = at tests/sources/functional/aborts_if.move:146: abort_at_2_or_3_spec_incorrect = at tests/sources/functional/aborts_if.move:147: abort_at_2_or_3_spec_incorrect @@ -154,6 +156,7 @@ error: abort not covered by any of the `aborts_if` clauses = at tests/sources/functional/aborts_if.move:155: abort_at_2_or_3_strict_incorrect = x = = at tests/sources/functional/aborts_if.move:155: abort_at_2_or_3_strict_incorrect + = x = = = = at tests/sources/functional/aborts_if.move:155: abort_at_2_or_3_strict_incorrect = ABORTED diff --git a/third_party/move/move-prover/tests/sources/functional/aborts_if_with_code.v2_exp b/third_party/move/move-prover/tests/sources/functional/aborts_if_with_code.v2_exp index 0cf0d4d60be2a..c3a99e48ff31e 100644 --- a/third_party/move/move-prover/tests/sources/functional/aborts_if_with_code.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/aborts_if_with_code.v2_exp @@ -54,7 +54,7 @@ error: abort code not covered by any of the `aborts_if` or `aborts_with` clauses = at tests/sources/functional/aborts_if_with_code.move:70: aborts_if_with_code_mixed_invalid = x = = at tests/sources/functional/aborts_if_with_code.move:73: aborts_if_with_code_mixed_invalid - = = + = x = = at tests/sources/functional/aborts_if_with_code.move:74: aborts_if_with_code_mixed_invalid = ABORTED @@ -74,7 +74,7 @@ error: abort code not covered by any of the `aborts_if` or `aborts_with` clauses = at tests/sources/functional/aborts_if_with_code.move:98: aborts_with_invalid = x = = at tests/sources/functional/aborts_if_with_code.move:101: aborts_with_invalid - = = + = x = = at tests/sources/functional/aborts_if_with_code.move:102: aborts_with_invalid = ABORTED @@ -96,6 +96,6 @@ error: abort code not covered by any of the `aborts_if` or `aborts_with` clauses = at tests/sources/functional/aborts_if_with_code.move:124: aborts_with_mixed_invalid = x = = at tests/sources/functional/aborts_if_with_code.move:127: aborts_with_mixed_invalid - = = + = x = = at tests/sources/functional/aborts_if_with_code.move:128: aborts_with_mixed_invalid = ABORTED diff --git a/third_party/move/move-prover/tests/sources/functional/choice.v2_exp b/third_party/move/move-prover/tests/sources/functional/choice.v2_exp index 9f8a12e2a7a11..1ac0f5b0e85ce 100644 --- a/third_party/move/move-prover/tests/sources/functional/choice.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/choice.v2_exp @@ -32,7 +32,7 @@ error: post-condition does not hold = at tests/sources/functional/choice.move:47: populate_R = s1 = = at tests/sources/functional/choice.move:48: populate_R - = s2 = + = s1 = = at tests/sources/functional/choice.move:49: populate_R = at tests/sources/functional/choice.move:56: populate_R (spec) @@ -45,7 +45,6 @@ error: post-condition does not hold = at tests/sources/functional/choice.move:76: test_not_using_min_incorrect = v = = at tests/sources/functional/choice.move:77: test_not_using_min_incorrect - = v_ref = = at tests/sources/functional/choice.move:78: test_not_using_min_incorrect = = = at tests/sources/functional/choice.move:79: test_not_using_min_incorrect @@ -58,7 +57,7 @@ error: post-condition does not hold = = = v = = at tests/sources/functional/choice.move:83: test_not_using_min_incorrect - = return = + = = = at tests/sources/functional/choice.move:75: test_not_using_min_incorrect = result = = at tests/sources/functional/choice.move:84: test_not_using_min_incorrect @@ -145,9 +144,6 @@ error: post-condition does not hold = at tests/sources/functional/choice.move:275: new_ballot_id = result = = at tests/sources/functional/choice.move:278: new_ballot_id - = = - = at tests/sources/functional/choice.move:287: create_ballot - = ballot_id = = at tests/sources/functional/choice.move:282: create_ballot = result = = at tests/sources/functional/choice.move:288: create_ballot diff --git a/third_party/move/move-prover/tests/sources/functional/data_invariant_for_mut_ref_arg.v2_exp b/third_party/move/move-prover/tests/sources/functional/data_invariant_for_mut_ref_arg.v2_exp index accf203d9c9c5..9ec50a0112d4e 100644 --- a/third_party/move/move-prover/tests/sources/functional/data_invariant_for_mut_ref_arg.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/data_invariant_for_mut_ref_arg.v2_exp @@ -26,7 +26,6 @@ error: data invariant does not hold = at tests/sources/functional/data_invariant_for_mut_ref_arg.move:26: push_2 = s = = at tests/sources/functional/data_invariant_for_mut_ref_arg.move:27: push_2 - = s = = at tests/sources/functional/data_invariant_for_mut_ref_arg.move:28: push_2 = at tests/sources/functional/data_invariant_for_mut_ref_arg.move:22: push_2 = s = diff --git a/third_party/move/move-prover/tests/sources/functional/data_invariant_in_map.v2_exp b/third_party/move/move-prover/tests/sources/functional/data_invariant_in_map.v2_exp index 9fe1cdff33742..a8079e5f4d271 100644 --- a/third_party/move/move-prover/tests/sources/functional/data_invariant_in_map.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/data_invariant_in_map.v2_exp @@ -7,9 +7,7 @@ error: data invariant does not hold │ = at tests/sources/functional/data_invariant_in_map.move:20: violation_1 = at tests/sources/functional/data_invariant_in_map.move:21: violation_1 - = t = = at tests/sources/functional/data_invariant_in_map.move:22: violation_1 - = = - = s = = at tests/sources/functional/data_invariant_in_map.move:23: violation_1 + = = = at tests/sources/functional/data_invariant_in_map.move:8 diff --git a/third_party/move/move-prover/tests/sources/functional/emits.v2_exp b/third_party/move/move-prover/tests/sources/functional/emits.v2_exp index 392584382ca2b..ff88a63b88c42 100644 --- a/third_party/move/move-prover/tests/sources/functional/emits.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/emits.v2_exp @@ -112,7 +112,8 @@ error: function does not emit the expected event = b = = handle = = at tests/sources/functional/emits.move:151: conditional_multiple_incorrect - = = + = b = + = handle = = at tests/sources/functional/emits.move:152: conditional_multiple_incorrect = at tests/sources/functional/emits.move:149: conditional_multiple_incorrect = handle = @@ -134,7 +135,8 @@ error: function does not emit the expected event = b = = handle = = at tests/sources/functional/emits.move:181: conditional_multiple_same_incorrect - = = + = b = + = handle = = at tests/sources/functional/emits.move:182: conditional_multiple_same_incorrect = at tests/sources/functional/emits.move:179: conditional_multiple_same_incorrect = handle = @@ -196,7 +198,7 @@ error: function does not emit the expected event = handle = = = = at tests/sources/functional/emits.move:288: opaque_incorrect - = = + = handle = = at tests/sources/functional/emits.move:289: opaque_incorrect = = = at tests/sources/functional/emits.move:286: opaque_incorrect @@ -224,7 +226,7 @@ error: emitted event not covered by any of the `emits` clauses = handle = = = = at tests/sources/functional/emits.move:311: opaque_completeness_incorrect - = = + = handle = = at tests/sources/functional/emits.move:312: opaque_completeness_incorrect = = = at tests/sources/functional/emits.move:309: opaque_completeness_incorrect @@ -253,7 +255,7 @@ error: emitted event not covered by any of the `emits` clauses = handle = = = = at tests/sources/functional/emits.move:352: opaque_partial_incorrect - = = + = handle = = at tests/sources/functional/emits.move:353: opaque_partial_incorrect = = = at tests/sources/functional/emits.move:350: opaque_partial_incorrect diff --git a/third_party/move/move-prover/tests/sources/functional/fixed_point_arithm.v2_exp b/third_party/move/move-prover/tests/sources/functional/fixed_point_arithm.v2_exp index 5d5c1903c37af..27dfe4630e200 100644 --- a/third_party/move/move-prover/tests/sources/functional/fixed_point_arithm.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/fixed_point_arithm.v2_exp @@ -8,6 +8,8 @@ error: post-condition does not hold = at tests/sources/functional/fixed_point_arithm.move:26: multiply_0_x_incorrect = x = = at tests/sources/functional/fixed_point_arithm.move:27: multiply_0_x_incorrect + = x = + = at tests/sources/functional/fixed_point_arithm.move:27: multiply_0_x_incorrect = result = = at tests/sources/functional/fixed_point_arithm.move:28: multiply_0_x_incorrect = at tests/sources/functional/fixed_point_arithm.move:30: multiply_0_x_incorrect (spec) @@ -23,7 +25,6 @@ error: post-condition does not hold = x = = at tests/sources/functional/fixed_point_arithm.move:43: multiply_x_0_incorrect = x = - = = = at tests/sources/functional/fixed_point_arithm.move:43: multiply_x_0_incorrect = result = = at tests/sources/functional/fixed_point_arithm.move:44: multiply_x_0_incorrect @@ -39,6 +40,8 @@ error: post-condition does not hold = at tests/sources/functional/fixed_point_arithm.move:64: multiply_1_x_incorrect = x = = at tests/sources/functional/fixed_point_arithm.move:65: multiply_1_x_incorrect + = x = + = at tests/sources/functional/fixed_point_arithm.move:65: multiply_1_x_incorrect = result = = at tests/sources/functional/fixed_point_arithm.move:66: multiply_1_x_incorrect = at tests/sources/functional/fixed_point_arithm.move:68: multiply_1_x_incorrect (spec) @@ -53,12 +56,11 @@ error: post-condition does not hold = at tests/sources/functional/fixed_point_arithm.move:81: multiply_x_1_incorrect = x = = at tests/sources/functional/fixed_point_arithm.move:82: multiply_x_1_incorrect - = x = = at ../move-stdlib/sources/fixed_point32.move:125 = at ../move-stdlib/sources/fixed_point32.move:126 = at ../move-stdlib/sources/fixed_point32.move:127 = at tests/sources/functional/fixed_point_arithm.move:82: multiply_x_1_incorrect - = = + = x = = at tests/sources/functional/fixed_point_arithm.move:82: multiply_x_1_incorrect = result = = at tests/sources/functional/fixed_point_arithm.move:83: multiply_x_1_incorrect @@ -80,15 +82,13 @@ error: post-condition does not hold = at ../move-stdlib/sources/fixed_point32.move:150: get_raw_value = result = = at ../move-stdlib/sources/fixed_point32.move:151: get_raw_value - = x = = at tests/sources/functional/fixed_point_arithm.move:106: mul_div_incorrect + = x = = y = - = y_raw_val = = at tests/sources/functional/fixed_point_arithm.move:106: mul_div_incorrect - = = = at tests/sources/functional/fixed_point_arithm.move:107: mul_div_incorrect - = = - = z = + = y = + = x = = at tests/sources/functional/fixed_point_arithm.move:107: mul_div_incorrect = result = = at tests/sources/functional/fixed_point_arithm.move:108: mul_div_incorrect @@ -109,15 +109,13 @@ error: post-condition does not hold = at ../move-stdlib/sources/fixed_point32.move:150: get_raw_value = result = = at ../move-stdlib/sources/fixed_point32.move:151: get_raw_value - = x = = at tests/sources/functional/fixed_point_arithm.move:106: mul_div_incorrect + = x = = y = - = y_raw_val = = at tests/sources/functional/fixed_point_arithm.move:106: mul_div_incorrect - = = = at tests/sources/functional/fixed_point_arithm.move:107: mul_div_incorrect - = = - = z = + = y = + = x = = at tests/sources/functional/fixed_point_arithm.move:107: mul_div_incorrect = result = = at tests/sources/functional/fixed_point_arithm.move:108: mul_div_incorrect @@ -135,6 +133,8 @@ error: post-condition does not hold = b = = c = = at tests/sources/functional/fixed_point_arithm.move:140: mul_2_times_incorrect + = a = + = at tests/sources/functional/fixed_point_arithm.move:140: mul_2_times_incorrect = result = = at tests/sources/functional/fixed_point_arithm.move:141: mul_2_times_incorrect = at tests/sources/functional/fixed_point_arithm.move:144: mul_2_times_incorrect (spec) @@ -151,6 +151,10 @@ error: post-condition does not hold = c = = d = = at tests/sources/functional/fixed_point_arithm.move:148: mul_3_times_incorrect + = a = + = at tests/sources/functional/fixed_point_arithm.move:148: mul_3_times_incorrect + = a = + = at tests/sources/functional/fixed_point_arithm.move:148: mul_3_times_incorrect = result = = at tests/sources/functional/fixed_point_arithm.move:149: mul_3_times_incorrect = at tests/sources/functional/fixed_point_arithm.move:152: mul_3_times_incorrect (spec) diff --git a/third_party/move/move-prover/tests/sources/functional/hash_model.v2_exp b/third_party/move/move-prover/tests/sources/functional/hash_model.v2_exp index b000e569c87f0..067befbd1a483 100644 --- a/third_party/move/move-prover/tests/sources/functional/hash_model.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/hash_model.v2_exp @@ -9,12 +9,8 @@ error: post-condition does not hold = v1 = = v2 = = at tests/sources/functional/hash_model.move:41: hash_test1_incorrect - = v1 = = at tests/sources/functional/hash_model.move:42: hash_test1_incorrect - = v2 = = at tests/sources/functional/hash_model.move:43: hash_test1_incorrect - = h1 = - = h2 = = result_1 = = result_2 = = at tests/sources/functional/hash_model.move:44: hash_test1_incorrect @@ -31,12 +27,8 @@ error: post-condition does not hold = v1 = = v2 = = at tests/sources/functional/hash_model.move:84: hash_test2_incorrect - = v1 = = at tests/sources/functional/hash_model.move:85: hash_test2_incorrect - = v2 = = at tests/sources/functional/hash_model.move:86: hash_test2_incorrect - = h1 = - = h2 = = result_1 = = result_2 = = at tests/sources/functional/hash_model.move:87: hash_test2_incorrect diff --git a/third_party/move/move-prover/tests/sources/functional/hash_model_invalid.v2_exp b/third_party/move/move-prover/tests/sources/functional/hash_model_invalid.v2_exp index edb74b494f9d8..902fea3a681d2 100644 --- a/third_party/move/move-prover/tests/sources/functional/hash_model_invalid.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/hash_model_invalid.v2_exp @@ -9,12 +9,8 @@ error: post-condition does not hold = v1 = = v2 = = at tests/sources/functional/hash_model_invalid.move:13: hash_test1 - = v1 = = at tests/sources/functional/hash_model_invalid.move:14: hash_test1 - = v2 = = at tests/sources/functional/hash_model_invalid.move:15: hash_test1 - = h1 = - = h2 = = result_1 = = result_2 = = at tests/sources/functional/hash_model_invalid.move:16: hash_test1 @@ -31,12 +27,8 @@ error: post-condition does not hold = v1 = = v2 = = at tests/sources/functional/hash_model_invalid.move:28: hash_test2 - = v1 = = at tests/sources/functional/hash_model_invalid.move:29: hash_test2 - = v2 = = at tests/sources/functional/hash_model_invalid.move:30: hash_test2 - = h1 = - = h2 = = result_1 = = result_2 = = at tests/sources/functional/hash_model_invalid.move:31: hash_test2 diff --git a/third_party/move/move-prover/tests/sources/functional/invariants.v2_exp b/third_party/move/move-prover/tests/sources/functional/invariants.v2_exp index 051e51eed97f5..3e362b420d6de 100644 --- a/third_party/move/move-prover/tests/sources/functional/invariants.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/invariants.v2_exp @@ -19,10 +19,9 @@ error: data invariant does not hold = at tests/sources/functional/invariants.move:113: lifetime_invalid_R = r = = at tests/sources/functional/invariants.move:114: lifetime_invalid_R - = r_ref = = at tests/sources/functional/invariants.move:115: lifetime_invalid_R - = x_ref = = at tests/sources/functional/invariants.move:116: lifetime_invalid_R + = = = at tests/sources/functional/invariants.move:15 error: data invariant does not hold @@ -44,13 +43,11 @@ error: data invariant does not hold = at tests/sources/functional/invariants.move:156: lifetime_invalid_S_branching = b = = at tests/sources/functional/invariants.move:157: lifetime_invalid_S_branching - = a_ref = + = = = at tests/sources/functional/invariants.move:158: lifetime_invalid_S_branching = at tests/sources/functional/invariants.move:143 = at tests/sources/functional/invariants.move:158: lifetime_invalid_S_branching = cond = - = b_ref = - = at tests/sources/functional/invariants.move:158: lifetime_invalid_S_branching = = = at tests/sources/functional/invariants.move:160: lifetime_invalid_S_branching = at tests/sources/functional/invariants.move:163: lifetime_invalid_S_branching diff --git a/third_party/move/move-prover/tests/sources/functional/is_txn_signer.v2_exp b/third_party/move/move-prover/tests/sources/functional/is_txn_signer.v2_exp index bb76d1302b97e..06eac2e0a45ea 100644 --- a/third_party/move/move-prover/tests/sources/functional/is_txn_signer.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/is_txn_signer.v2_exp @@ -55,8 +55,9 @@ error: global memory invariant does not hold = at tests/sources/functional/is_txn_signer.move:60: ADMIN_ADDRESS = result = = at tests/sources/functional/is_txn_signer.move:61: ADMIN_ADDRESS - = _account = = at tests/sources/functional/is_txn_signer.move:85: increment_incorrect + = _account = + = = = at tests/sources/functional/is_txn_signer.move:83: increment_incorrect = at tests/sources/functional/is_txn_signer.move:85: increment_incorrect = at tests/sources/functional/is_txn_signer.move:90 diff --git a/third_party/move/move-prover/tests/sources/functional/let.v2_exp b/third_party/move/move-prover/tests/sources/functional/let.v2_exp index eded3c5280a35..23ad0bafa7ec6 100644 --- a/third_party/move/move-prover/tests/sources/functional/let.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/let.v2_exp @@ -17,10 +17,12 @@ error: function does not abort under this condition = a = = b = = at tests/sources/functional/let.move:70: spec_let_with_abort_incorrect - = a = = at tests/sources/functional/let.move:71: spec_let_with_abort_incorrect - = at tests/sources/functional/let.move:72: spec_let_with_abort_incorrect + = a = = b = + = = + = at tests/sources/functional/let.move:72: spec_let_with_abort_incorrect + = = = at tests/sources/functional/let.move:69: spec_let_with_abort_incorrect = a = = b = @@ -58,7 +60,10 @@ error: abort not covered by any of the `aborts_if` clauses = a = = b = = at tests/sources/functional/let.move:70: spec_let_with_abort_incorrect + = at tests/sources/functional/let.move:71: spec_let_with_abort_incorrect = a = + = b = + = = = at tests/sources/functional/let.move:71: spec_let_with_abort_incorrect = ABORTED = at tests/sources/functional/let.move:77: spec_let_with_abort_incorrect (spec) diff --git a/third_party/move/move-prover/tests/sources/functional/loop_unroll.v2_exp b/third_party/move/move-prover/tests/sources/functional/loop_unroll.v2_exp index 4b791fe4c927f..5a9899d57c119 100644 --- a/third_party/move/move-prover/tests/sources/functional/loop_unroll.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/loop_unroll.v2_exp @@ -19,7 +19,7 @@ error: abort not covered by any of the `aborts_if` clauses = at tests/sources/functional/loop_unroll.move:94: t6_failure = at tests/sources/functional/loop_unroll.move:90: t6_failure = at tests/sources/functional/loop_unroll.move:96: t6_failure - = i = + = = = n = = at tests/sources/functional/loop_unroll.move:97: t6_failure = = @@ -30,7 +30,7 @@ error: abort not covered by any of the `aborts_if` clauses = at tests/sources/functional/loop_unroll.move:94: t6_failure = at tests/sources/functional/loop_unroll.move:90: t6_failure = at tests/sources/functional/loop_unroll.move:96: t6_failure - = i = + = = = n = = at tests/sources/functional/loop_unroll.move:97: t6_failure = = @@ -41,7 +41,7 @@ error: abort not covered by any of the `aborts_if` clauses = at tests/sources/functional/loop_unroll.move:94: t6_failure = at tests/sources/functional/loop_unroll.move:90: t6_failure = at tests/sources/functional/loop_unroll.move:96: t6_failure - = i = + = = = n = = at tests/sources/functional/loop_unroll.move:97: t6_failure = = @@ -52,7 +52,7 @@ error: abort not covered by any of the `aborts_if` clauses = at tests/sources/functional/loop_unroll.move:94: t6_failure = at tests/sources/functional/loop_unroll.move:90: t6_failure = at tests/sources/functional/loop_unroll.move:96: t6_failure - = i = + = = = n = = at tests/sources/functional/loop_unroll.move:97: t6_failure = = @@ -63,7 +63,7 @@ error: abort not covered by any of the `aborts_if` clauses = at tests/sources/functional/loop_unroll.move:94: t6_failure = at tests/sources/functional/loop_unroll.move:90: t6_failure = at tests/sources/functional/loop_unroll.move:96: t6_failure - = i = + = = = n = = at tests/sources/functional/loop_unroll.move:97: t6_failure = = @@ -89,32 +89,32 @@ error: abort not covered by any of the `aborts_if` clauses = n = = at tests/sources/functional/loop_unroll.move:122: t7_failure = at tests/sources/functional/loop_unroll.move:123: t7_failure - = i = + = = = n = = at tests/sources/functional/loop_unroll.move:124: t7_failure = = = at tests/sources/functional/loop_unroll.move:124: t7_failure = at tests/sources/functional/loop_unroll.move:122: t7_failure = at tests/sources/functional/loop_unroll.move:123: t7_failure - = i = + = = = n = = at tests/sources/functional/loop_unroll.move:124: t7_failure = = = at tests/sources/functional/loop_unroll.move:122: t7_failure = at tests/sources/functional/loop_unroll.move:123: t7_failure - = i = + = = = n = = at tests/sources/functional/loop_unroll.move:124: t7_failure = = = at tests/sources/functional/loop_unroll.move:122: t7_failure = at tests/sources/functional/loop_unroll.move:123: t7_failure - = i = + = = = n = = at tests/sources/functional/loop_unroll.move:124: t7_failure = = = at tests/sources/functional/loop_unroll.move:122: t7_failure = at tests/sources/functional/loop_unroll.move:123: t7_failure - = i = + = = = n = = at tests/sources/functional/loop_unroll.move:124: t7_failure = = diff --git a/third_party/move/move-prover/tests/sources/functional/loops.v2_exp b/third_party/move/move-prover/tests/sources/functional/loops.v2_exp index 7106ede7ae26d..cd77c4fb30149 100644 --- a/third_party/move/move-prover/tests/sources/functional/loops.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/loops.v2_exp @@ -64,7 +64,6 @@ error: induction case of the loop invariant does not hold = at tests/sources/functional/loops.move:123: nested_loop_outer_invariant_incorrect = at tests/sources/functional/loops.move:128: nested_loop_outer_invariant_incorrect = at tests/sources/functional/loops.move:131: nested_loop_outer_invariant_incorrect - = y = = x = = at tests/sources/functional/loops.move:117: nested_loop_outer_invariant_incorrect = at tests/sources/functional/loops.move:119: nested_loop_outer_invariant_incorrect @@ -111,7 +110,6 @@ error: induction case of the loop invariant does not hold = at tests/sources/functional/loops.move:191: loop_with_two_back_edges_incorrect = at tests/sources/functional/loops.move:195: loop_with_two_back_edges_incorrect = at tests/sources/functional/loops.move:196: loop_with_two_back_edges_incorrect - = y = = x = = at tests/sources/functional/loops.move:197: loop_with_two_back_edges_incorrect = at tests/sources/functional/loops.move:189: loop_with_two_back_edges_incorrect diff --git a/third_party/move/move-prover/tests/sources/functional/loops_with_memory_ops.v2_exp b/third_party/move/move-prover/tests/sources/functional/loops_with_memory_ops.v2_exp index eb9119dee9861..a3f77cb72c9ca 100644 --- a/third_party/move/move-prover/tests/sources/functional/loops_with_memory_ops.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/loops_with_memory_ops.v2_exp @@ -18,43 +18,43 @@ error: induction case of the loop invariant does not hold = length = = i = = at tests/sources/functional/loops_with_memory_ops.move:64: nested_loop2 + = length = = = - = x = = at tests/sources/functional/loops_with_memory_ops.move:66: nested_loop2 = at tests/sources/functional/loops_with_memory_ops.move:67: nested_loop2 = at tests/sources/functional/loops_with_memory_ops.move:68: nested_loop2 = at tests/sources/functional/loops_with_memory_ops.move:69: nested_loop2 = at tests/sources/functional/loops_with_memory_ops.move:70: nested_loop2 - = enter loop, variable(s) a, b, b, i, x havocked and reassigned + = enter loop, variable(s) a, b, b, i, $t28 havocked and reassigned = a = = b = = i = - = x = + = = = loop invariant holds at current state = at tests/sources/functional/loops_with_memory_ops.move:67: nested_loop2 = at tests/sources/functional/loops_with_memory_ops.move:68: nested_loop2 = at tests/sources/functional/loops_with_memory_ops.move:69: nested_loop2 = at tests/sources/functional/loops_with_memory_ops.move:70: nested_loop2 = at tests/sources/functional/loops_with_memory_ops.move:74: nested_loop2 - = enter loop, variable(s) i, x havocked and reassigned + = enter loop, variable(s) i, $t28 havocked and reassigned = i = - = x = + = = = at tests/sources/functional/loops_with_memory_ops.move:75: nested_loop2 = at tests/sources/functional/loops_with_memory_ops.move:80: nested_loop2 = at tests/sources/functional/loops_with_memory_ops.move:81: nested_loop2 = a = - = at tests/sources/functional/loops_with_memory_ops.move:81: nested_loop2 = b = + = at tests/sources/functional/loops_with_memory_ops.move:81: nested_loop2 = at tests/sources/functional/loops_with_memory_ops.move:85: nested_loop2 = = = b = = at tests/sources/functional/loops_with_memory_ops.move:86: nested_loop2 = at tests/sources/functional/loops_with_memory_ops.move:89: nested_loop2 - = y = + = length = = i = = at tests/sources/functional/loops_with_memory_ops.move:90: nested_loop2 + = length = = = - = x = = at tests/sources/functional/loops_with_memory_ops.move:65: nested_loop2 = at tests/sources/functional/loops_with_memory_ops.move:67: nested_loop2 = at tests/sources/functional/loops_with_memory_ops.move:68: nested_loop2 @@ -80,33 +80,30 @@ error: unknown assertion failed = length = = i = = at tests/sources/functional/loops_with_memory_ops.move:64: nested_loop2 + = length = = = - = x = = at tests/sources/functional/loops_with_memory_ops.move:66: nested_loop2 = at tests/sources/functional/loops_with_memory_ops.move:67: nested_loop2 = at tests/sources/functional/loops_with_memory_ops.move:68: nested_loop2 = at tests/sources/functional/loops_with_memory_ops.move:69: nested_loop2 = at tests/sources/functional/loops_with_memory_ops.move:70: nested_loop2 - = enter loop, variable(s) a, b, b, i, x havocked and reassigned + = enter loop, variable(s) a, b, b, i, $t28 havocked and reassigned = a = = b = = i = - = x = + = = = loop invariant holds at current state = at tests/sources/functional/loops_with_memory_ops.move:67: nested_loop2 = at tests/sources/functional/loops_with_memory_ops.move:68: nested_loop2 = at tests/sources/functional/loops_with_memory_ops.move:69: nested_loop2 = at tests/sources/functional/loops_with_memory_ops.move:70: nested_loop2 = at tests/sources/functional/loops_with_memory_ops.move:74: nested_loop2 - = enter loop, variable(s) i, x havocked and reassigned + = enter loop, variable(s) i, $t28 havocked and reassigned = i = - = x = + = = = at tests/sources/functional/loops_with_memory_ops.move:75: nested_loop2 = at tests/sources/functional/loops_with_memory_ops.move:80: nested_loop2 = at tests/sources/functional/loops_with_memory_ops.move:81: nested_loop2 - = a = - = b = - = at tests/sources/functional/loops_with_memory_ops.move:81: nested_loop2 = at tests/sources/functional/loops_with_memory_ops.move:85: nested_loop2 = = = b = diff --git a/third_party/move/move-prover/tests/sources/functional/mut_ref.v2_exp b/third_party/move/move-prover/tests/sources/functional/mut_ref.v2_exp index 968ca06aec16c..6d2769d4c7b6f 100644 --- a/third_party/move/move-prover/tests/sources/functional/mut_ref.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/mut_ref.v2_exp @@ -40,6 +40,7 @@ error: data invariant does not hold = result = = x = = at tests/sources/functional/mut_ref.move:92: return_ref_different_path_vec2 + = at tests/sources/functional/mut_ref.move:122: call_return_ref_different_path_vec2_incorrect = = = at tests/sources/functional/mut_ref.move:122: call_return_ref_different_path_vec2_incorrect = at tests/sources/functional/mut_ref.move:8 diff --git a/third_party/move/move-prover/tests/sources/functional/nested_invariants.v2_exp b/third_party/move/move-prover/tests/sources/functional/nested_invariants.v2_exp index b4d83685c0075..d177659668d6f 100644 --- a/third_party/move/move-prover/tests/sources/functional/nested_invariants.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/nested_invariants.v2_exp @@ -13,8 +13,8 @@ error: data invariant does not hold = at tests/sources/functional/nested_invariants.move:64: mutate_inner_data_invariant_invalid = o = = at tests/sources/functional/nested_invariants.move:65: mutate_inner_data_invariant_invalid - = r = = at tests/sources/functional/nested_invariants.move:66: mutate_inner_data_invariant_invalid + = = = at tests/sources/functional/nested_invariants.move:29 = at tests/sources/functional/nested_invariants.move:32 = at tests/sources/functional/nested_invariants.move:16 @@ -42,8 +42,8 @@ error: data invariant does not hold = at tests/sources/functional/nested_invariants.move:58: mutate_outer_data_invariant_invalid = o = = at tests/sources/functional/nested_invariants.move:59: mutate_outer_data_invariant_invalid - = r = = at tests/sources/functional/nested_invariants.move:60: mutate_outer_data_invariant_invalid + = = = at tests/sources/functional/nested_invariants.move:29 = at tests/sources/functional/nested_invariants.move:32 diff --git a/third_party/move/move-prover/tests/sources/functional/nonlinear_arithm.v2_exp b/third_party/move/move-prover/tests/sources/functional/nonlinear_arithm.v2_exp index df8ab37977749..d23bdded04c8c 100644 --- a/third_party/move/move-prover/tests/sources/functional/nonlinear_arithm.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/nonlinear_arithm.v2_exp @@ -148,6 +148,7 @@ error: post-condition does not hold = at tests/sources/functional/nonlinear_arithm.move:207: mul5_incorrect = at tests/sources/functional/nonlinear_arithm.move:208: mul5_incorrect = at tests/sources/functional/nonlinear_arithm.move:210: mul5_incorrect + = a = = at tests/sources/functional/nonlinear_arithm.move:203: mul5_incorrect = result = = at tests/sources/functional/nonlinear_arithm.move:211: mul5_incorrect @@ -165,6 +166,8 @@ error: post-condition does not hold = c = = d = = at tests/sources/functional/nonlinear_arithm.move:225: distribution_law_incorrect + = b = + = a = = result = = at tests/sources/functional/nonlinear_arithm.move:226: distribution_law_incorrect = at tests/sources/functional/nonlinear_arithm.move:228: distribution_law_incorrect (spec) diff --git a/third_party/move/move-prover/tests/sources/functional/references.v2_exp b/third_party/move/move-prover/tests/sources/functional/references.v2_exp index fbb7171105515..7bfd263a4e3f8 100644 --- a/third_party/move/move-prover/tests/sources/functional/references.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/references.v2_exp @@ -8,7 +8,6 @@ error: function does not abort under this condition = at tests/sources/functional/references.move:69: mut_ref_incorrect = b = = at tests/sources/functional/references.move:70: mut_ref_incorrect - = b_ref = = at tests/sources/functional/references.move:71: mut_ref_incorrect = = = at tests/sources/functional/references.move:50: mut_b diff --git a/third_party/move/move-prover/tests/sources/functional/serialize_model.v2_exp b/third_party/move/move-prover/tests/sources/functional/serialize_model.v2_exp index faa9e43030cf1..956592095522b 100644 --- a/third_party/move/move-prover/tests/sources/functional/serialize_model.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/serialize_model.v2_exp @@ -9,12 +9,8 @@ error: post-condition does not hold = v1 = = v2 = = at tests/sources/functional/serialize_model.move:28: bcs_test1_incorrect - = v1 = = at tests/sources/functional/serialize_model.move:29: bcs_test1_incorrect - = v2 = = at tests/sources/functional/serialize_model.move:30: bcs_test1_incorrect - = s1 = - = s2 = = result_1 = = result_2 = = at tests/sources/functional/serialize_model.move:31: bcs_test1_incorrect diff --git a/third_party/move/move-prover/tests/sources/functional/specs_in_fun.v2_exp b/third_party/move/move-prover/tests/sources/functional/specs_in_fun.v2_exp index a631c33087ebb..6de09f87f158f 100644 --- a/third_party/move/move-prover/tests/sources/functional/specs_in_fun.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/specs_in_fun.v2_exp @@ -9,6 +9,7 @@ error: unknown assertion failed = x = = y = = at tests/sources/functional/specs_in_fun.move:43: simple1_incorrect + = x = = at tests/sources/functional/specs_in_fun.move:45: simple1_incorrect error: unknown assertion failed diff --git a/third_party/move/move-prover/tests/sources/functional/strong_edges.v2_exp b/third_party/move/move-prover/tests/sources/functional/strong_edges.v2_exp index cca2f7435587a..1905172c1632c 100644 --- a/third_party/move/move-prover/tests/sources/functional/strong_edges.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/strong_edges.v2_exp @@ -10,8 +10,9 @@ error: post-condition does not hold = at tests/sources/functional/strong_edges.move:47: glob_and_field_edges_incorrect = addr = = at tests/sources/functional/strong_edges.move:48: glob_and_field_edges_incorrect - = addr = = at tests/sources/functional/strong_edges.move:49: glob_and_field_edges_incorrect + = addr = + = = = at tests/sources/functional/strong_edges.move:50: glob_and_field_edges_incorrect = at tests/sources/functional/strong_edges.move:55: glob_and_field_edges_incorrect (spec) = at tests/sources/functional/strong_edges.move:54: glob_and_field_edges_incorrect (spec) @@ -25,7 +26,7 @@ error: unknown assertion failed = at tests/sources/functional/strong_edges.move:60: loc__edge_incorrect = r = = at tests/sources/functional/strong_edges.move:61: loc__edge_incorrect - = r_ref = = at tests/sources/functional/strong_edges.move:62: loc__edge_incorrect + = = = r = = at tests/sources/functional/strong_edges.move:64: loc__edge_incorrect diff --git a/third_party/move/move-prover/tests/sources/functional/trace.v2_exp b/third_party/move/move-prover/tests/sources/functional/trace.v2_exp index 3a03fb8ff1529..b6908eee455b2 100644 --- a/third_party/move/move-prover/tests/sources/functional/trace.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/trace.v2_exp @@ -14,6 +14,8 @@ error: post-condition does not hold = a = = b = = at tests/sources/functional/trace.move:16: add_invalid + = b = + = a = = result = = at tests/sources/functional/trace.move:17: add_invalid = at tests/sources/functional/trace.move:19: add_invalid (spec) @@ -35,6 +37,8 @@ error: post-condition does not hold = b = = at tests/sources/functional/trace.move:23: update_invalid = a = + = b = + = a = = at tests/sources/functional/trace.move:24: update_invalid = at tests/sources/functional/trace.move:26: update_invalid (spec) = `ensures a == old(a) + b;` = diff --git a/third_party/move/move-prover/tests/sources/functional/type_dependent_code.v2_exp b/third_party/move/move-prover/tests/sources/functional/type_dependent_code.v2_exp index 9378f56af2a69..a601c772ae0e5 100644 --- a/third_party/move/move-prover/tests/sources/functional/type_dependent_code.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/type_dependent_code.v2_exp @@ -60,9 +60,8 @@ error: post-condition does not hold = at ../move-stdlib/sources/signer.move:13: address_of = result = = at ../move-stdlib/sources/signer.move:14: address_of - = account = = at tests/sources/functional/type_dependent_code.move:47: test1 - = x = + = account = = at tests/sources/functional/type_dependent_code.move:48: test1 = at tests/sources/functional/type_dependent_code.move:50: test1 (spec) @@ -83,8 +82,7 @@ error: post-condition does not hold = at ../move-stdlib/sources/signer.move:13: address_of = result = = at ../move-stdlib/sources/signer.move:14: address_of - = account = = at tests/sources/functional/type_dependent_code.move:63: test2 - = t1 = + = account = = at tests/sources/functional/type_dependent_code.move:64: test2 = at tests/sources/functional/type_dependent_code.move:66: test2 (spec) diff --git a/third_party/move/move-prover/tests/sources/functional/verify_custom_table.v2_exp b/third_party/move/move-prover/tests/sources/functional/verify_custom_table.v2_exp index 868c816071271..7fce261fff366 100644 --- a/third_party/move/move-prover/tests/sources/functional/verify_custom_table.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/verify_custom_table.v2_exp @@ -14,7 +14,7 @@ error: post-condition does not hold = at tests/sources/functional/verify_custom_table.move:72: add_fail = t = = at tests/sources/functional/verify_custom_table.move:73: add_fail - = return = + = = = at tests/sources/functional/verify_custom_table.move:68: add_fail = result = = at tests/sources/functional/verify_custom_table.move:74: add_fail @@ -31,7 +31,7 @@ error: post-condition does not hold = at tests/sources/functional/verify_custom_table.move:203: create_and_insert_fail_due_to_typed_key_encoding = t = = at tests/sources/functional/verify_custom_table.move:204: create_and_insert_fail_due_to_typed_key_encoding - = return = + = = = at tests/sources/functional/verify_custom_table.move:201: create_and_insert_fail_due_to_typed_key_encoding = result = = at tests/sources/functional/verify_custom_table.move:205: create_and_insert_fail_due_to_typed_key_encoding @@ -48,7 +48,7 @@ error: post-condition does not hold = at tests/sources/functional/verify_custom_table.move:215: create_and_insert_fail1 = t = = at tests/sources/functional/verify_custom_table.move:216: create_and_insert_fail1 - = return = + = = = at tests/sources/functional/verify_custom_table.move:213: create_and_insert_fail1 = result = = at tests/sources/functional/verify_custom_table.move:217: create_and_insert_fail1 @@ -65,7 +65,7 @@ error: post-condition does not hold = at tests/sources/functional/verify_custom_table.move:224: create_and_insert_fail2 = t = = at tests/sources/functional/verify_custom_table.move:225: create_and_insert_fail2 - = return = + = = = at tests/sources/functional/verify_custom_table.move:222: create_and_insert_fail2 = result = = at tests/sources/functional/verify_custom_table.move:226: create_and_insert_fail2 diff --git a/third_party/move/move-prover/tests/sources/functional/verify_table.v2_exp b/third_party/move/move-prover/tests/sources/functional/verify_table.v2_exp index 6a8a1685a62bb..0bd5b0c48a783 100644 --- a/third_party/move/move-prover/tests/sources/functional/verify_table.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/verify_table.v2_exp @@ -14,7 +14,7 @@ error: post-condition does not hold = at tests/sources/functional/verify_table.move:27: add_fail = t = = at tests/sources/functional/verify_table.move:28: add_fail - = return = + = = = at tests/sources/functional/verify_table.move:23: add_fail = result = = at tests/sources/functional/verify_table.move:29: add_fail diff --git a/third_party/move/move-prover/tests/sources/regression/type_param_bug_121721.v2_exp b/third_party/move/move-prover/tests/sources/regression/type_param_bug_121721.v2_exp index c2252d8dd79a8..6849312b04e0e 100644 --- a/third_party/move/move-prover/tests/sources/regression/type_param_bug_121721.v2_exp +++ b/third_party/move/move-prover/tests/sources/regression/type_param_bug_121721.v2_exp @@ -17,8 +17,9 @@ error: global memory invariant does not hold = at ../move-stdlib/sources/signer.move:14: address_of = proposal = = at tests/sources/regression/type_param_bug_121721.move:86: create_ballot + = = = at tests/sources/regression/type_param_bug_121721.move:88: create_ballot = at tests/sources/regression/type_param_bug_121721.move:87: create_ballot - = = + = ballot_address = = at tests/sources/regression/type_param_bug_121721.move:167 = at tests/sources/regression/type_param_bug_121721.move:173 diff --git a/third_party/move/move-prover/tests/sources/regression/type_param_bug_200228.v2_exp b/third_party/move/move-prover/tests/sources/regression/type_param_bug_200228.v2_exp index dbc8cf4e7584a..caa0f5b262170 100644 --- a/third_party/move/move-prover/tests/sources/regression/type_param_bug_200228.v2_exp +++ b/third_party/move/move-prover/tests/sources/regression/type_param_bug_200228.v2_exp @@ -8,7 +8,6 @@ error: post-condition does not hold = at tests/sources/regression/type_param_bug_200228.move:6: type_param_bug = addr = = at tests/sources/regression/type_param_bug_200228.move:7: type_param_bug - = addr = = result = = at tests/sources/regression/type_param_bug_200228.move:8: type_param_bug = at tests/sources/regression/type_param_bug_200228.move:11: type_param_bug (spec) diff --git a/third_party/move/scripts/move_pr.sh b/third_party/move/scripts/move_pr.sh index 62f4d0ce4cfde..de5415101d3dd 100755 --- a/third_party/move/scripts/move_pr.sh +++ b/third_party/move/scripts/move_pr.sh @@ -20,7 +20,7 @@ echo "*************** [move-pr] Assuming move root at $MOVE_BASE" # Run only tests which would also be run on CI export ENV_TEST_ON_CI=1 -while getopts "htcgdia" opt; do +while getopts "htcgdi2a" opt; do case $opt in h) cat <