Fix tuple declarations in aggregates.

This commit is contained in:
Christian Kamm
2009-03-23 14:47:51 +01:00
parent 2dcc7be873
commit 372b40dd94
2 changed files with 20 additions and 2 deletions

View File

@@ -767,13 +767,16 @@ void VarDeclaration::semantic(Scope *sc)
VarDeclaration *v = new VarDeclaration(loc, arg->type, id, ti);
//printf("declaring field %s of type %s\n", v->toChars(), v->type->toChars());
v->semantic(sc);
/*
// removed for LDC since TupleDeclaration::toObj already creates the fields;
// adding them to the scope again leads to duplicates
if (sc->scopesym)
{ //printf("adding %s to %s\n", v->toChars(), sc->scopesym->toChars());
if (sc->scopesym->members)
sc->scopesym->members->push(v);
}
*/
Expression *e = new DsymbolExp(loc, v);
exps->data[i] = e;
}

15
tests/mini/tuplestruct.d Normal file
View File

@@ -0,0 +1,15 @@
struct V(T...) {
T v;
}
alias V!(Object, int) MyV;
void main()
{
assert(MyV.sizeof == Object.sizeof + int.sizeof);
auto o = new Object;
auto v = MyV(o, 3);
assert(v.v[0] is o);
assert(v.v[1] == 3);
}