You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a Weapon class with a method isMassDestruction() that returns false by default. The subclass NuclearBomb overrides this method to return true.
During a refactor, the method isMassDestruction() was renamed to isDestructive() in the Weapon class.
We updated the method in NuclearBomb, but we missed the override_on_non_overriding_member warning, as it was just one of 3,737 warnings and 1777 hints. (we have lots of auto generated code)
The method in NuclearBomb wasn’t updated to the new name, and, there were not analyzer error, the bug reached production, it caused a critical bug, leading to a nuclear bomb explosion in the app.
classWeapon {
boolisDestructive() {
returnfalse;
}
}
classNuclearBombextendsWeapon {
@overrideboolisMassDestruction() {
returntrue; // This is the old method name, which wasn't updated
}
}
Discussion
One may argue that the developer should do the shore of cleaning up warnings and info. And Yes, there is already a way to turn the linter rule into an error with following:
However, having override_on_non_overriding_member flag raised, wether it be an error, warning or info in almost all case suggest a bug. Therefore, I believe it should be turned into a keyword. And prevent the application from compiling if the rule is raised. (much like how @required once was not a keyword)
Many programming language already behave as per the proposal.
The text was updated successfully, but these errors were encountered:
tolotrasamuel
changed the title
[Proposal] Make override a keyword
[Proposal] Make @override a keyword
Mar 25, 2025
Motivation:
Here’s the scenario:
Weapon
class with a methodisMassDestruction()
that returnsfalse
by default. The subclassNuclearBomb
overrides this method to returntrue
.isMassDestruction()
was renamed toisDestructive()
in theWeapon
class.NuclearBomb
, but we missed theoverride_on_non_overriding_member
warning, as it was just one of 3,737 warnings and 1777 hints. (we have lots of auto generated code)NuclearBomb
wasn’t updated to the new name, and, there were not analyzer error, the bug reached production, it caused a critical bug, leading to a nuclear bomb explosion in the app.Here's the code:
After the refactor, the code became:
Discussion
One may argue that the developer should do the shore of cleaning up warnings and info. And Yes, there is already a way to turn the linter rule into an error with following:
However, having
override_on_non_overriding_member
flag raised, wether it be an error, warning or info in almost all case suggest a bug. Therefore, I believe it should be turned into a keyword. And prevent the application from compiling if the rule is raised. (much like how@required
once was not a keyword)Many programming language already behave as per the proposal.
The text was updated successfully, but these errors were encountered: