Skip to content

feat(move): Move view functions (verifier implementation)#11359

Draft
lollobene wants to merge 2 commits intovm-lang/6548-move-view-functionsfrom
vm-lang/11256-move-view-functions-bytecode-verifier
Draft

feat(move): Move view functions (verifier implementation)#11359
lollobene wants to merge 2 commits intovm-lang/6548-move-view-functionsfrom
vm-lang/11256-move-view-functions-bytecode-verifier

Conversation

@lollobene
Copy link
Copy Markdown
Contributor

Description of change

IOTA verifier implementation for view functions

Links to any relevant issues

fixes #11256

@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 Apr 28, 2026
Refactoring

Disallow mutable params in view funcs

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.

View parameter refined

Add '#[view]' lint and signature/type checks

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.

Assignment implementation
@lollobene lollobene force-pushed the vm-lang/11256-move-view-functions-bytecode-verifier branch from 06c4c99 to 969656f Compare April 28, 2026 13:43
@lollobene lollobene changed the title feat(move): Move view functions (compiler implementation) feat(move): Move view functions (verifier implementation) Apr 28, 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.

[execution] Implement the move view function checks for the iota-verifier

2 participants