Bug 9117 – format fails if opCast and this alias are both defined in an aliased struct
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-12-06T09:56:00Z
Last change time
2012-12-07T22:17:45Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
puneet
Comments
Comment #0 by puneet — 2012-12-06T09:56:42Z
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"
}