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 <B[16]> 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`.

Reply via email to