[Issue 21780] alias this preferred over immutable conversion even if alias this is deprecated and de is on

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Mar 29 14:09:03 UTC 2021


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

--- Comment #4 from moonlightsentinel at disroot.org ---
(In reply to FeepingCreature from comment #2)
> That's not really a "regression" - well, it is a regression, but it's an

This is still a regression. DMD should prefer const-conversions over implicit
conversions (e.g. alias this).

This extends example exhibits wrong behaviour since 2.061 :
(Unless i misunderstood the rules for overload matching)

extern(C) void puts(const scope char*);

immutable struct S { }

struct Nullable {
    S get_() { return S.init; }
    deprecated alias get_ this;
}

void foo(immutable Nullable) { puts("Nullable"); }
void foo(immutable S) { puts("S"); }

void main() {
    foo(Nullable()); // prints "S"
}

--


More information about the Digitalmars-d-bugs mailing list