You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a follow-up on the discussion here: #8715 (comment).
For me this is the main reason I use nnkArgList, example taken from #7737.
import macros, typetraits, sequtils
procgetSubType*(T: NimNode): NimNode=echogetTypeInst(T).treerepr # <---- Output comes from hereresult=getTypeInst(T)[1]
macrotyped_helper(x: varargs[typed]): untyped=let foo =getSubType(x[0])
result=quotedo: discardmacrountyped_heavylifting(x: varargs[untyped]): untyped=# var containers = nnkArgList.newTree()var containers = nnkBracket.newTree()
for arg in x:
ifeqIdent(arg[0], "in"):
containers.add arg[2]
result=quotedo:
typed_helper(`containers`)
var a, b, c: seq[int]
untyped_heavylifting z in c, x in a, y in b:
discard
The getSubType proc returns:
# Case nnkArgListBracketExprSym"seq"Sym"int"
and
# Case nnkBracketBracketExprSym"array"InfixIdent".."IntLit0IntLit2BracketExprSym"seq"Sym"int"
i.e. varargs[typed] needs nnkArgList for proper type resolution.
cc @Araq@zah@LemonBoy
Related to #7719/nim-lang/RFCs#44 (Working with types in macro is difficult)
The text was updated successfully, but these errors were encountered:
I'd argue that we just need a bit of consistency here, let's use nkArgList for argument lists and nkBracket for everything else instead of this awkward situation where you can mix&match nodes.
This is a follow-up on the discussion here: #8715 (comment).
For me this is the main reason I use
nnkArgList
, example taken from #7737.The
getSubType
proc returns:and
i.e. varargs[typed] needs nnkArgList for proper type resolution.
cc @Araq @zah @LemonBoy
Related to #7719/nim-lang/RFCs#44 (Working with types in macro is difficult)
The text was updated successfully, but these errors were encountered: