Thread overview
problem with Tuple over user-defined class
Jul 02, 2008
baleog
Jul 02, 2008
baleog
Jul 02, 2008
Koroskin Denis
July 02, 2008
Hello,
Tuple from the typecons works fine with the basic data types. But not with the user-defined classes.
Test code:
--
import std.typecons;
class A
{
  int x;
}

unittest
{
  Tuple!(int) x; // works fine
  Tuple(A) y; /* Error: identifier 'A' is not defined
                        Error: A is used as a type
                       ~/dmd/src/phobos/std/typecons.d: variable std.typecons.Values!(A).Tuple.T voids have no value */
}
--
does it possible to use Tuple struct from typecons with the user-defined class?

Thank you

p.s. dmd-2.014
July 02, 2008
baleog Wrote:
>   Tuple(A) y; /* Error: identifier 'A' is not defined
need to read "Tuple!(A) y;"

sorry
July 02, 2008
On Wed, 02 Jul 2008 20:43:03 +0400, baleog <maccarka@yahoo.com> wrote:

> Hello,
> Tuple from the typecons works fine with the basic data types. But not with the user-defined classes.
> Test code:
> --
> import std.typecons;
> class A
> {
>   int x;
> }
>
> unittest
> {
>   Tuple!(int) x; // works fine
>   Tuple(A) y; /* Error: identifier 'A' is not defined
>                         Error: A is used as a type
>                        ~/dmd/src/phobos/std/typecons.d: variable std.typecons.Values!(A).Tuple.T voids have no value */
> }
> --
> does it possible to use Tuple struct from typecons with the user-defined class?
>
> Thank you
>
> p.s. dmd-2.014

Confirm, 2.009 and 2.015 suffer from the same problem. Don't have other versions nearby to test.

Simplified test case:

Test.d
~~~~~~
import std.typecons;

class A {
  int x;
}

Tuple!(A) y;

// end of Test.d

Output:
Error: identifier 'A' is not defined
Error: A is used as a type
C:\dmd\bin\..\src\phobos\std\typecons.d: variable std.typecons.Tuple!(A).Tuple._0 voids have no value
C:\dmd\bin\..\src\phobos\std\typecons.d(522): template instance std.typecons.Tuple!(A) error instantiating

Line numbers not mentioned, too.
Anyone fills the bug report?