> What you need is a default initializer for array. It has nothing to do with > Val.
According to Nim documentation about [variables initialization](https://nim-lang.org/docs/manual.html#statements-and-expressions-var-statement), `array[0.., Val]` is initialized to `default(Val)` which in that case is `default(int)` and 0 is out of the valid range, reason why the compiler complains. If I could write (using a new keyword **zero** to indicate the default value of the type) : type Val = range['A' .. 'Z'] zero 'A' Run then the compiler could initialize an `array[0 .. n, Val]` to 'A' and `result` would be correctly initialized. > I do think Nim should auto initialize the result variable. I'm not sure if > this is a bug in the "proveInit" algorithm or a bug in the way nim is > initializing result. It may be worth a bug report but I'm not sure. >From what I can see in the debugger, `result` is initialized/filled with 0. >And this is conformed to the documentation about variables initialization. > As an alternative, I wrote a macro to "initialize" arrays for you. Thanks. It's more a workaround than a satisfaying solution but I'll see if I can use it in my code. Using the no warning pragma is shorter though ;-)
