# HG changeset patch # User Christian Kamm # Date 1237816071 -3600 # Node ID 76e72fdef04d8fa0d34bf81bff7dee87e3b92fb7 # Parent f2f13f111e2ed56f941d220f6c8c35c50409dc9e Fix tuple declarations in aggregates. diff -r f2f13f111e2e -r 76e72fdef04d dmd/declaration.c --- a/dmd/declaration.c Mon Mar 23 01:01:55 2009 +0100 +++ b/dmd/declaration.c Mon Mar 23 14:47:51 2009 +0100 @@ -767,13 +767,16 @@ 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; } diff -r f2f13f111e2e -r 76e72fdef04d tests/mini/tuplestruct.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/mini/tuplestruct.d Mon Mar 23 14:47:51 2009 +0100 @@ -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); +} +