-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[compiler] add visibility modifier to structs/enums: step 2 #18083
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
base: main
Are you sure you want to change the base?
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
32ad45f to
dba5487
Compare
a764f00 to
927a48e
Compare
292a245 to
7c8867c
Compare
927a48e to
1682ec5
Compare
7c8867c to
3a00446
Compare
1682ec5 to
b5d8385
Compare
| ============ bytecode verification failed ======== | ||
|
|
||
| Diagnostics: | ||
| bug: bytecode verification failed with unexpected status code `CALL_BORROWED_MUTABLE_REFERENCE_ERROR`: |
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.
This kind of error will go away once we change the bytecode verifier.
6cc3c83 to
5b30bcd
Compare
e1b0417 to
dfff6fd
Compare
e524ad8 to
d15279d
Compare
dfff6fd to
1e893c8
Compare
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.
This PR is being reviewed by Cursor Bugbot
Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
third_party/move/move-compiler-v2/src/file_format_generator/function_generator.rs
Show resolved
Hide resolved
third_party/move/move-compiler-v2/src/file_format_generator/function_generator.rs
Show resolved
Hide resolved
2542c22 to
60805ed
Compare
60805ed to
e7724b0
Compare
6eb2d64 to
e1a1542
Compare
| FF::Bytecode::Pack, | ||
| FF::Bytecode::PackGeneric, | ||
| ); | ||
| } |
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.
Bug: Pack: Unchecked Language Version Causes Errors
The Pack operation handler is missing a language version check. Unlike PackVariant (line 863), Unpack (line 914), and UnpackVariant (line 959), the regular Pack operation does not verify that language_version_for_public_struct() is enabled before attempting to use the pack API. This causes the code to attempt accessing pack APIs that were never generated when the language feature is disabled, leading to incorrect behavior or internal errors.
e1a1542 to
effba77
Compare
effba77 to
c550c6e
Compare
Description
This PR adds the code generation of public APIs for structs and enums to file format generator.
For structs and enums the following apis are generated:
pack$address$module$struct[$variant](_field_name: _field_type, ...): struct_typeunpack$address$module$struct[$variant](_s: struct_type): (field_type, ...)borrow[_mut]$address$module$struct$field$offset[$variant](_s: &[mut] struct_type): &[mut] field_typeFor enums, test variant api is generated:
test_variant$address$module$enum$variant(_s: &enum_type): boolFor a struct with
nfields, the number of generated functions is 2 + 2 * n;For an enum with
mvariants and each variant hasnfields and all fields have separated borrow field functions, the number of generated functions is 3*m + 2 * m * n.Note that attributes will be added in sub sequent PRs.
How Has This Been Tested?
New unit tests, transactional tests and e2e move test cases are added. Note that some cases are generating bytecode verification error due to limitation of current borrow semantics for functions. This will be resolved in subsequent PRs.
Key Areas to Review
Type of Change
Which Components or Systems Does This Change Impact?
Checklist
Note
Generate pack/unpack/borrow/test-variant APIs for public/package structs/enums and auto-wrap cross-module operations to these APIs; add supporting indices, source-map wiring, model updates, and extensive tests/config.
pack$…,unpack$…,borrow$…/borrow_mut$…, andtest_variant$…functions (incl. variants and generics).Pack/Unpack/TestVariant/BorrowFieldops to the generated API calls (with instantiation helpers and FreezeRef as needed).is_empty_struct; include visibility handling and allow attaching functions created by API generation when loading bytecode.public_structs_enums_upgrade.structs_visibility/*).public-structconfig and exclude new suite from other configs; adjust separate baselines.Written by Cursor Bugbot for commit c550c6e. This will update automatically on new commits. Configure here.