Thread overview
[Issue 19010] new fails on dynamic array aliases
Jun 21, 2018
ag0aep6g
Jun 21, 2018
Basile B.
Dec 12, 2019
Basile-z
Mar 21, 2020
Basile-z
June 21, 2018
https://issues.dlang.org/show_bug.cgi?id=19010

ag0aep6g <ag0aep6g@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ag0aep6g@gmail.com

--- Comment #1 from ag0aep6g <ag0aep6g@gmail.com> ---
The alias has nothing to do with the error. This gives the same error:

----
unittest {
    int[] t = new int[]; /* Error: new can only create structs, dynamic arrays
or class objects, not int[]'s */
}
----

(In reply to elpenguino+D from comment #0)
> This doesn't seem to have ever compiled correctly.

As far as I know, `new int[]` is not supposed to compile. The spec [1] is a bit scarce on this, but `new`ing arrays is only mentioned with explicit lengths.


[1] https://dlang.org/spec/expression.html#new_expressions

--
June 21, 2018
https://issues.dlang.org/show_bug.cgi?id=19010

Basile B. <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |b2.temp@gmx.com

--- Comment #2 from Basile B. <b2.temp@gmx.com> ---
Grammartically it's valid (it's the first new rule, i.e `new AllocatorArgumentsopt Type`) but since `new` for arrays doesn't return a pointer to an array, allowing this would be a bit pointless because

  `int[] a = new int[];`

would be the same as

  `int[] a;`

--
December 12, 2019
https://issues.dlang.org/show_bug.cgi?id=19010

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #3 from Basile-z <b2.temp@gmx.com> ---
The problem is actually a bad diagnostic. This is like 20422, i.e the length parameter misses.

*** This issue has been marked as a duplicate of issue 20422 ***

--
March 21, 2020
https://issues.dlang.org/show_bug.cgi?id=19010

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|b2.temp@gmx.com             |

--