[Issue 23552] New: Function `x` does not override any function, but it actually does
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Dec 13 12:26:11 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=23552
Issue ID: 23552
Summary: Function `x` does not override any function, but it
actually does
Product: D
Version: D2
Hardware: x86_64
OS: Windows
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: grimmaple95 at gmail.com
Consider code below:
```
import std;
abstract class Base
{
void foo();
}
class Derived : Base
{
void foo() { writeln("foo"); }
int data() { return 0; }
}
class DerivedX : Derived
{
override int data() { return 1; }
}
```
The main issue with this code is missing `override` for `Derived`'s `foo`
function. However, this code produces two errors:
```
onlineapp.d(10): Error: cannot implicitly override base class method
`onlineapp.Base.foo` with `onlineapp.Derived.foo`; add `override` attribute
onlineapp.d(23): Error: function `onlineapp.DerivedX.data` does not override
any function
```
The first error is entirely coorect. But the other one is completely wrong. If
`override` is added, then the second error is gone too.
--
More information about the Digitalmars-d-bugs
mailing list