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" }
Comment #1 by k.hara.pg — 2012-12-07T07:17:58Z
Comment #2 by github-bugzilla — 2012-12-07T22:17:35Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/75064f6be11c61e4cd7aaef70a982fc0e8fc1cef fix Issue 9117 - format fails if opCast and this alias are both defined in an aliased struct https://github.com/D-Programming-Language/phobos/commit/b3c60e3c9f1b6eef54b687bf75b5b20cbe705877 Merge pull request #994 from 9rnsr/fix9117 Issue 9117 - format fails if opCast and this alias are both defined in an aliased struct