www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13941] New: NewExpression grammar is insufficient

https://issues.dlang.org/show_bug.cgi?id=13941

          Issue ID: 13941
           Summary: NewExpression grammar is insufficient
           Product: D
           Version: D2
          Hardware: All
               URL: http://dlang.org/grammar.html#NewExpressionWithArgs
                OS: All
            Status: NEW
          Keywords: spec
          Severity: normal
          Priority: P1
         Component: websites
          Assignee: nobody puremagic.com
          Reporter: briancschott gmail.com
            Blocks: 10233

Consider the following reasonable D program:

---
void main()
{
    import std.stdio : writeln;
    int[][] var = new int[][](3, 2);
    writeln(var);
}
---

The relevant parts of the grammar:

NewExpressionWithArgs:
    'new' AllocatorArguments? Type '(' ArgumentListopt ')'
Type:
    TypeCtors? BasicType
    TypeCtors? BasicType AltDeclarator
AltDeclarator:
    BasicType2? Identifier AltDeclaratorSuffixes
AltDeclaratorSuffix:
    '[' ']'

"int[][]" cannot be parsed with the AltDeclarator rule because there is no
identifier between "int" and "[][]"

--
Jan 05 2015