Closed
Description
varargs[typed]
as macro parameter type doesn't accept a NimNode
of kind nnkClosedSymChoice
but just a parameter type of typed
does.
Example
import macros
macro typedVarargs(x: varargs[typed]) =
echo x[0].kind
macro typedSingle(x: typed) =
echo x.kind
typedSingle(len)
typedVarargs(len)
Current Output
nnkSym
/usercode/in.nim(10, 13) Error: type mismatch: got <proc (x: HSlice[len.U, len.V]): int{.inline, noSideEffect.} | proc (x: seq[T]): int{.noSideEffect.} | proc (x: string): int{.noSideEffect, gcsafe, locks: 0.} | proc (x: TOpenArray: openArray or varargs): int{.noSideEffect.} | proc (x: set[T]): int{.noSideEffect.} | proc (x: typedesc[array] or array): int{.noSideEffect.} | proc (x: cstring): int{.noSideEffect, gcsafe, locks: 0.} | proc (w: WideCString): int{.noSideEffect, gcsafe, locks: 0.} | proc (n: NimNode): int{.noSideEffect.}>
but expected one of:
macro typedVarargs(x: varargs[typed])
first type mismatch at position: 1
required type for x: varargs[typed]
but expression 'len' is of type: None
expression: typedVarargs(len)
Expected Output
nnkSym
nnkClosedSymChoice
Additional Information
Seems to exist at least back from 1.0.0
Testing on nightly
$ nim -v
Nim Compiler Version 1.6.2 [MacOSX: amd64]
Compiled at 2021-12-20
Copyright (c) 2006-2021 by Andreas Rumpf
active boot switches: -d:release