mirror of
https://github.com/dlang/phobos.git
synced 2025-05-01 07:30:33 +03:00
Fix 10961 - Assigning void[] to Variant causes compiler errors.
This commit is contained in:
parent
0475a1a2fd
commit
01b7536eb9
1 changed files with 13 additions and 2 deletions
|
@ -416,7 +416,8 @@ private:
|
||||||
{
|
{
|
||||||
enforce(0, "Not implemented");
|
enforce(0, "Not implemented");
|
||||||
}
|
}
|
||||||
static if (isDynamicArray!(A) && allowed!(typeof(A.init[0])))
|
// Can't handle void arrays as there isn't any result to return.
|
||||||
|
static if (isDynamicArray!(A) && !is(Unqual!(typeof(A.init[0])) == void) && allowed!(typeof(A.init[0])))
|
||||||
{
|
{
|
||||||
// array type; input and output are the same VariantN
|
// array type; input and output are the same VariantN
|
||||||
auto result = cast(VariantN*) parm;
|
auto result = cast(VariantN*) parm;
|
||||||
|
@ -460,7 +461,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
case OpID.catAssign:
|
case OpID.catAssign:
|
||||||
static if (is(typeof((*zis)[0])) && is(typeof((*zis) ~= *zis)))
|
static if (!is(Unqual!(typeof((*zis)[0])) == void) && is(typeof((*zis)[0])) && is(typeof((*zis) ~= *zis)))
|
||||||
{
|
{
|
||||||
// array type; parm is the element to append
|
// array type; parm is the element to append
|
||||||
auto arg = cast(VariantN*) parm;
|
auto arg = cast(VariantN*) parm;
|
||||||
|
@ -1121,6 +1122,16 @@ unittest
|
||||||
assert(v == S.init);
|
assert(v == S.init);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Issue #10961
|
||||||
|
unittest
|
||||||
|
{
|
||||||
|
// Primarily test that we can assign a void[] to a Variant.
|
||||||
|
void[] elements = cast(void[])[1, 2, 3];
|
||||||
|
Variant v = elements;
|
||||||
|
void[] returned = v.get!(void[]);
|
||||||
|
assert(returned == elements);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Algebraic data type restricted to a closed set of possible
|
* Algebraic data type restricted to a closed set of possible
|
||||||
* types. It's an alias for a $(D_PARAM VariantN) with an
|
* types. It's an alias for a $(D_PARAM VariantN) with an
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue