[Issue 4273] New: Error: functions cannot return a tuple

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jun 4 16:24:43 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4273

           Summary: Error: functions cannot return a tuple
           Product: D
           Version: 2.040
          Platform: x86
        OS/Version: Mac OS X
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: sean at invisibleduck.org


--- Comment #0 from Sean Kelly <sean at invisibleduck.org> 2010-06-04 16:24:41 PDT ---
If line A is changed to "auto x = foo(1,2);" then the code compiles without
incident.  This should compile with one parameter as well.

   import std.typecons;

   template fooRet(T...)
   {
       static if( T.length == 1 )
           alias T fooRet;
       else
           alias Tuple!(T) fooRet;
   }

   fooRet!(T) foo(T...)(T vals)
   {
       Tuple!(T) ret;
       static if( T.length == 1 )
           return ret.field[0];
       else
           return ret;
   }

   void main()
   {
       auto x = foo(1); // A
   }

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list