Bug 5851 – Ambiguous alias this accepted.

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-04-17T06:55:00Z
Last change time
2012-07-18T02:59:46Z
Keywords
accepts-invalid, pull
Assigned to
yebblies
Creator
b.helyer

Comments

Comment #0 by b.helyer — 2011-04-17T06:55:06Z
import std.stdio; class Foo { this() { o = new Object(); } Object o; alias o this; override string toString() { return "Foo"; } } void foo(Object o) { writeln(o); } void main() { foo(new Foo()); } The code compiles, and prints "Foo". After discussing with Andrei, I believe this code is an error.
Comment #1 by andrei — 2011-04-17T06:56:37Z
Yah, it's a simple case of unreachable code - the alias this would never ever get a chance. This needs to be rejected.
Comment #2 by yebblies — 2012-02-01T01:35:31Z
Comment #3 by github-bugzilla — 2012-07-17T01:32:59Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/51106f05fe3cf3abd2650ddd316eaaeedafc9fc6 Issue 5851 - Ambiguous alias this accepted Disallow alias this when the aggregate type implicitly converts to the aliased type. Fixes issue 5851. https://github.com/D-Programming-Language/dmd/commit/bc83600d34f6f7d5c5effdaa3c9ed635701b6953 Merge pull request #676 from yebblies/issue5851 Issue 5851 - Ambiguous alias this accepted