forked from MystenLabs/sui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[move 2024][alpha] Method syntax (MystenLabs#13933)
## Description See 'Release Notes' for feature description. This PR: - Resurrects original method style syntax - Adds a `defines_primitive` annotation so that method style syntax can be used with primitive/builtin types - Adds use fun declarations Some notes about implementation details - A normal use alias, `use a::m::f as g` introduces an implicit `use fun a::m::f as a::m::S.g` in situations where the first argument of `a::m::f` is `a::m::S`. This ensures that there isn't any weird precedence/shadowing between `use` and `use fun` in a given scope. - There are some nuances here, but the rules are ensuring that once you have a module that calls `x.foo()`, it always resolves to the same function `a::m::bar`, even if new `public use fun`s are added elsewhere. - I had to move `ProgramInfo` into the `naming::ast::program` and `typing::ast::program` to properly resolve `use funs` (particularly with this implicit setup described above) Follow up - `let mut` and `mut` variable modifiers - I think I will rewrite alias maps in expansion to reduce clones (as I did with use fun declarations ## Test Plan - New tests --- If your changes are not user-facing and not a breaking change, you can skip the following section. Otherwise, please indicate what changed, and then add to the Release Notes section as highlighted during the release process. ### Type of Change (Check all that apply) - [ ] protocol change - [X] user-visible impact - [ ] breaking change for a client SDKs - [ ] breaking change for FNs (FN binary must upgrade) - [ ] breaking change for validators or node operators (must upgrade binaries) - [ ] breaking change for on-chain data layout - [ ] necessitate either a data wipe or data migration ### Release notes Method style syntax has been added to Move 2024.alpha. This means functions can now be invoked with the syntax, `e.foo(arg1, arg2)`. Assuming `e: a::m::S` (or `&a::m::S` or `&mut a::m::S`), `e.foo(arg1, arg2)` will resolve to `a::m::foo(e, arg1, arg2)`. Additionally, the compiler will borrow `e` when necessary. For instances where the desired target function is not declared in the same module as the type (or is not declared with the desired name), a `use fun` alias can be used instead. For example, `use b::n::bar as S.baz` will allow `e.baz()` to resolve as `b::n::bar(e)`. A `public use fun` can be declared in the types defining module, allowing the alias to be used outside of the module.
- Loading branch information
Showing
132 changed files
with
4,307 additions
and
447 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
Oops, something went wrong.