Bug 11061 – std.variant.Variant equality comparison always returns false for static array literals.

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-09-17T22:35:14Z
Last change time
2019-06-10T02:47:25Z
Keywords
pull
Assigned to
No Owner
Creator
Kapps

Comments

Comment #0 by opantm2+dbugs — 2013-09-17T22:35:14Z
Attempting to compare a Variant containing a static array to an array literal will always return false. The same code using a dynamic array instead of a static array works. Presumably it's checking the pointer instead of the contents. Example: import std.variant; void main() { int[4] el = [0, 1, 2, 3]; Variant v1 = el; assert(v1 == el); // passes assert(v1 == [0, 1, 2, 3]); // fails }
Comment #1 by opantm2+dbugs — 2014-05-20T06:15:37Z
The actual problem here is that v1 == [0, 1, 2, 3] isn't a check against a static array, but rather a check against a dynamic array. I don't think there's a solution besides making it so arrays in Variant can be compared to other arrays/Variants regardless of whether they're static or dynamic arrays.
Comment #2 by dlang-bot — 2019-06-06T08:59:55Z
@Zevenberge updated dlang/phobos pull request #7061 "Variant of an array can be compared with another array" fixing this issue: - fix Issue 11061 - Variant of an array can be compared with another array Fixes 11061 https://github.com/dlang/phobos/pull/7061
Comment #3 by dlang-bot — 2019-06-10T02:47:25Z
dlang/phobos pull request #7061 "Variant of an array can be compared with another array" was merged into master: - 613c0b1f725b7e19295bca0bac9122cc311413de by Marco de Wild: fix Issue 11061 - Variant of an array can be compared with another array Fixes 11061 https://github.com/dlang/phobos/pull/7061