When an empty nkArgList `varargs[untyped]` is passed around it is now reused for efficiency sake and to prevent the introduction of a spurious element: before this commit we'd pass the caller a nkArgList[nkHiddenStdConv[nkBracket]] node instead of just an empty nkArgList. Fixes #8706
21 lines
344 B
Nim
21 lines
344 B
Nim
discard """
|
|
output: '''0
|
|
0
|
|
'''
|
|
"""
|
|
|
|
import macros
|
|
|
|
macro varargsLen(args:varargs[untyped]): untyped =
|
|
doAssert args.kind == nnkArglist
|
|
doAssert args.len == 0
|
|
result = newLit(args.len)
|
|
|
|
template bar(a0:varargs[untyped]): untyped =
|
|
varargsLen(a0)
|
|
|
|
template foo(x: int, a0:varargs[untyped]): untyped =
|
|
bar(a0)
|
|
|
|
echo foo(42)
|
|
echo bar()
|