-
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
Require 'override' and 'virtual' keyword #5424
Comments
draft of specification:
|
How to handle combinations of overloading and overriding? |
I tend to make functions that are marked |
And I think it makes sense to introduce the keywords themselves in 0.6.0, but to only deprecate omitting them. So in 0.6.0 omitting the keywords would cause warnings, unless you specify e.g. |
Will this info (e.g. a function being |
What do you exactly mean by that? |
I guess the most appropriate location for such a thing would be the JSON AST (which is included in the |
To recap my understanding of the goals:
I would argue that users want to do the |
I'd say the overriding function function signature must match the signature exactly, that should include any overloads, too. |
Yes, I think this is how it is handled currently. |
About the default: I'm actually not sure if virtual is really that common. In any case, if we do not default to non-virtual, this feature is useless. |
Well, yes, my suggestion was to basically use |
Discussion resulted in relaxation of the requirements for the case of a function being inherited from multiple base classes:
|
In addition to that: It is illegal, if a function that is not declared in a contract would have multiple base functions. |
I'm still not entirely sure about this case and fine with both options, but I wanted to bring it up once more:
Should this be valid or not? We said ǹot having There's two cases: either Explicit allowing would mean you need to write Explicit disallowing would mean you need to write @chriseth Your specification would mean defaulting to allowing. Do we want to do it that way? I'm fine with it, just reconfirming. |
I was just looking over the draft PR(s) for implementing this - and I'm realizing: requiring to redeclare functions of the base "virtual" again to allow them to be overridden would make the implementation much simpler, since we'd only need to check one level at a time :-). And by the same logic I could imagine that this would make auditing code easier, so I'm actually still leaning towards that option... |
Can you ask the list? |
One option that will get us around discussing which should be the default is to allow both, i.e. to have "virtual" and "final" inheritance, but I'm not sure, if we should seriously consider that :-). |
if |
How would this work in the case of an overloaded functions? Is this portion of the spec still being considered? |
@ericDeCourcy currently, overloading and overriding are considered to be unrelated. We might want to restrict this, but probably not for 0.6.0. |
Our current specification has one hole:
|
Which we could solve be allowing |
Sounds good! I would not allow anything like |
for reference, the current PR for |
Do we want this for 0.6.0 as well? |
Maybe better to introduce calldata variables for public functions? |
Related to #2563
Steps:
override
for public state variables, but they can't bevirtual
Public State Variable Overriding #7839override
Implement override keyword #7563virtual
The text was updated successfully, but these errors were encountered: