Bug 7007 – [] should have a type of its own

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
Other
OS
All
Creation time
2011-11-25T13:20:47Z
Last change time
2024-12-13T17:57:03Z
Assigned to
No Owner
Creator
timon.gehr
Moved to GitHub: dmd#18383 →

Comments

Comment #0 by timon.gehr — 2011-11-25T13:20:47Z
Now that null has an own type (issue 5416), typeof([]) == void[] is inconsistent. Consider: void foo(int[] x){} void bar(T)(T x){foo(x);} void main(){ foo(null); // ok foo([]); // ok bar(null); // ok! bar([]); // fail } This example should compile.
Comment #1 by k.hara.pg — 2011-11-26T00:43:39Z
There are some implementation issues. If you name an unspecified element type as 'Nothing', auto a = []; // Nothing[] auto b1 = [[]]; // Nothing[][] auto b2 = [[], null]; // Nothing[][], but its runtime is different from b1 int[][] na1 = b1; // may need runtime allocation and conversion int[][] na2 = b2; // may need runtime allocation and conversion
Comment #2 by timon.gehr — 2011-11-26T07:25:17Z
Nothing[][] is not a subtype of int[][]. The assignments should not even compile.
Comment #3 by bearophile_hugs — 2012-08-26T04:38:24Z
See also Issue 8589
Comment #4 by dkorpel — 2021-09-08T10:19:25Z
This will be fixed once DIP1034 "Add a Bottom Type (reboot)" is implemented.
Comment #5 by robert.schadek — 2024-12-13T17:57:03Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18383 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB