[Issue 9151] New: opCast makes "this" alias ineffective

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Dec 13 09:34:15 PST 2012


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

           Summary: opCast makes "this" alias ineffective
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: puneet at coverify.org


--- Comment #0 from Puneet Goel <puneet at coverify.org> 2012-12-13 09:34:14 PST ---
The following code gives me an error saying:
Error: template instance opCast!(bool) opCast!(bool) does not match template
declaration opCast(T)() if (is(T == int))

The error disappears if the opCast is not defined.

struct Foo {
  int t;
  bool get() {
    return (t == 0);
  }
  alias get this;
  T opCast(T) () if(is(T == int)) {
    return t;
  }
}

void main() {
  Foo f;
  if(f) {}
}

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


More information about the Digitalmars-d-bugs mailing list