Deprecation message when assigning Nullable values to an associative array.

Peter Jacobs peterj at mech.uq.edu.au
Sat Apr 3 09:49:32 UTC 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 at 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 at 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?



More information about the Digitalmars-d-learn mailing list