[Issue 686] New: [Regression] opCast of a struct or union is called in nonsensical circumstances

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Dec 13 11:58:06 PST 2006


http://d.puremagic.com/issues/show_bug.cgi?id=686

           Summary: [Regression] opCast of a struct or union is called in
                    nonsensical circumstances
           Product: D
           Version: 0.177
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: smjg at iname.com


This used to work.  But now, it's broken the bit array/pointer types in my
utility library.

----------
struct Qwert {
    Yuiop opCast() {
        return Yuiop.init;
    }
}

struct Yuiop {
    Qwert asdfg() {
        return Qwert.init;
    }

    void hjkl() {
        Qwert zxcvb = asdfg();  // line 13
    }
}
----------
opCast_struct.d(13): Error: cannot implicitly convert expression
(((this.asdfg)().opCast)()) of type Yuiop to Qwert
----------

There's absolutely no reason that it should be trying to call Qwert.opCast. 
adsfg() is already of type qwert; even if it wasn't, this wouldn't make sense
since "Overloading the cast operator does not affect implicit casts, it only
applies to explicit casts."

If Qwert.opCast is removed, the code compiles without error.


-- 



More information about the Digitalmars-d-bugs mailing list