void main(){
int[3] arr = [1, 2, 3,];
}
Is the extra comma legal or is it not flagged as error because of a compiler bug? I have many mixins that generate arrays with the extra comma at the end. I would like to know if I should taken the time to remove them.
even this compiles without errors:
void main(){
int[3] arr = [1, 2, 3,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,];
}
I believe it’s legal in order to allow for templates (or even mixins) to work in a generic manner:
It makes templates much easier to work with, so that you don’t have to special-case against special outputs.
A more realistic example:
Now what happens if
ais equal tob? Thenarr2decays to[-10, ].