Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REG2.067a] Issue 13300 - pure function 'std.array.Appender!(T[]).Appender.ensureAddable' cannot call impure function 'test.T.__fieldPostBlit' #2439

Merged
merged 1 commit into from
Aug 22, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 40 additions & 4 deletions std/variant.d
Original file line number Diff line number Diff line change
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