The following code does not compile with dmd v2.068.0. void main() { int* buf1 = new int[2].ptr; // Ok struct MyStruct {} MyStruct* buf2 = (new MyStruct[2]).ptr; // Ok // Error: expected TypeTuple when indexing ('[2]'), got 'MyStruct' MyStruct* buf3 = new MyStruct[2].ptr; }
Oh, did it work? AFAIK, D grammar never allowed to parse (new A.B) as (new A).B, that would require semantic analysis before parsing.
https://github.com/D-Programming-Language/dmd/pull/4876
(In reply to Sobirari Muhomori from comment #1) > Oh, did it work? AFAIK, D grammar never allowed to parse (new A.B) as (new > A).B, that would require semantic analysis before parsing. http://dlang.org/changelog.html#postfix-new
(In reply to kdmult from comment #3) > (In reply to Sobirari Muhomori from comment #1) > > Oh, did it work? AFAIK, D grammar never allowed to parse (new A.B) as (new > > A).B, that would require semantic analysis before parsing. > > http://dlang.org/changelog.html#postfix-new Until 2.067, compiler parser had recognized `MyStruct[2].` for the new-ed type, and `.ptr` was parsed as dot-identifier expression. In 2.068, the issue 1215 fix had (accidentally) changed parser behavior, to make the whole part of `MyStruct[2].ptr` as the new-ed type. Then semantic analysis is failing to find such the type.
Commit pushed to stable at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/c1d8b528477bdda68128826454b92be643760e53 fix Issue 14911 - Compiler found indexing in code "new MyStruct[2].ptr"
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/c1d8b528477bdda68128826454b92be643760e53 fix Issue 14911 - Compiler found indexing in code "new MyStruct[2].ptr"