Comparison of struct with Nullable member

anonymous via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jul 17 11:12:18 PDT 2015


On Friday, 17 July 2015 at 12:18:56 UTC, TC wrote:
> Hello,
> I came around a strange behavior and I'm not sure if it is a 
> bug or feature.
>
> import std.typecons : Nullable;
> struct Foo
> {
> 	string bar;
> 	Nullable!int baz;
> }
>
> auto a = Foo("bb");
> auto b = Foo("bb");
> assert(a == b);
>
> This ends up with: Called `get' on null Nullable!int
>
> But if I change bar to be an int for example, than it passes ok.
> I would expect this to pass ok.
>
> Tested on dmd 2.067.1 win64

Bug. I reported a reduced version as 
<https://issues.dlang.org/show_bug.cgi?id=14806>.


More information about the Digitalmars-d-learn mailing list