Skip to content
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

Rewrite of parts of the #[public] macro #1193

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Conversation

iFrostizz
Copy link
Contributor

@iFrostizz iFrostizz commented Jul 24, 2024

Closes #1183

Copy parameters in bindings definition:
The parameter names used to be param_0, param_1, ...
The original parameter names have been copied to have better docs and LSP support.

You can verify this with cargo doc -p counter -F bindings --open

Screenshot 2024-07-24 at 13 42 06

As part of this, much of the code could be simplified further

@iFrostizz iFrostizz self-assigned this Jul 24, 2024
@iFrostizz iFrostizz changed the title Copy parameters in bindings definition Rewrite of parts of the #[public] macro Jul 24, 2024
@iFrostizz iFrostizz marked this pull request as ready for review July 24, 2024 13:51
Comment on lines +33 to +41
// pass parameter if ignored with underscore
if matches!(*pat_type.pat, Pat::Wild(_)) {
pat_type.pat = Box::new(Pat::Ident(PatIdent {
attrs: vec![],
by_ref: None,
mutability: None,
ident: Ident::new("_ctx", Span::call_site()),
subpat: None,
}))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now needed because the parameters are all user-defined. Meaning that the context that used to be param_0 as expected could also be a wildcard _ and this parameter cannot be passed around.
Now the issue is that this is going to fail if any other parameter is named _ctx such as with this function signature:

#[public]
pub fn inc(_: Context, _ctx: Context, external: Program, address: Address)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Review 👀
Development

Successfully merging this pull request may close these issues.

Bindings should copy the parameter names
1 participant