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

feat: no lazy init (contract parameters) #1985

Merged
merged 10 commits into from
Feb 26, 2025
Merged

feat: no lazy init (contract parameters) #1985

merged 10 commits into from
Feb 26, 2025

Conversation

verytactical
Copy link
Contributor

Issue

Closes #1756.

Checklist

  • I have updated CHANGELOG.md
  • I have run all the tests locally and no test failure was reported
  • I have run the linter, formatter and spellchecker
  • I did not do unrelated and/or undiscussed refactorings

Shvandre
Shvandre previously approved these changes Feb 26, 2025
Copy link
Contributor

@Shvandre Shvandre left a comment

Choose a reason for hiding this comment

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

We discussed this changes with @verytactical and agreed on adding more comments here, especially for field names, such as separate, contract and some others.

Also now new constructor requires to add fake ASTNode of init() function, but this cannot be bypassed easily, so it will stay as is.

Besides new constructor lacks the possibility to make some arguments optional, but we decided not to implement that in this PR not to overcomplicate it.

@verytactical verytactical marked this pull request as ready for review February 26, 2025 12:57
@verytactical verytactical requested a review from a team as a code owner February 26, 2025 12:57
@anton-trunov anton-trunov added this to the v1.6.0 milestone Feb 26, 2025
@anton-trunov anton-trunov self-assigned this Feb 26, 2025
@novusnota novusnota self-requested a review February 26, 2025 13:22
);
} else {
throwCompilationError(
"Cannot define init() on a contract that has contract initializer",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

contract parameters

@@ -365,6 +365,24 @@ exports[`resolveDescriptors should fail descriptors for getter-outside-contract
"
`;

exports[`resolveDescriptors should fail descriptors for init-on-contract-no-fields 1`] = `
"<unknown>:6:5: All fields must be defined in contract initializer if it exists
Copy link
Contributor Author

Choose a reason for hiding this comment

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

as contract parameters

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cannot use contract fields along with contract parameters

`;

exports[`resolveDescriptors should fail descriptors for init-on-contract-no-init 1`] = `
"<unknown>:6:5: Initialization was already defined on contract Contract
Copy link
Contributor Author

Choose a reason for hiding this comment

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

init() cannot be used along with contract parameters

@anton-trunov anton-trunov merged commit 594db25 into main Feb 26, 2025
24 checks passed
@anton-trunov anton-trunov deleted the contract-init branch February 26, 2025 15:25
@anton-trunov anton-trunov changed the title feat: no lazy init feat: no lazy init (contract parameters) Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introduce contract parameters to resolve unnecessary lazy contract initialization
4 participants