Thread overview
Deprecation message when assigning Nullable values to an associative array.
Apr 03, 2021
Peter Jacobs
Apr 03, 2021
rikki cattermole
Apr 03, 2021
rikki cattermole
Apr 03, 2021
Peter Jacobs
April 03, 2021
I am using the OpenMPI binding and, in recent times, I have been getting a deprecation message when compiling.  It seems to be related to assigning Nullable!int entries to an associative array.  The following program shows the same message three times but it does run as I expect.


import std.stdio, std.typecons;

void main(string[] args)
{
    Nullable!(int)[string] my_entries;
    // First way.
    my_entries["A"] = Nullable!int.init;
    // Second way.
    Nullable!(int) empty;
    my_entries["B"] = empty;
    // Third way.
    my_entries["C"] = 0.nullable;
    my_entries["C"].nullify();
    writeln("my_entries=", my_entries);

    Nullable!(int) b = Nullable!int.init;
    writeln("b=", b);
    Nullable!(int) c = 0.nullable;
    writeln("c=", c);
}



peterj@helmholtz ~/work/play/dlang $ dmd null_test.d
null_test.d(7): Deprecation: function `std.typecons.Nullable!int.Nullable.get_` is deprecated - Implicit conversion with `alias Nullable.get this` will be removed after 2.096. Please use `.get` explicitly.
null_test.d(10): Deprecation: function `std.typecons.Nullable!int.Nullable.get_` is deprecated - Implicit conversion with `alias Nullable.get this` will be removed after 2.096. Please use `.get` explicitly.
null_test.d(12): Deprecation: function `std.typecons.Nullable!int.Nullable.get_` is deprecated - Implicit conversion with `alias Nullable.get this` will be removed after 2.096. Please use `.get` explicitly.
peterj@helmholtz ~/work/play/dlang $ ./null_test
my_entries=["A":Nullable.null, "C":Nullable.null, "B":Nullable.null]
b=Nullable.null
c=0


Can someone please tell me how I should set these associative array entries such that I keep the compiler happy?

April 03, 2021
Nullable has an alias this which has been deprecated.

It is due for removal (the alias this).

You can remove it manually from your copy of phobos source.

Otherwise you'll just have to wait until it is removed upstream. (deprecation are not errors, so you can ignore them).
April 03, 2021
On 03/04/2021 10:58 PM, rikki cattermole wrote:
> Nullable has an alias this which has been deprecated.
> 
> It is due for removal (the alias this).
> 
> You can remove it manually from your copy of phobos source.
> 
> Otherwise you'll just have to wait until it is removed upstream. (deprecation are not errors, so you can ignore them).

So yeah, next release.

https://github.com/dlang/phobos/commit/36c309fc5fb5bc886e14bd8010e1375fa3a57d53#diff-81bed7f05cbd4e992067b7019125e6a1349ebe5098c6980b64bbbca8d5491e17
April 03, 2021
On Saturday, 3 April 2021 at 10:03:09 UTC, rikki cattermole wrote:
>
> On 03/04/2021 10:58 PM, rikki cattermole wrote:
>> Nullable has an alias this which has been deprecated.
>> 
>> It is due for removal (the alias this).
>> 
>> You can remove it manually from your copy of phobos source.
>> 
>> Otherwise you'll just have to wait until it is removed upstream. (deprecation are not errors, so you can ignore them).
>
> So yeah, next release.
>
> https://github.com/dlang/phobos/commit/36c309fc5fb5bc886e14bd8010e1375fa3a57d53#diff-81bed7f05cbd4e992067b7019125e6a1349ebe5098c6980b64bbbca8d5491e17

Thank you.  I am happy with this situation.

PJ