Bug 2641 – std.variant Variant's check for "can append" is wrong
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2009-02-01T20:44:00Z
Last change time
2015-06-09T01:20:59Z
Assigned to
andrei
Creator
wbaxter
Comments
Comment #0 by wbaxter — 2009-02-01T20:44:51Z
The code below used in std.variant seems to be assuming that if a type can be indexed, then it can also be appended to:
-----
case OpID.catAssign:
auto me = cast(A*) pStore;
static if (is(typeof((*me)[0])) && !is(typeof(me.keys)))
{
// array type; parm is the element to append
auto arg = cast(VariantN*) parm;
alias typeof((*me)[0]) E;
if (arg[0].convertsTo!(E))
{
// append one element to the array
(*me) ~= [ arg[0].get!(E) ];
}
else
{
// append a whole array to the array
(*me) ~= arg[0].get!(A);
}
---
This causes it to fail when trying to use a fixed-length struct, like a fixed vec3 that provides an opIndex but no opCatAssign.
Comment #1 by andrei — 2009-07-07T10:06:58Z
Fixed in future 2.032 (and checked in for the impatient).