accept object type node from macros (#19179)
This commit is contained in:
parent
a59ad20062
commit
f91867aa31
2 changed files with 17 additions and 1 deletions
16
tests/macros/ttypenodes.nim
Normal file
16
tests/macros/ttypenodes.nim
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import macros
|
||||
|
||||
macro makeEnum(): untyped =
|
||||
newTree(nnkEnumTy, newEmptyNode(), ident"a", ident"b", ident"c")
|
||||
|
||||
macro makeObject(): untyped =
|
||||
newTree(nnkObjectTy, newEmptyNode(), newEmptyNode(), newTree(nnkRecList,
|
||||
newTree(nnkIdentDefs, ident"x", ident"y", ident"int", newEmptyNode())))
|
||||
|
||||
type
|
||||
Foo = makeEnum()
|
||||
Bar = makeObject()
|
||||
|
||||
doAssert {a, b, c} is set[Foo]
|
||||
let bar = Bar(x: 3, y: 4)
|
||||
doAssert (bar.x, bar.y) == (3, 4)
|
||||
Loading…
Add table
Add a link
Reference in a new issue