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