Skip to content

Commit

Permalink
[testcase] genSym fails to make unique identifier for ref object types (
Browse files Browse the repository at this point in the history
#19506)

close #15118
  • Loading branch information
ringabout committed Feb 14, 2022
1 parent 8e8231f commit 2ef71c0
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions tests/macros/tmacros_various.nim
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ x: some string
([("key", "val"), ("keyB", "2")], [("val", "key"), ("2", "keyB")])
([("key", "val"), ("keyB", "2")], [("val", "key"), ("2", "keyB")])
0
0
0
'''
"""

Expand Down Expand Up @@ -270,3 +272,61 @@ block: # bug #13511

debugAst:
add(foo(), component)

block: # bug #15118
macro flop(name: static string) =
let id = genSym(nskType, "env")
let r =
nnkStmtList.newTree(
nnkTypeSection.newTree(
nnkTypeDef.newTree(
id,
newEmptyNode(),
nnkRefTy.newTree(
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
nnkRecList.newTree(
nnkIdentDefs.newTree(
newIdentNode(name),
newIdentNode("int"),
newEmptyNode()
)
)
)
)
)
),

# var f: T

nnkVarSection.newTree(
nnkIdentDefs.newTree(
newIdentNode("f"),
id,
newEmptyNode()
)
),

# echo f.a
nnkCommand.newTree(
newIdentNode("new"),
newIdentNode("f")
),

nnkCommand.newTree(
newIdentNode("echo"),
nnkDotExpr.newTree(
newIdentNode("f"),
newIdentNode(name)
)
)
)
r


block:
flop("a")

block:
flop("b")

0 comments on commit 2ef71c0

Please sign in to comment.