Skip to content

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
vm-lang/11414-move-view-functions-package-upgradability
Draft

feat(move): Move view functions (verifier implementation) - package upgradability#11449
lollobene wants to merge 16 commits intovm-lang/11256-move-view-functions-bytecode-verifierfrom
vm-lang/11414-move-view-functions-package-upgradability

Conversation

@lollobene
Copy link
Copy Markdown
Contributor

Description of change

View Functions metadata upgradability

Links to any relevant issues

fixes #11414

lollobene and others added 16 commits April 7, 2026 16:31
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.
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.
@iota-ci iota-ci added sc-platform Issues related to the Smart Contract Platform group. vm-language Issues related to the VM & Language Team labels May 6, 2026
@lollobene lollobene changed the title Vm lang/11414 move view functions package upgradability feat(move): Move view functions (verifier implementation) - package upgradability May 6, 2026
@lollobene lollobene self-assigned this May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sc-platform Issues related to the Smart Contract Platform group. vm-language Issues related to the VM & Language Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants