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
BUG: the 1st of {nnkIdent, nnkSym}: is allowed
the 2nd one of {nnkEmpty, nnkLiterals}: is not allowed, giving compile error
seems like the 1st one should also give compiler error?
either way, it's inconsistent
import macros
procreplaceNodes(ast: NimNode): NimNode=procinspect(node: NimNode): NimNode=case node.kind:
of {nnkIdent, nnkSym}: #this set one is allowed, seems like a BUG# of nnkIdent, nnkSym:returnident($node)
of {nnkEmpty, nnkLiterals}: # this one is not allowed, giving Error: type mismatch: got <set[NimNodeKind]> but expected 'NimNodeKind = enum'# of nnkEmpty, nnkLiterals: # this would workreturnident($node)
else:
var rTree = node.kind.newTree()
for child in node:
rTree.addinspect(child)
return rTree
result=inspect(ast)
The use case for allowing a set is to allow the case values to be defined in a const somewhere else. The reason that {nnkEmpty, nnkLiterals} doesn't work is because nnkLiterals isn't an enum value, it's a set:
BUG: the 1st
of {nnkIdent, nnkSym}:
is allowedthe 2nd one
of {nnkEmpty, nnkLiterals}:
is not allowed, giving compile errorseems like the 1st one should also give compiler error?
either way, it's inconsistent
/cc @mratsim I extracted this from your answer in #8531 (comment)
The text was updated successfully, but these errors were encountered: