digitalmars.D.bugs - [Issue 22922] New: Support empty array literal in -betterC
- d-bugmail puremagic.com (28/28) Mar 24 2022 https://issues.dlang.org/show_bug.cgi?id=22922
https://issues.dlang.org/show_bug.cgi?id=22922 Issue ID: 22922 Summary: Support empty array literal in -betterC Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: andy.pj.hanson gmail.com There is an unnecessary error for empty array literals when -betterC is enabled. ``` extern(C) void main() { int[] x = []; int[] y = (cast(int*) null)[0 .. 0]; } ``` Compile with `dmd a.d -betterC` and it outputs: ``` a.d(2): Error: `TypeInfo` cannot be used with -betterC ``` Since the expression `(cast(int*) null)[0 .. 0]` works, DMD should be able to translate `[]` into it without needing TypeInfo. --
Mar 24 2022