Re: Understanding "Error: cannot evaluate at compile time"
I've been reading all the [issues related to static and templates](https://github.com/nim-lang/Nim/issues?q=is%3Aissue+is%3Aopen+static+template), [macros](https://github.com/nim-lang/Nim/issues?q=is%3Aissue+is%3Aopen+static+macro) and [typedesc](https://github.com/nim-lang/Nim/issues?q=is%3Aissue+is%3Aopen+template+typedesc). I see that I'm entering the fuzzy zone where Nim typing is not totally defined and the syntax is moving. The discussions on generics vs type variables shows that there's no consensus on how types variability must be managed in Nim. And I think that it impacts finding a clean way to solve these types of bugs. Meanwhile, I have to find a way to change my code to stay in Nim safer areas, _if possible_.
Re: Understanding "Error: cannot evaluate at compile time"
The issue is typedesc/static in template is slightly broken, see [issue 1](https://github.com/nim-lang/Nim/issues/14053) (this exact issue), [issue 2](https://github.com/nim-lang/Nim/issues/13527) (points out a case where static works and typedesc doesnt), [issue 3](https://github.com/nim-lang/Nim/issues/7160) (this exact issue for typedesc).
Re: Understanding "Error: cannot evaluate at compile time"
type B[S: static[int]] = object template foo(size: static[int]): auto = B[size]() echo foo(16).repr Run Works on my machine
Understanding "Error: cannot evaluate at compile time"
This [small bit of code](https://play.nim-lang.org/#ix=2jYh) barks at compile time with `(4, 35) Error: cannot evaluate at compile time: size`. type B[S: static int] = object template foo(size: static int): B[size] = B[size]() echo foo(16).repr Run The error is about the `size` in `B[size]` in the template declaration. Why does the compiler complains as not knowing `size` value at compile time as it is declared `static int`? When replacing `static int` by `int`, the error turns to `Error: type mismatch: got but expected 'B[size]'`. The only combinations to get it compiling are if I replace `size` by `16`, or if I remove all the `static` in the code. But programming is not trying syntax at random and I would like to understand why it fails when I use `static`.