introduce nkTupleConstr AST node for unary tuple construction; breaking change
This commit is contained in:
parent
ab426faa22
commit
47335aab41
26 changed files with 91 additions and 56 deletions
|
|
@ -1,7 +1,10 @@
|
|||
discard """
|
||||
output: '''61, 125'''
|
||||
output: '''61, 125
|
||||
(Field0: 0) (Field0: 13)'''
|
||||
"""
|
||||
|
||||
import macros
|
||||
|
||||
proc `^` (a, b: int): int =
|
||||
result = 1
|
||||
for i in 1..b: result = result * a
|
||||
|
|
@ -12,3 +15,12 @@ var n = (56, 3)
|
|||
m = (n[0] + m[1], m[1] ^ n[1])
|
||||
|
||||
echo m[0], ", ", m[1]
|
||||
|
||||
# also test we can produce unary anon tuples in a macro:
|
||||
macro mm(): untyped =
|
||||
result = newTree(nnkTupleConstr, newLit(13))
|
||||
|
||||
proc nowTuple(): (int,) =
|
||||
result = (0,)
|
||||
|
||||
echo nowTuple(), " ", mm()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue