Mercurial > projects > ddmd
diff dmd/ArrayInitializer.d @ 79:43073c7c7769
updated to 2.035
also implemented a few missing functions
still crashes in Import.importAll though
author | Trass3r |
---|---|
date | Mon, 30 Aug 2010 03:57:51 +0200 |
parents | ef02e2e203c2 |
children | be2ab491772e |
line wrap: on
line diff
--- a/dmd/ArrayInitializer.d Sun Aug 29 14:39:08 2010 +0100 +++ b/dmd/ArrayInitializer.d Mon Aug 30 03:57:51 2010 +0200 @@ -2,6 +2,7 @@ import dmd.ArrayTypes; import dmd.Type; +import dmd.TypeAArray; import dmd.TypeNext; import dmd.Array; import dmd.Loc; @@ -132,7 +133,7 @@ for (size_t i = 0; i < value.dim; i++) { if (index.data[i]) - goto Lno; + goto Laa; } for (size_t i = 0; i < value.dim; i++) @@ -151,9 +152,22 @@ } return type; - Lno: - error(loc, "cannot infer type from this array initializer"); - return Type.terror; + Laa: + /* It's possibly an associative array initializer + */ + Initializer iz = cast(Initializer)value.data[0]; + Expression indexinit = cast(Expression)index.data[0]; + if (iz && indexinit) + { + Type t = iz.inferType(sc); + indexinit = indexinit.semantic(sc); + Type indext = indexinit.type; + t = new TypeAArray(t, indext); + type = t.semantic(loc, sc); + } + else + error(loc, "cannot infer type from this array initializer"); + return type; } /******************************** @@ -171,6 +185,9 @@ Type t = null; if (type) { + if (type == Type.terror) + return new ErrorExp(); + t = type.toBasetype(); switch (t.ty) {