Skip to content

Commit d07b101

Browse files
authored
Merge pull request #5541 from jmdavis/issue_17482
Fix issue 17482: Fix Nullable!Variant equality checks. merged-on-behalf-of: Sebastian Wilzbach <sebi.wilzbach@gmail.com>
2 parents bff3364 + a7ea880 commit d07b101

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

std/typecons.d

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2228,7 +2228,8 @@ Params:
22282228
}
22292229

22302230
/// Ditto
2231-
bool opEquals()(auto ref const(T) rhs) const
2231+
bool opEquals(U)(auto ref const(U) rhs) const
2232+
if (is(typeof(this.get == rhs)))
22322233
{
22332234
return _isNull ? false : rhs == _value;
22342235
}
@@ -2276,6 +2277,16 @@ Params:
22762277
assert(a != Nullable!int(29));
22772278
}
22782279

2280+
// Issue 17482
2281+
@system unittest
2282+
{
2283+
import std.variant : Variant;
2284+
Nullable!Variant a = Variant(12);
2285+
assert(a == 12);
2286+
Nullable!Variant e;
2287+
assert(e != 12);
2288+
}
2289+
22792290
template toString()
22802291
{
22812292
import std.format : FormatSpec, formatValue;

0 commit comments

Comments
 (0)