www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8759] New: autogenerated opEquals does no handle well Variant


           Summary: autogenerated opEquals does no handle well Variant
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: fawzi gmx.ch

--- Comment #0 from Fawzi Mohamed <fawzi gmx.ch> 2012-10-04 14:40:00 PDT ---
Not sure where to put this (if it is a phobos or dmd bug), but the interaction
is ugly: adding the field a (or any field that has opEquals with const) to
struct B makes the compilation fail with the given error.

Manually implementing a const opEquals with casts is a workaround for this, but
 I find it ugly because a small change to a (adding opEquals), requires
opEquals to struct using it.

module t;
import std.variant;

struct A{
    int opEquals(ref const(A) o) const /+ this const is the trigger of the bug
+/ {
        return &o is &this;

struct B{
    Variant x;
    A a;
fails compiling with dmd 2.060 with:

/home/fawzi/d/dmd2/linux/bin64/../../src/phobos/std/variant.d(513): Error:
static assert  "Assigning Variant objects from const Variant objects is
currently not supported."
instantiated from here: opAssign!(const(VariantN!(32LU)))
instantiated from here: __ctor!(const(VariantN!(32LU)))
t.d(10):        instantiated from here: opEquals!(const(VariantN!(32LU)))


might be or be related with issue5310 or issue8328

Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 04 2012