www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2597] New: auto return doesn't work for a variety of cases

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2597

           Summary: auto return doesn't work for a variety of cases
           Product: D
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: andrei metalanguage.com


Type deduction for function value return type doesn't work for member functions
of templates, e.g.:

struct S(T)
{
    auto a(U)(U x) { return 5; }
    auto b(T x) { return 5; }
    auto c() { return 5; }
}

doesn't work (a is fine, b and c are not although all three are function
templates). I'm thinking also non-templates could be helped by auto:

auto d(T)(T x) { return 5; }
auto e(int x) { return 5; }

d works, e doesn't. Should it?


-- 
Jan 20 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2597





------- Comment #1 from jarrett.billingsley gmail.com  2009-01-21 08:02 -------
(In reply to comment #0)

 auto d(T)(T x) { return 5; }
 auto e(int x) { return 5; }
 
 d works, e doesn't. Should it?

Of course it should. Why does this work: auto e = (int x) { return 5; } but not: auto e(int x) { return 5; } ? Wouldn't the two use.. more or less the exact same mechanism? --
Jan 21 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2597


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #2 from bugzilla digitalmars.com  2009-03-11 14:56 -------
Fixed dmd 2.026


-- 
Mar 11 2009