Thread overview |
---|
June 15, 2018 comparing nullables | ||||
---|---|---|---|---|
| ||||
Hi all, do you see any valid reason why the last line yields an error: import std.typecons; void main() { void* ptr1; void* ptr2; assert(ptr1 is null); assert(ptr2 is null); assert(ptr1 == ptr2); Nullable!uint val1; Nullable!uint val2; assert(val1.isNull); assert(val2.isNull); assert(val1 == val2); Nullable!(uint, uint.max) val3; Nullable!(uint, uint.max) val4; assert(val3.isNull); assert(val4.isNull); assert(val3 == val4); } The error is core.exception.AssertError@/usr/local/opt/dmd/include/dlang/dmd/std/typecons.d(3457): Called `get' on null Nullable!(uint,nullValue). As I can see, this is due the lack of opEquals in the Nullable(T, T nullValue), in contrast to Nullable(T). |
June 15, 2018 Re: comparing nullables | ||||
---|---|---|---|---|
| ||||
Posted in reply to Alex | On Friday, 15 June 2018 at 15:00:38 UTC, Alex wrote: > Hi all, > do you see any valid reason why the last line yields an error: > > import std.typecons; > void main() > { > void* ptr1; > void* ptr2; > > assert(ptr1 is null); > assert(ptr2 is null); > assert(ptr1 == ptr2); > > Nullable!uint val1; > Nullable!uint val2; > assert(val1.isNull); > assert(val2.isNull); > assert(val1 == val2); > > Nullable!(uint, uint.max) val3; > Nullable!(uint, uint.max) val4; > assert(val3.isNull); > assert(val4.isNull); > assert(val3 == val4); > } > > The error is > core.exception.AssertError@/usr/local/opt/dmd/include/dlang/dmd/std/typecons.d(3457): Called `get' on null Nullable!(uint,nullValue). > > As I can see, this is due the lack of opEquals in the Nullable(T, T nullValue), in contrast to Nullable(T). https://github.com/dlang/phobos/pull/6583 |
June 15, 2018 Re: comparing nullables | ||||
---|---|---|---|---|
| ||||
Posted in reply to bauss | On Friday, 15 June 2018 at 16:49:47 UTC, bauss wrote:
>
> https://github.com/dlang/phobos/pull/6583
Thanks a lot.
|
Copyright © 1999-2021 by the D Language Foundation