changeset 1132:76e72fdef04d

Fix tuple declarations in aggregates.
author Christian Kamm <kamm incasoftware de>
date Mon, 23 Mar 2009 14:47:51 +0100
parents f2f13f111e2e
children eeb8b95ea92e 9d308feaec27
files dmd/declaration.c tests/mini/tuplestruct.d
diffstat 2 files changed, 20 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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;
 	}
--- /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);
+}
+