[Issue 21780] New: 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 07:48:37 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=21780
Issue ID: 21780
Summary: alias this preferred over immutable conversion even if
alias this is deprecated and de is on
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: trivial
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: default_357-line at yahoo.de
Consider the following code:
immutable struct S { }
struct Nullable {
S get_() { return S.init; }
deprecated alias get_ this;
}
void foo(immutable Nullable) { }
void foo(immutable S) { }
void main() {
foo(Nullable());
}
So `Nullable()` is implicitly convertible to `immutable Nullable` without
hitting the "alias this". And yet, DMD will prefer the deprecated conversion
even if `-de` is on, erroring with
Deprecation: `alias get_ this` is deprecated
This despite the fact that removing the `alias get_ this` will allow the code
to compile.
Marked as trivial because as you can guess from the struct name, this issue
will solve itself "naturally" when 2.097 releases. :)
--
More information about the Digitalmars-d-bugs
mailing list