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

          Issue ID: 22198
           Summary: Compile time bounds checking for static arrays
           Product: D
           Version: D2
          Hardware: Other
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: [email protected]
          Reporter: [email protected]

The following code fails to error out at compile time:

void main(){
    int[10] a;
    auto b = a[0..20];//mistake
}
The error is instead:
[email protected](3): Range violation
----------------
??:? _d_arrayboundsp [0x555bdc2b6c29]
./onlineapp.d:3 _Dmain [0x555bdc2b6b86]

This can easily be caught at compile time, please do so.

Thank you for your time!

--

Reply via email to