Thread overview
[Issue 2597] New: auto return doesn't work for a variety of cases
Jan 21, 2009
d-bugmail
Jan 21, 2009
d-bugmail
Mar 11, 2009
d-bugmail
January 21, 2009
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?


-- 

January 21, 2009
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?


-- 

March 11, 2009
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


--