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

Check for initializer errors #1095

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ericglau
Copy link
Member

@ericglau ericglau commented Oct 25, 2024

Draft PR to detect issues in parent initializer calls.

This infers functions as initializers if they have a modifier that is initializer, reinitializer, or onlyInitializing, or the function itself is named as initialize, initializer, reinitialize, or reinitializer.

This reports an error if any parent contract has an inferred initializer and any of the following are true for the (child) contract being validated:

  1. Missing initializer: This contract does not appear to have an initializer.
  2. Missing initializer call: This contract's initializer is missing a call to a parent initializer.
  3. Duplicate initializer call: This contract has duplicate calls to the same parent initializer function.
  4. Incorrect initializer order: This contract does not call parent initializers in the correct order.

Limitations:

  • This does not recursively check the initializer function, where its called functions may have calls to the parent initializer. This could result in a false positive, but users could workaround this by using unsafe-allow missing-initializer-call

Remaining:

  • Fix tests to avoid initializer errors in unrelated test cases.
  • Add a way to ignore all initializer errors from options
  • Documentation
  • Improve error messages to include more context, such as what was the expected linearization order and what was found instead, or what the duplicate call was
  • Improve error messages to have more detailed suggestions for user action.
  • Update changelog and bump version

Fixes #160

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.

Detect issues in parent initializer calls
1 participant