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

Document init(struct) safety pattern #1511

Open
anton-trunov opened this issue Jan 23, 2025 · 3 comments
Open

Document init(struct) safety pattern #1511

anton-trunov opened this issue Jan 23, 2025 · 3 comments
Assignees
Labels
kind: docs Documentation for docs.tact-lang.org kept in docs folder
Milestone

Comments

@anton-trunov
Copy link
Member

init does not allow as annotations for its parameters, but sometimes it is really useful and apparently would have saved some debugging time for @Shvandre.

Here is an example of the pattern:
#1023 (comment)

@anton-trunov anton-trunov added the kind: docs Documentation for docs.tact-lang.org kept in docs folder label Jan 23, 2025
@anton-trunov anton-trunov added this to the Doc: 2025-02 milestone Jan 23, 2025
@novusnota novusnota modified the milestones: Doc: 2025-02, Doc: 2025-01 Jan 24, 2025
@anton-trunov
Copy link
Member Author

Depends on #1590

@novusnota
Copy link
Member

Depends on #1590

Well, the simple workaround is to name the only parameter as params or args. The following snippet works:

import "@stdlib/deploy";

struct Init { foo: Int as uint8 }

contract Quux with Deployable {
    init(args: Init) {
        // ...doing something with args.foo
    }
}

@anton-trunov
Copy link
Member Author

Yeah, it's a workaround for a workaround

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: docs Documentation for docs.tact-lang.org kept in docs folder
Projects
None yet
Development

No branches or pull requests

2 participants