> That will always parse to an associative array. Then in the semantic pass, if > U is a constant expression that turns out to be an integer it is reinterpreted as a static array.
Ah, interesting. But that describes the implementation (i.e. how the compiler copes with the ambiguity) and not the language itself. > Context-free means that it's unambiguous as to which grammar rule is to be applied at any point during the parsing process. The problem is that it _is_ ambiguous what rule to apply. To me, just because static arrays and associative arrays happen to have similar _looks_ doesn't make parsing them context-free -- they're defined with completely separate syntaxes, and they just happen to look identical. The fact that the compiler has to do a semantic analysis in order to figure this out (which was originally a syntax problem) really makes me wonder why you mention that D is still context-free. > Not to mention, the context-free grammar is entirely for parsing tokens into > an abstract syntax tree. Again, just because the AST's _happen_ to _look_ the same for static and associative arrays, does that mean that this makes D context-free? The meaning of the expression is still ambiguous, whether or not it fits well within the tree. Furthermore, I would say that a struct like this: struct Temp(T...) { int[T] arr; } should work perfectly if T.length == 0, since it would then be a dynamic array. But the parser is forced to treat it as an associative array, and so _both_ of these break: Temp!() a; Temp!(2) b; //Why does this break? Why should the second one break, in any case?