mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-02-18 04:33:27 +01:00
Fix tuple declarations in aggregates.
This commit is contained in:
@@ -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
15
tests/mini/tuplestruct.d
Normal 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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user