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

Support unsafe-allow-reachable in constructors #715

Open
ericglau opened this issue Jan 18, 2023 · 0 comments
Open

Support unsafe-allow-reachable in constructors #715

ericglau opened this issue Jan 18, 2023 · 0 comments

Comments

@ericglau
Copy link
Member

ericglau commented Jan 18, 2023

Related to #702

If a constructor calls a parent constructor with a modifier-like syntax like the below, @custom:oz-upgrades-unsafe-allow-reachable has no effect if that is defined on the constructor:

abstract contract Parent {
    /// @custom:oz-upgrades-unsafe-allow constructor
    constructor() {
        msg.sender.delegatecall('');
    }
}

/// @custom:oz-upgrades-unsafe-allow constructor
contract Child is Parent {
    /// @custom:oz-upgrades-unsafe-allow-reachable delegatecall
    constructor() Parent() {}
}

This is because we are not dereferencing this constructor call, but are always reporting errors in inherited contract constructors. Note that the constructor call is actually a ModifierInvocation that references the parent contract itself, not the parent constructor.

The workaround for users is to define @custom:oz-upgrades-unsafe-allow-reachable at the contract level instead.

@ericglau ericglau changed the title Support @custom:oz-upgrades-unsafe-allow-reachable in constructors Support unsafe-allow-reachable in constructors Jan 18, 2023
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

No branches or pull requests

1 participant