-
Notifications
You must be signed in to change notification settings - Fork 11.3k
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
[move-compiler][sui-mode] Add entry function signature checks #12990
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
6 Ignored Deployments
|
fn tx_context_kind(sp!(_, last_param_ty_): &Type) -> TxContextKind { | ||
let (is_mut, inner_ty) = match last_param_ty_ { | ||
Type_::Ref(is_mut, inner_ty) => (*is_mut, &inner_ty.value), | ||
_ => return TxContextKind::None, |
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.
At this point do we already detect and error on a TxContext
by value?
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.
Ah, yeah it could be an interesting warning/error?
But nothing needed at the bytecode level, so this is sort of new for source language.
let inner_name = match inner_ty { | ||
Type_::Apply(_, sp!(_, n_), _) => n_, | ||
_ => return TxContextKind::None, | ||
}; |
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.
let
... else
?
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.
In fact, would it be crazy to do this all in one let ... else
?
let (is_mut, Type_::Apply(_, sp!(_, n_), _) = last_param_ty_ else {
return TxContextKind::None
}
(Also, what's with the trailing underscores?)
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.
A naming pattern I use around the compiler for Spanned<T>
items, where I will normally do n @ sp!(loc, n_)
. Which (for better or for worse) is a pattern I've held onto from OCaml
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.
And I cannot do 1 let-else
because of the Box
💢
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.
As I said it, I knew this was why, I just hoped I was wrong...
} | ||
} | ||
|
||
fn entry_return( |
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.
Can we document or link to the documentation for what we expect from a valid entry return type? (TIL we can return drop
-able types from an entry functions).
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.
I can do it as a separate PR, sure!
- Ported entry function signature checks to the compiler guarded by sui-mode
Description
Test Plan
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)
Release notes
The Sui Move toolchain will now provide diagnostics (in the form of errors) for incorrect
entry
function signatures at the source language level.