D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 20624 - [REG2.088] AA access gives wrong deprecation message.
Summary: [REG2.088] AA access gives wrong deprecation message.
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 regression
Assignee: No Owner
URL:
Keywords: industry, rejects-valid
Depends on:
Blocks:
 
Reported: 2020-03-01 19:39 UTC by johanengelen
Modified: 2021-08-22 21:19 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description johanengelen 2020-03-01 19:39:21 UTC
The following code gives a wrong deprecation message since DMD 2.088:

```
import std.typecons;

alias T = Nullable!ulong;
T normal;
T[4] array;
T[string] aa;

void g(string s, ulong value) {
    normal = value; // no problem
    array[0] = value; // no problem
    
    aa[s] = value;
    // Should directly use opAssign. Instead gives wrong deprecation message:
    // std.typecons.Nullable!ulong.Nullable.get_ is deprecated - Implicit conversion with alias Nullable.get this will be removed after 2.096. Please use .get explicitly.
    
    aa[s].opAssign(value); // workaround that works without deprecation msg
}

void main() {
    g("hoi", 1);
}
```

The deprecation message is invalid: alias this is never used (because Nullable.opAssign is directly callable). Moreover, the suggested fix (".get()") results in wrong code.
Comment 1 johanengelen 2020-07-31 14:39:36 UTC
Instead of opAssign, the better fix is `aa[s] = Nullable!ulong(value);`.
Comment 2 RazvanN 2021-08-17 16:31:09 UTC
I cannot reproduce this with latest master. Closing as WORKSFORME. @Johan please reopen if you have anything else to add.
Comment 3 johanengelen 2021-08-22 21:19:32 UTC
This started working with 2.097. As per the wrong deprecation message, probably this was automatically "fixed" by removing Implicit conversion with alias this.