www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23381] New: null/init are not accepted as initializers of a

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

          Issue ID: 23381
           Summary: null/init are not accepted as initializers of a
                    zero-sized static array
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: maxsamukha gmail.com

int[0] a = []; // ok
int[0] a1 = null; // fail
int[0] a2 = (int[]).init; // fail

void main()
{
}

onlineapp.d(2): Error: cannot implicitly convert expression `null` of type
`typeof(null)` to `int[0]`
onlineapp.d(3): Error: cannot implicitly convert expression `null` of type
`int[]` to `int[0]`

Accepted in function scopes:

void main()
{
    int[0] a1 = null; // ok
    int[0] a2 = (int[]).init; // ok
}

--
Sep 30 2022