D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 21246 - Compiler must show mismatching types when functions do not properly override
Summary: Compiler must show mismatching types when functions do not properly override
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2020-09-14 05:18 UTC by Andrej Mitrovic
Modified: 2020-09-15 04:42 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Andrej Mitrovic 2020-09-14 05:18:44 UTC
foo.d:

-----
module foo;

import std.datetime : Clock;

class B
{
    void set (Clock clock) { }
}
-----

test.d:

-----
import foo;

class Clock { }
class C : B
{
    override void set (Clock clock) { }
}

void main () { }
-----

$ dmd test.d
> test.d(6,19): Error: function `void test.C.set(Clock clock)` does not override any function, did you mean to override `void foo.B.set(Clock clock)`?

This diagnostic is infuriating. You could easily spend the better part of an hour trying to diagnose what's wrong - the actual issue is that `Clock` refers to two completely different symbols. 

But the compiler is not helpful - it keeps recommending to override the method without giving a hint to what is wrong.
Comment 1 Dlang Bot 2020-09-15 03:58:46 UTC
@RazvanN7 created dlang/dmd pull request #11734 "Fix Issue 21246 - Compiler must show mismatching types when functions do not properly override" fixing this issue:

- Fix Issue 21246 - Compiler must show mismatching types when functions do not properly override

https://github.com/dlang/dmd/pull/11734
Comment 2 Dlang Bot 2020-09-15 04:42:52 UTC
dlang/dmd pull request #11734 "Fix Issue 21246 - Compiler must show mismatching types when functions do not properly override" was merged into master:

- 55d249f513b91aab05a3e634558479233485795d by RazvanN7:
  Fix Issue 21246 - Compiler must show mismatching types when functions do not properly override

https://github.com/dlang/dmd/pull/11734