[Issue 14062] Not pure std.variant.Variant ctor

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Mar 6 18:54:15 PST 2015


https://issues.dlang.org/show_bug.cgi?id=14062

Kenji Hara <k.hara.pg at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Hardware|x86                         |All
                 OS|Windows                     |All
           Severity|regression                  |enhancement

--- Comment #4 from Kenji Hara <k.hara.pg at gmail.com> ---
(In reply to sinkuupump from comment #2)
> Ah, constructor can avoid calling fptr(OpId.destruct) because
> fpr==&handler!void there, so it can be pure. But destructor is still impure.
> Any ideas?

As you say, constructing Variant can be pure depending on the initialized value
type, so it would be an enhancement.

It is more precise test case for the enhancement:

auto makeVar(int n) pure
{
    import std.variant: Variant;
    return Variant(1);  // constructing Variant with int could be pure
}
void main()
{
    auto v = makeVar(1);
}

However to support it, a compile bug need to be fixed beforehand.
Issue 14252 - Erroneous dtor attributes check even if the struct returned
immediately


On the other hand, non-algebraic Variant type cannot copy or destruct in pure
function.


Change the importance to 'enhancement'.

--


More information about the Digitalmars-d-bugs mailing list