Skip to content

Commit

Permalink
fix Issue 13300 - pure function 'std.array.Appender!(T[]).Appender.en…
Browse files Browse the repository at this point in the history
…sureAddable' cannot call impure function 'test.T.__fieldPostBlit'
  • Loading branch information
9rnsr committed Aug 19, 2014
1 parent fcdc0d3 commit 1baf12b
Showing 1 changed file with 40 additions and 4 deletions.
44 changes: 40 additions & 4 deletions std/variant.d
Expand Up @@ -585,14 +585,20 @@ public:
opAssign(value);
}

this(this)
static if (!AllowedTypes.length || anySatisfy!(hasElaborateCopyConstructor, AllowedTypes))
{
fptr(OpID.postblit, &store, null);
this(this)
{
fptr(OpID.postblit, &store, null);
}
}

~this()
static if (!AllowedTypes.length || anySatisfy!(hasElaborateDestructor, AllowedTypes))
{
fptr(OpID.destruct, &store, null);
~this()
{
fptr(OpID.destruct, &store, null);
}
}

/** Assigns a $(D_PARAM VariantN) from a generic
Expand Down Expand Up @@ -2425,6 +2431,36 @@ unittest
assert(S.cnt == 0);
}

unittest
{
// Bugzilla 13300
static struct S
{
this(this) {}
~this() {}
}

static assert( hasElaborateCopyConstructor!(Variant));
static assert(!hasElaborateCopyConstructor!(Algebraic!bool));
static assert( hasElaborateCopyConstructor!(Algebraic!S));
static assert( hasElaborateCopyConstructor!(Algebraic!(bool, S)));

static assert( hasElaborateDestructor!(Variant));
static assert(!hasElaborateDestructor!(Algebraic!bool));
static assert( hasElaborateDestructor!(Algebraic!S));
static assert( hasElaborateDestructor!(Algebraic!(bool, S)));

import std.array;
alias Algebraic!bool Value;

static struct T
{
Value value;
@disable this();
}
auto a = appender!(T[]);
}

unittest
{
// Make sure Variant can handle types with opDispatch but no length field.
Expand Down

0 comments on commit 1baf12b

Please sign in to comment.