Mercurial > projects > ddmd
comparison dmd/StructInitializer.d @ 135:af1bebfd96a4 dmd2037
dmd 2.038
author | Eldar Insafutdinov <e.insafutdinov@gmail.com> |
---|---|
date | Mon, 13 Sep 2010 22:19:42 +0100 |
parents | 60bb0fe4563e |
children | e3afd1303184 |
comparison
equal
deleted
inserted
replaced
134:4251f96733f4 | 135:af1bebfd96a4 |
---|---|
76 this.value.push(value); | 76 this.value.push(value); |
77 } | 77 } |
78 | 78 |
79 override Initializer semantic(Scope sc, Type t) | 79 override Initializer semantic(Scope sc, Type t) |
80 { | 80 { |
81 TypeStruct ts; | |
82 int errors = 0; | 81 int errors = 0; |
83 | 82 |
84 //printf("StructInitializer.semantic(t = %s) %s\n", t.toChars(), toChars()); | 83 //printf("StructInitializer.semantic(t = %s) %s\n", t.toChars(), toChars()); |
85 vars.setDim(field.dim); | 84 vars.setDim(field.dim); |
86 t = t.toBasetype(); | 85 t = t.toBasetype(); |
87 if (t.ty == Tstruct) | 86 if (t.ty == Tstruct) |
88 { | 87 { |
89 uint i; | |
90 uint fieldi = 0; | 88 uint fieldi = 0; |
91 | 89 |
92 ts = cast(TypeStruct)t; | 90 auto ts = cast(TypeStruct)t; |
93 ad = ts.sym; | 91 ad = ts.sym; |
94 for (i = 0; i < field.dim; i++) | 92 if (ad.ctor) |
93 error("%s %s has constructors, cannot use { initializers }, use %s( initializers ) instead", | |
94 ad.kind(), ad.toChars(), ad.toChars()); | |
95 for (size_t i = 0; i < field.dim; i++) | |
95 { | 96 { |
96 Identifier id = field[i]; | 97 Identifier id = field[i]; |
97 Initializer val = value[i]; | 98 Initializer val = value[i]; |
98 Dsymbol s; | 99 Dsymbol s; |
99 VarDeclaration v; | 100 VarDeclaration v; |