Discussion Thread: DIP 1039--Static Arrays with Inferred Length--Community Review Round 1
Dukc
ajieskola at gmail.com
Fri Jan 8 11:49:30 UTC 2021
On Thursday, 7 January 2021 at 15:58:24 UTC, Luhrel wrote:
>
> ```
> int staticArrFunc(int[6] a)
> {
> return a[0];
> }
>
> void main()
> {
> int[] s = [1, 2, 3, 4, 5, 6];
> int[] y = s[0 .. staticArrFunc(cast(int[$]) [1,2,3])];
> // Error: CTFE internal error: trying to access
> uninitialized var
> }
> ```
>
> Do you have a currently working example, that would potentially
> be broken by my DIP ?
It does not compile because length of `s` is not known at compile
time. It SHOULD compile if `s` was either a static array or a
manifest constant, but currently it does not - what a lucky bug!
I still think it deserves a mention -it's standard practice to
put the "breaking changes" section even if there are none. In
this case it seems a breaking change by the spec, but not by the
implementation.
More information about the Digitalmars-d-announce
mailing list