www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10962] New: Wrong implicit conversion of enum in const function

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

           Summary: Wrong implicit conversion of enum in const function
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: kekeniro2 yahoo.co.jp



I have no idea whether this is a very specific case.

class SomeClass {
    enum E : short { init }
    E e1;
    E foo() const {
      //E ret = e1 ? E.init : e1; // OK
      //E e2;
      //return e2 ? E.init : e2; // OK
        return e1 ? E.init : e1; // NG
    }
}

DMD gives:
Error: cannot implicitly convert expression (this.e1 ? 0 : cast(int)this.e1) of
type int to E

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 03 2013