Closed mratsim closed 1 month ago
@mratsim please minimize; note that https://github.com/nim-lang/Nim/pull/17590 fixes https://github.com/nim-lang/Nim/issues/14585 but not this issue, however it could very well be that a similar fix as https://github.com/nim-lang/Nim/pull/17590 would fix this too
Come on, it's a single file with 37 lines. It's also the minimum translation of my data structure and what I attempted to do.
Given how distinct, static, symbol resolution/bindsym, generics, {.compileTime.} and types interact with each other and the useless error message, I think that's reasonable minimal reproducing example.
I tried to minimize this a bit more and obtained the following code:
import macros
macro makeIntLit(c: static int): untyped =
result = newLit(c)
type Test*[T: static int] = object
myArray: array[makeIntLit(T), int]
It turns out, that the compiler passes the NimNode "T" to makeIntLit,
instead of an int. Therefore its register is of kind rkNode
and the call to newLit
fails. In the original example, the same thing happens: Instead of passing the enum value BLS12_381
, the node "C" is passed to the Mod
macro.
I see two ways to solve this:
When using a macro to compute the static int that parametrize a static type in a type section, we get
Test case