Files
Nim/tests/vm/tissues.nim
Timothee Cour 6ce3949c8a add isNamedTuple; make $(1, 2) be (1, 2) instead of (Field0: 1, Field1: 2) which leaked implementation detail (#10070)
* add `isNamedTuple`; make $(1, 2) be (1, 2) instead of leaking implementation detail (Field0: 1, Field1: 2)
  fixes this: #8670 (comment) /cc @alehander42 @Vindaar @mratsim

* Note: isNamedTuple is useful in other places, eg #10010 (comment)

* move isNamedTuple to helpers.nim to avoid exposing new symbol to system.nim

* remove workaround in tests/vm/tissues.nim failing test now that #10218 was makes it work
2019-01-08 18:37:25 -08:00

29 lines
631 B
Nim

import macros
block t9043: # issue #9043
proc foo[N: static[int]](dims: array[N, int]): string =
const N1 = N
const N2 = dims.len
const ret = $(N, dims.len, N1, N2)
static: doAssert ret == $(N, dims.len, N1, N2)
ret
doAssert foo([1, 2]) == "(2, 2, 2, 2)"
block t4952:
proc doCheck(tree: NimNode) =
let res: tuple[n: NimNode] = (n: tree)
assert: tree.kind == res.n.kind
for sub in tree:
doCheck(sub)
macro id(body: untyped): untyped =
doCheck(body)
id(foo((i: int)))
static:
let tree = newTree(nnkExprColonExpr)
let t = (n: tree)
assert: t.n.kind == tree.kind