Thread overview
[Issue 4273] New: Error: functions cannot return a tuple
Jun 04, 2010
Sean Kelly
Jun 05, 2010
Walter Bright
Jun 05, 2010
Walter Bright
Jun 05, 2010
Sean Kelly
June 04, 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@puremagic.com
        ReportedBy: sean@invisibleduck.org


--- Comment #0 from Sean Kelly <sean@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: -------
June 04, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4273


bearophile_hugs@eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs@eml.cc


--- Comment #1 from bearophile_hugs@eml.cc 2010-06-04 16:55:10 PDT ---
I don't understand the purpose of your code, but I think the problems are in your code.

Maybe in fooRet you meant to use:
alias T[0] fooRet;

You can also use:
auto foo(T...)(T vals)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 05, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4273



--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> 2010-06-04 17:16:41 PDT ---
"Fixing" this would require conflating a Tuple!(T) with T. I think this would
be a mistake.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 05, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4273


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |WONTFIX


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 05, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4273



--- Comment #3 from Sean Kelly <sean@invisibleduck.org> 2010-06-04 18:21:00 PDT ---
You're right, it was a mistake in my code.  Sorry.

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