Files
Nim/tests/generics/m14509.nim
metagn f1789cc465 resolve local symbols in generic type call RHS (#22610)
resolve local symbols in generic type call

fixes #14509
2023-09-01 09:00:15 +02:00

17 lines
415 B
Nim

import macros
type float32x4 = array[4, float32]
type float32x8 = array[8, float32]
{.experimental: "dynamicBindSym".}
macro dispatch(N: static int, T: type SomeNumber): untyped =
let BaseT = getTypeInst(T)[1]
result = bindSym($BaseT & "x" & $N)
type
VecIntrin*[N: static int, T: SomeNumber] = dispatch(N, T)
func `$`*[N, T](vec: VecIntrin[N, T]): string =
## Display a vector
$cast[array[N, T]](vec)