-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
Allow private visibility for modifier keyword #3454
Comments
Can you explain "Handle visibility inheritance the way inheritance is supposed to be handled (see test cases), not the way Solidity currently handles visibility inheritance" in a bit more detail, please? There is also the option to disallow overriding for modifiers in general, which would probably be a good idea. Currently, modifiers are virtual, but I'm not sure if people actually use that. If you really need that, you can always call a virtual function inside the modifier. |
Regarding visibility inheritance -- currently you cannot override functions with a function of different visibility (can't find issue), but in the future Solidity will allow greater than / equal visibility in subclasses. These test cases demonstrate the LATTER, which is inconsistent with how functions currently work, FORMER. Woah, right now modifiers are dynamic dispatch? Wow, TIL B.x and B.y both return pragma solidity ^0.4.19;
contract A {
modifier m {
require(true);
_;
}
function x() m pure external {
}
}
contract B is A {
modifier m {
require(false);
_;
}
function y() m pure external {
}
} Ok, well if modifiers are virtual then I would expect this to work but it doesn't. pragma solidity ^0.4.19;
contract A {
modifier m;
} Wow, TIL, private functions can also be overridden with virtual dispatch. Ok, well today I learned a lot more about how Solidity actually works. If you read the documentation before writing code you might think the language is messed up (read documentation on contract function inheritance versus the above). But if you just start writing code and seeing how it works then it makes sense how things work. In that case, here is the way that interfaces can be fixed to be more Solidity-like as per the way that Solidity actually works:
|
Closing. Do not have a concrete need. 0.6.0 has virtual and override. |
In this example, contract
A
uses a modifiermod
for its own purposes (that you can't see here today).Contract
A
would like to avoid exporting this modifier for inherited contracts. But unfortunately,B
's environment has become polluted by this unwanted side effect.Work plan
modifier
to have visibility specified asinternal
orprivate
, other visibilities shall be an errormodifier
's visibility is implicitlyinternal
modifier
documentationTest suite
The text was updated successfully, but these errors were encountered: