Bug 8780 – std.traits.ReturnType of overloaded functions

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-10-08T03:29:06Z
Last change time
2018-04-19T20:31:55Z
Keywords
accepts-invalid
Assigned to
Kenji Hara
Creator
luka8088

Comments

Comment #0 by luka8088 — 2012-10-08T03:29:06Z
module program; import std.stdio; import std.traits; int f1 () { return 1; } string f1 () { return "2"; } void main () { ReturnType!(f1) v1; writeln(typeid(typeof(v1))); // int // chould this lead to unexpected behavior ? }
Comment #1 by luka8088 — 2012-10-08T03:44:04Z
module program; import std.stdio; import std.traits; class a {} class b {} int f1 (a o) { return 1; } string f1 (b o) { return "2"; } void main () { a a1 = new a(); b b1 = new b(); writeln(a1.f1()); // 1 writeln(b1.f1()); // 2 typeof(a1.f1()) v1; // int typeof(b1.f1()) v2; // string ReturnType!(a1.f1) v2; // Error: no property 'f1' for type 'program.a' // Error: ReturnType!(__error) is used as a type }
Comment #2 by luka8088 — 2012-10-08T04:04:34Z
I am sorry for such bad description but it seems to me that there are multiple bugs here and I am not sure where the problem is - or even if there is one. Free free to provide a better description =)
Comment #3 by verylonglogin.reg — 2012-11-15T00:35:25Z
This is because of Issue 7549. Not a duplicate as library have to workaround compiler bugs and work correct.
Comment #4 by simen.kjaras — 2018-04-19T20:31:55Z
*** This issue has been marked as a duplicate of issue 7549 ***