feat(move): Move view functions (verifier implementation) - package upgradability#11449
Draft
lollobene wants to merge 16 commits intovm-lang/11256-move-view-functions-bytecode-verifierfrom
Conversation
Introduce unified handling and checks for the IOTA '#[view]' attribute across the compiler. Changes include: - Linter: consolidate view diagnostics into a single VIEW_FUNCTION code/filter, update diagnostic message and notes, and refactor the view-function visitor to only warn for public functions that satisfy view constraints. Add new tests and update snapshots to reflect the new diagnostic text and filter name. - Typing: add view_signature and view_param_ty validations during typing to enforce public visibility, non-void returns, disallow returning or taking objects by value, disallow mutable object refs, and forbid mutable TxContext params. Implement helpers (contains_object_ty, tx_context_kind) used by both typing and linter logic. - Known attributes & view attribute: minor renames/refactors and formatting updates. - Tests/docs: add true_positive_view_function test and snapshot, update several linter snapshots. Also bump copyright year in updated files and apply small refactors to unify naming and behavior.
Validate view function parameters for mutability and refine type checks. view_param_ty now receives parameter mutability and emits diagnostics for mutable-by-value or mutable-reference parameters in #[view] functions; an unreachable is added for inconsistent mutable ref cases. contains_user_defined_type_by_value and contains_paramtetric_object_ty were tightened to inspect abilities (copy/drop) and to treat vectors/funcs appropriately. Added new tests (string.move/string.snap) and updated invalid test/snapshot to cover the new diagnostics and line changes.
This reverts commit c7ac064.
Delete the view_function linter and its registration, and remove related helper functions used to validate view signatures. This removes external-crates/move/.../linters/view_function.rs, unregisters view_function in linters/mod.rs, and deletes is_valid_view_signature (and related param/return helpers) from typing.rs. Update test snapshots to drop view_function warnings and remove the view_function test files and expectations.
This reverts commit 97a301c.
This file contains hidden or 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
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 of change
View Functions metadata upgradability
Links to any relevant issues
fixes #11414