Bug 22647 – [std.variant.Variant] Cannot compare types compliant with null comparison with 'null'

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2022-01-03T23:11:50Z
Last change time
2022-01-10T15:03:22Z
Keywords
pull
Assigned to
No Owner
Creator
João Lourenço

Comments

Comment #0 by jlourenco5691 — 2022-01-03T23:11:50Z
std.variant.Variant should behave the same as the core language. Some types are comparable with null (arrays and pointers). If the Variant's current type is one of those, then comparing with null should be allowed. ``` import std; void main() { int* ptr; Variant a = ptr; // is of type int* assert(ptr == null); // true assert(a == null); // false } ```
Comment #1 by dlang-bot — 2022-01-03T23:24:12Z
@iK4tsu created dlang/phobos pull request #8350 "Fix Issue 22647 - [std.variant.Variant] Cannot compare types compliant with null comparison with 'null'" fixing this issue: - std.variant: Add Variant unittests for 'null' comparisons Fix Issue #22647 - [std.variant.Variant] Cannot compare types compliant with null comparison with 'null' Signed-off-by: João Lourenço <[email protected]> https://github.com/dlang/phobos/pull/8350
Comment #2 by dlang-bot — 2022-01-10T15:03:22Z
dlang/phobos pull request #8350 "Fix Issue 22647 - [std.variant.Variant] Cannot compare types compliant with null comparison with 'null'" was merged into master: - b901b5fb50d280c6ba4203646189e425adab411d by João Lourenço: std.variant: Add Variant unittests for 'null' comparisons Fix Issue #22647 - [std.variant.Variant] Cannot compare types compliant with null comparison with 'null' Signed-off-by: João Lourenço <[email protected]> https://github.com/dlang/phobos/pull/8350