Fix VarDecls for tuples. Closes #99.

I've implemented it this way since it doesn't require any changes in the
frontend. However, I think having TypeTuple expressed as LLVM struct types
would make much more sense and open the door to tuple lvalues.
This commit is contained in:
Christian Kamm
2008-10-05 11:47:47 +02:00
parent 40d0df8769
commit 2a999b72e8
4 changed files with 86 additions and 0 deletions

30
tests/mini/tupleval.d Normal file
View File

@@ -0,0 +1,30 @@
module foo;
template ParameterTupleOf( Fn )
{
static if( is( Fn Params == function ) )
alias Params ParameterTupleOf;
else static if( is( Fn Params == delegate ) )
alias ParameterTupleOf!(Params) ParameterTupleOf;
else static if( is( Fn Params == Params* ) )
alias ParameterTupleOf!(Params) ParameterTupleOf;
else
static assert( false, "Argument has no parameters." );
}
struct S
{
int opApply(T)(T dg)
{
alias ParameterTupleOf!(T) U;
U u;
u[0] = 1;
u[1] = 2;
return 0;
}
}
void main()
{
foreach(int x, int y; S()){}
}