[Issue 21246] New: Compiler must show mismatching types when functions do not properly override

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Sep 14 05:18:44 UTC 2020


https://issues.dlang.org/show_bug.cgi?id=21246

          Issue ID: 21246
           Summary: Compiler must show mismatching types when functions do
                    not properly override
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: andrej.mitrovich at gmail.com

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.

--


More information about the Digitalmars-d-bugs mailing list