[Issue 9117] New: format fails if opCast and this alias are both defined in an aliased struct

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Dec 6 09:56:45 PST 2012


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

           Summary: format fails if opCast and this alias are both defined
                    in an aliased struct
           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-06 09:56:42 PST ---
This is a reduced code. Does not compile with released DMD or with github
snapshot. Strangely it compiles without any error if the opCast operation is
commented out. Note that the opCast operation casts to frop, which is totally
unrelated.

struct Bar {
  Foo foo;
  alias foo this;
  string toString() {
    return "Bar";
  }
}

struct Frop {}

struct Foo {
  int n = 0;
  alias n this;
  T opCast (T) () if (is(T == Frop))
  {
    return Frop();
  }
  string toString() {
    return "Foo";
  }
}

void main() {
  import std.stdio;
  Foo foo;
  writeln(foo);            // no issues
  Bar bar;
  // Compiles if either the alias or opCast in Foo are commented out
  writeln(bar);            // does not compile -- should just print "Bar"
}

-- 
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