Thread overview
[Issue 21538] Overriding with more attributes on delegate parameter is allowed
Jan 10
Bolpat
Jan 10
Bolpat
Jan 27
RazvanN
Jan 27
Dlang Bot
January 10
https://issues.dlang.org/show_bug.cgi?id=21538

Bolpat <qs.il.paperinik@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid, safe

--- Comment #1 from Bolpat <qs.il.paperinik@gmail.com> ---
DMD rejected the override from version 2.066 to 2.074.1; the regression affects DMD since 2.075.1.

Just to prove that the cast and the actual delegate isn't the issue, the following compiles, too:

    auto dg = delegate() @system { int* p; int x; p = &x; }; // unsafe actions
    I i = new C;
    i.f(dg); // okay, unexpeced

It works with function pointers, too:

    auto fp = () @system { int* p; int x; p = &x; };
    i.g(fp);

--
January 10
https://issues.dlang.org/show_bug.cgi?id=21538

Bolpat <qs.il.paperinik@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |qs.il.paperinik@gmail.com

--
January 27
https://issues.dlang.org/show_bug.cgi?id=21538

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |razvan.nitu1305@gmail.com

--- Comment #2 from RazvanN <razvan.nitu1305@gmail.com> ---
>From spec [1]: "A function in a derived class with the same name and covariant
with a function in a base class overrides that function". Also, [2] (point 8) defines covariance: "A covariant function has a type that is implicitly convertible to the type of the overridden function.". Finally, [3] (point 6) shows that @safe functions are covariant with @system functions.

PR that explicitly introduced this: https://github.com/dlang/dmd/pull/6731 .

I think that this case was simply overlooked. Functions that implement interface functions should match exactly.

[1] https://dlang.org/spec/function.html#function-inheritance [2] https://dlang.org/spec/function.html#virtual-functions [3] https://dlang.org/spec/function.html#safe-functions

--
January 27
https://issues.dlang.org/show_bug.cgi?id=21538

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #3 from Dlang Bot <dlang-bot@dlang.rocks> ---
@RazvanN7 created dlang/dmd pull request #12160 "Fix Issue 21538 - Overriding with more attributes on delegate parameter is allowed" fixing this issue:

- Fix Issue 21538 - Overriding with more attributes on delegate parameter is allowed

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

--