-
Notifications
You must be signed in to change notification settings - Fork 11.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[0/n][enums] Move enums implementation #17245
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The latest updates on your projects. Learn more about Vercel for Git ↗︎
3 Ignored Deployments
|
This was referenced Apr 19, 2024
tzakian
force-pushed
the
tzakian/move-enums-implementation
branch
from
April 22, 2024 19:57
96fab27
to
060990f
Compare
tzakian
force-pushed
the
tzakian/move-enums-implementation
branch
from
April 22, 2024 22:39
060990f
to
6c5ab65
Compare
tnowacki
requested changes
Apr 24, 2024
tnowacki
reviewed
Apr 24, 2024
external-crates/move/crates/move-binary-format/src/file_format_common.rs
Outdated
Show resolved
Hide resolved
UnpackVariantGeneric(VariantHandle), | ||
UnpackVariantGenericImmRef(VariantHandle), | ||
UnpackVariantGenericMutRef(VariantHandle), | ||
VariantSwitch(VariantJumpTable), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was scrolling quickly and was like wtf... then realized this was normalized.rs
... proceed :)
external-crates/move/crates/move-cli/tests/move_unit_tests/test_with_warnings/Move.toml
Show resolved
Hide resolved
tzakian
force-pushed
the
tzakian/move-enums-implementation
branch
from
April 25, 2024 23:27
6c5ab65
to
0b0e5bd
Compare
tzakian
force-pushed
the
tzakian/move-enums-implementation
branch
from
May 2, 2024 19:35
0b0e5bd
to
bcb9f29
Compare
tzakian
force-pushed
the
tzakian/move-enums-implementation
branch
from
May 13, 2024 18:28
bcb9f29
to
6a646a2
Compare
tzakian
force-pushed
the
tzakian/move-enums-implementation
branch
from
May 14, 2024 22:09
6a646a2
to
1f87170
Compare
tzakian
force-pushed
the
tzakian/move-enums-implementation
branch
from
May 16, 2024 20:50
1f87170
to
48ebf3c
Compare
tzakian
force-pushed
the
tzakian/move-enums-implementation
branch
from
May 21, 2024 19:52
48ebf3c
to
b067549
Compare
tzakian
force-pushed
the
tzakian/move-enums-implementation
branch
from
May 22, 2024 18:04
0e9fab5
to
8f1cb35
Compare
tnowacki
approved these changes
May 23, 2024
tzakian
force-pushed
the
tzakian/move-enums-implementation
branch
from
May 23, 2024 17:17
8f1cb35
to
0caf49f
Compare
tzakian
force-pushed
the
tzakian/move-enums-implementation
branch
from
May 23, 2024 18:49
0caf49f
to
9a3dd52
Compare
tzakian
force-pushed
the
tzakian/move-enums-implementation
branch
from
May 24, 2024 00:42
9a3dd52
to
5c315e9
Compare
tzakian
added a commit
that referenced
this pull request
May 24, 2024
## Description This is the top-level (and final!) PR in the stack for Move enums. This PR * Updates the protocol config to support the new execution version * Adds new e2e adapter tests to make sure we handle enums properly * Updates snapshots for tests (and protocol config snapshots and the like). This also then tests all other tests that have been added below this in the stack (e.g., the package resolver tests, graphql tests, all the Move tests, other misc tests that were added). **NB:** Before landing this we need to determine the best way of turning on the correct binary-version for testing only. So I would encourage mainly looking at the tests (and the updated snapshots for the replay tool). Protocol-config changes, and snapshots for them will need to be updated as this gets closer to landing, and we further concretize the testing/pre-rollout/rollout plan. ## Stack: * #17245 * #17246 * #17247 * #17248 * #17249 * #17250 * #17251 **<< You are here** 🎉 ## Test plan It's pretty much all tests.
tzakian
added a commit
that referenced
this pull request
May 24, 2024
## Description Adds support for Move enums to both graphql and json-rpc. This adds a couple different things. At a high level: 1. Adds an interface `IMoveDatatype` that allows for access to common fields between both Move structs and enums (e.g., name, type parameters, abilities). 2. Adds methods `datatype(name: String)` and `datatypes` to `MovePackage` that returns datatypes. Note that datatype names are still sorted in the same way as before in pagination (in particular: it will not be paginated as all structs, then all enums or vis-versa, but paginated in sorted order on the datatype names). This is due to the way `datatypes` is implemented in the package resolver. 3. Adds `MoveEnum` as a GraphQL type and associated machinery. This PR is meant to be a logically-reviewable portion but is not land-able on its own. It must be merged in with the changes in the rest of this stack to be landed. ## Stack: * #17245 * #17246 * #17247 * #17248 * #17249 * #17250 **<< You are here** * #17251 ## Test plan Added new tests in this PR for the new features. --- ## Release notes Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required. For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates. - [ ] Protocol: - [ ] Nodes (Validators and Full nodes): - [ ] Indexer: - [X] JSON-RPC: - [X] GraphQL: - [ ] CLI: - [ ] Rust SDK:
tzakian
added a commit
that referenced
this pull request
May 24, 2024
## Description Adds support for Move enums to the Sui package resolver crate along with tests for it. This PR is meant to be a logically-reviewable portion but is not land-able on its own. It must be merged in with the changes in the rest of this stack to be landed. ## Stack: * #17245 * #17246 * #17247 * #17248 * #17249 **<< You are here** * #17250 * #17251 ## Test plan Added tests in the PR to make sure we can properly resolve enum types. --- ## Release notes Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required. For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates. - [ ] Protocol: - [ ] Nodes (Validators and Full nodes): - [ ] Indexer: - [ ] JSON-RPC: - [ ] GraphQL: - [ ] CLI: - [ ] Rust SDK:
tzakian
added a commit
that referenced
this pull request
May 24, 2024
## Description Changes for Move enums in `sui-execution`. Generally nothing surprising. Only thing worth note is that enums are not allowed to be OTWs (see tests in top commit in this stack). This PR is meant to be a logically-reviewable portion but is not land-able on its own. It must be merged in with the changes in the rest of this stack to be landed. ## Stack: * #17245 * #17246 * #17247 * #17248 **<< You are here** * #17249 * #17250 * #17251 ## Test plan Tests in the top commit on this stack.
tzakian
added a commit
that referenced
this pull request
May 24, 2024
…ms (#17247) ## Description This PR contains the changes needed for Move enums in sui-types, the protocol config changes (except for bumping the bytecode version), along with other misc/smaller changes that are not easily categorized. This PR is meant to be a logically-reviewable portion but is not land-able on its own. It must be merged in with the changes in the rest of this stack to be landed. ## Stack: * #17245 * #17246 * #17247 **<< You are here** * #17248 * #17249 * #17250 * #17251 ## Test plan Tests are in the top commit in this stack here:
## Description This PR consists of tests only! (and updates to exp files of existing tests). ## Stack: * #17245 * #17246 **<< You are here** * #17247 * #17248 * #17249 * #17250 * #17251 # Test Plan ## File format Status: Done * Bounds checking and serialization proptests updated. ### Deserializer Status: Done * Added test to verify that we are properly checking for versioning issues -- e.g., if someone manually changed the version of the serialized module so the version was pre-enums, but contained enum-data inside of it. ### Serializer Status: Done * Ensured that serializing a version 7 module at version 6 works as long as no version 7 features are used, and that the resulting module can be deserialized into version 6 and version 7 modules. * Proptests for serializer/deserializer round-trips * Tested round-trip properties: - Version 7 module with no eums can: - Be serialized under version 6 - Result can be deserialized under version 6 and 7 and reserialized at version 6 and 7. * Updated serializer, and added tests to make sure we use the module's version when serializing, unless it is specified as an override. ## Compatibility Status: Done * [x] Add config to allow adding new variants * [x] Existing variants must be in the same order (have the same tag) * [x] Cannot remove a variant * [x] Cannot change a field or fields of an existing variant * [x] Cannot rename existing variant ## Bytecode Verifier Status: Done * [x] Unpack - [x] [type-checker] Unpack a non-generic enum with generic instruction (by value, imm ref, and mut ref) - [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/unpack_non_generic_enum_generically.mvir] - [x] [type-checker] Unpack a generic enum with non-generic instruction (by value, imm ref, and mut ref) - [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/unpack_generic_enum_non_generically.mvir] - [x] [type-checker] Unpack a generic enum with invalid type arguments (by value, imm ref, and mut ref) - [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/unpack_generic_enum_wrong_type_arg.mvir] - [x] ImmRef - [type-checker] Unpack a mutable reference [generic, non-generic] - [type-checker] Unpack a value [generic, non-generic] - [x] MutRef - [type-checker] Unpack an immutable reference [generic, non-generic] - [type-checker] Unpack a value [generic, non-generic] - [x] [stack-balance] Unpack with invalid number of arguments [too many, too little] - [x] [bound-checker] Invalid variant index [generic, non-generic] - [x] [bound-checker] Invalid enum definition/definition instantiation index [generic, non-generic] * [x] Write test to make sure we properly track borrows out of variant ref unpacks: - [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/reference_safety/factor_invalid_2_enum.mvir] - [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/reference_safety/imm_borrow_on_mut_trivial_invalid_enum.mvir] * Pack - [x] [type-checker] Pack a non-generic enum [generic] - [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/pack_generic_enum_non_generically.mvir] - [x] [type-checker] Pack a generic enum [non-generic] - [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/pack_non_generic_enum_generically.mvir] - [x] [type-checker] Pack a generic enum with invalid type arguments [generic] - [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/pack_generic_enum_invalid_type_arguments.mvir] - [bound-checker] Invalid variant index [generic, non-generic] - [x] Pack with invalid number of arguments [generic, non-generic][too many, too little] - [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/stack_usage_verifier/pack_invalid_number_arguments_enum.mvir] - [x] Pack with references [generic, non-generic][imm-ref, mut-ref] - [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/pack_enum_with_refs.mvir] * VariantSwitch/Jump Table (these cannot be IR tests sadly except for the last) - [type-checker] Head Type - [x] Head type isn't an enum [struct, primitive type] - Structurally impossible to represent since it takes an enum definition index - [x] Head type is a reference type [enum, struct, primitive type] - Structurally impossible to represent since it takes an enum definition index - [x] Head type is to a different enum [generic, mono] - [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/variant_switch_invalid_head_type.mvir] - Switch value type - [x] [type-checker] Not a reference [enum, struct, primitive type] - [x] [type-checker] Is a mutable reference [enum, struct, primitive type] - [x] [type-checker] Switch value type and head type disagree [enum/struct, struct/enum, enum/primitive, struct/primitive, reference[enum,struct,primitive]] - [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/variant_switch_invalid_head_type.mvir] - [x] [bounds-checker] Invalid code index in jump table - [x] [bound-checker] Invalid jump table index - Exhaustiveness * [x] [type-checker] Write test that checks we properly error if an inexhaustive jump table is supplied [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/variant_switch_partial_enum_switch.mvir] ### Abilities * [x] Enum can have fewer abilities than the type that it contains [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/ability_field_requirements/unrestricted_enum_has_resource_field.exp] * [x] Enum cannot have abilities that a type that it contains does not satisfy [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/ability_field_requirements/unrestricted_enum_has_resource_field.mvir] ### check_bounds * [x] Generic enum cannot have too few type arguments [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/check_bounds/too_few_type_actuals_enum.mvir] * [x] Generic enum cannot have too many type arguments [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/check_bounds/too_many_type_actuals_enum.mvir] ### check_duplication * [x] Cannot have enum and struct in the same module with the same name [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/check_duplication/duplicate_enum_and_struct_names.mvir] * [x] Cannot have two enums in the same module with the same name [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/check_duplication/duplicate_enum_name.mvir] * [x] Cannot have an enum variant with duplicate field names [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/check_duplication/duplicate_field_name_enum.mvir] * [x] Cannot have an enum with duplicate variant names [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/check_duplication/duplicate_variant_name.mvir] * [x] Cannot have an empty enum [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/check_duplication/empty_enums.mvir] - [x] Check for duplicated variant handles [external-crates/move/crates/bytecode-verifier-tests/src/unit_tests/duplication_tests.rs] - [x] Check for duplicated datatype names [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/enum_defs/module_enum_struct_shared_name.mvir] ### enum_defs * [x] Can have an enum with the same name as the module [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/enum_defs/module_enum_shared_name.mvir] * [x] Cannot have mutually recursive enums (simple test) [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/enum_defs/mutual_recursive_enum.mvir] * [x] More complex recursive enum definition checks [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/enum_defs/recursive_enum.mvir] * [x] Cannot declare an enum with references inside of it [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/enum_defs/ref_in_enum.mvir] ### instantiaion_loops [each test is an existing test that we have for structs but ported over to enums] * [x] Complex type instantiation loop using enums [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/instantiation_loops/complex_1_enum.mvir] * [x] Mutually recursive enum type instantiated with a type is OK [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/instantiation_loops/mutually_recursive_non_generic_type_ok_enum.mvir] * [x] Mutually recursive enum type instantiation with a type is OK since the types eventually shuffle to ground out [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/instantiation_loops/mutually_recursive_three_args_type_con_non_generic_types_ok_enum.mvir] * ... ### locals_safety * [x] Re-assign an enum that doesn't have drop [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/locals_safety/assign_enum_resource.mvir] ### stack_usage_verifier * [x] Unpack an enum variant with too many fields [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/stack_usage_verifier/unpack_extra_binding_enum.mvir] * [x] Unpack an enum variant with too few fields [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/stack_usage_verifier/unpack_missing_binding_enum.mvir] ### type_safety * [x] Write a mutable non-drop reference containing an enum [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/assign_local_resource.mvir] * [x] Write a mutable non-drop reference containing an enum twice [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/assign_local_resource_twice.mvir] * [x] Write a mutable non-drop reference contained in an enum [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/assign_resource_type_enum.mvir] * [x] Dereference an non-copy enum reference type [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/cant_deref_resource.mvir] * [x] Check that equality can occur over enum references without drop [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/equality_resource_refs.mvir] * [x] Check that equality cannot be called over non-drop enum types [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/equality_resource_values.mvir] * [x] Verify that we can take immutable references into an enum variant, and then take those fields by ownership once those references are no longer live [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/generic_abilities_imm_unpack_enum.mvir] * [x] Verify that we can take mutable references into an enum variant, and then take those fields by ownership once those references are no longer live [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/generic_abilities_unpack_mut_enum.mvir] * [x] Verify that we properly typecheck a valid generic pack of an enum variant [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/generic_abilities_pack.mvir] * [x] Try to copy an enum type that does not have copy [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/generic_abilities_struct_non_nominal_resource.mvir] * [x] Unpack a generic enum where the inner value's type parameter doesn't have copy, and then fail to the destroy the value after unpacking [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/generic_abilities_unpack.mvir] * [x] Can call a generic function with an instantiated enum variant value [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/generic_call.mvir] * [x] Can borrow a deep generic field from within an enum/its variants and properly dereference and return the resulting value [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/generic_field_borrow.mvir] * [x] Can borrow and unpack an enum reference returned from a generic function call [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/generic_field_unpack_borrow_after_call_enum.mvir] * [x] Can import and use a generic enum type from another module [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/generic_import_struct.mvir] * [x] Example using `Option` (the actual one this time!) and making sure it typechecks [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/generic_option.mvir] * [x] We can call pack a generic enum variant correctly [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/generic_pack.mvir] * [x] Check correct ability constraints for enum definition parameters [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/generic_struct_def.mvir] * [x] Type mismatch in a field write inside an enum variant [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/invalid_field_write_mut_unpack_enum.mvir] * [x] Type mismatch in generic unpack of enum [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/generic_unpack_type_mismatch.mvir] * [x] Type mismatch in generic pack of enum (and struct) [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/generic_pack_type_mismatch.mvir] * [x] Try to overwrite a non-drop value by mut ref held inside an enum [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/invalid_resouce_write_unpack_mut_enum.mvir] * [x] Try to unpack_mut on an immutable reference (both generic and non-generic) [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/mut_borrow_from_imm_ref_enum.mvir] * [x] Pass an imm ref enum type to a function expecting a mut ref [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/mut_call_with_imm_ref_enum.mvir] * [x] Make sure bytecode operations ability requirements respect enum type abilities [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/phantom_params/bytecode_ops_abilities_bad.mvir] * [x] Make sure bytecode operations ability requirements work with enum abilities (positive tests) [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/phantom_params/bytecode_ops_abilities_ok.mvir] * [x] Verify ability constraints are properly enforced for enum types [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/phantom_params/constraints_abilities_bad.mvir] * [x] Verify ability constraints are properly enforced for enum types (positive tests)[external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/phantom_params/constraints_abilities_ok.mvir] * [x] Make sure field abilities (or lack thereof) are properly computed and enforced [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/phantom_params/fields_abilities_bad.mvir] * [x] Make sure field abilities (or lack thereof) are properly computed and enforced (positive tests)[external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/phantom_params/fields_abilities_ok.mvir] * [x] Check for illegal phantom type parameter usage on enums [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/phantom_params/struct_definition_bad.mvir] * [x] Check for legal phantom type parameter usage on enums [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/phantom_params/struct_definition_ok.mvir] * [x] Check for invalid instantiations of a ref enum type in function parameters [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/ref_type_param.mvir] * [x] Check for invalid (and exploitable) usage patterns around references of enums [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/ref_type_param_exploits.mvir] * [x] Pack a monomorphic enum with the wrong (non-primitive) type [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/resource_instantiate_bad_type.mvir] * [x] Return type mismatch with enum type and unused non-drop enum (sequencing of these checks) [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/return_type_mismatch_and_unused_resource.mvir] * [x] Verify that generic enums instantiated with other (non-copy/drop) enums behave as expected [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/struct_kind_inference.mvir] * [x] Verify that a non-copy/drop enum can be unpacked, and its contents returned from a function successfully [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/unpack_resource.mvir] * [x] Verify that unpacking with a different type, but same variant name/tag/layout will result in a type error [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/unpack_wrong_type.mvir] * [x] Verify that we can create droppable enums, and that they can be dropped [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/unrestricted_instantiate.mvir] * [x] Try to pack a monomorphic enum with an invalid field type [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/unrestricted_instantiate_bad_type.mvir] * [x] Fail to do anything with a non-drop enum type [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/unused_resource_holder.mvir] * [x] Ensure that type parameter constraints are properly computed and reported for function type parameters without the proper abilities even though they are inside a native container (vector) [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/type_safety/vector_type_param.mvir] - [x] Fail to handle an undroppable value within a variant switch [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/control_flow/variant_switch.mvir] - [x] Try to use an unassigned value within a variant switch arm [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/control_flow/variant_switch.mvir] - [x] Fail to unpack an undroppable enum within a variant switch [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/control_flow/variant_switch_successor.mvir] - [x] Make sure we properly construct the control flow graph for a variant switch as an unconditional branch [external-crates/move/crates/bytecode-verifier-transactional-tests/tests/control_flow/variant_switch_unconditional_branch.mvir] - [x] Added low-level tests to make sure we properly construct the control flow graph [external-crates/move/crates/move-binary-format/src/unit_tests/control_flow_graph_tests.rs] and in [external-crates/move/crates/move-ir-compiler/src/unit_tests/cfg_tests.rs] - [x] Added test to make sure successors are always sorted/stable, and that the control-flow graph generated is the same regardless of the order of the jumps within a variant switch [external-crates/move/crates/move-binary-format/src/unit_tests/control_flow_graph_tests.rs:out_of_order_blocks_variant_switch] ## VM * [x] Test trying to unpack the wrong variant (generic, non-generic) * [x] Test that execution proceeds normally, and that we get expected results for computations that use enums * [x] Test that mutable references taken from an enum variant can be modified, and that these modifications are reflected correctly * [x] Test that we can mutate the variant inside of an enum type. - [x] Added tests to make sure we can't infinitie loop within a variant switch [external-crates/move/crates/move-vm-transactional-tests/tests/enums/variant_switch_loop.mvir] ## Values * [x] Test that enum `Option` is backwards compatible with vector `Option`.
tzakian
requested review from
amnn,
wlmyng,
stefan-mysten,
emmazzz,
suiwombat,
mystenmark and
joyqvq
as code owners
May 24, 2024 17:46
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This adds the enums implementation for Move. This PR only contains the changes for enums within
external-crates/move
and nowhere else. This PR does not contain any tests. The tests for these changes can be found in the PR above in the stack.Note that individual commits are cut out within this PR to (hopefully) make the review process a bit easier.
Stack:
Test plan
Tested in the PR above this.
Release notes
Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.
For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.