Comparison of struct with Nullable member

TC via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jul 17 05:18:55 PDT 2015


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


More information about the Digitalmars-d-learn mailing list