digitalmars.D.bugs - [Issue 9618] New: DMD takes unnecessary route to alias this in certain situations
- d-bugmail puremagic.com (53/53) Feb 28 2013 http://d.puremagic.com/issues/show_bug.cgi?id=9618
http://d.puremagic.com/issues/show_bug.cgi?id=9618 Summary: DMD takes unnecessary route to alias this in certain situations Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: puneet coverify.org --- I am using the latest DMD github snapshot. The following reduced code gives me an error on line 4: test.d(4): Error: e2ir: cannot cast b.barObj.val of type int to type test.BarBase The error disappears if I comment out the "alias this" on line 10. As per my analysis, the following conditions must be met for the error to appear. 1. At least one (correct) "alias this" mapping should have already happened. In this example, that mapping is from Bar -> BarObj 2. An implicit upcast is required after the first alias mapping has occurred. In the example that upcast is from BarObj -> BarBase In such situations, DMD is not looking at the possible upcast if further "alias this" is possible. It does (incorrect) mapping to "alias this" and ends up in a compile failure. class Foo(T) { // 1 T a ; // 2 void bind(Bar b) { // 3 this.a = b; // 4 } // 5 } // 6 class BarBase{} // 7 class BarObj: BarBase { // 8 int val; // 9 alias val this; // 10 } // 11 class Bar { // 12 BarObj barObj; // 13 alias barObj this; // 14 } // 15 class Top { // 16 Bar bar; // 17 Foo!(BarBase) foo; // 18 this() { // 19 foo.bind(bar); // 20 } // 21 } // 22 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 28 2013