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
This commit is contained in:
Timothee Cour 2019-01-08 18:37:25 -08:00 • committed by GitHub
commit 6ce3949c8a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 113 additions and 23 deletions

View file

@ -1,7 +1,7 @@
discard """
output:'''
void
(Field0: "string", Field1: "string")
("string", "string")
1 mod 7
@[2, 2, 2, 2, 2]
impl 2 called

View file

@ -1,3 +1,18 @@
# todo: merge with $nimc_D/tests/metatype/ttypetraits.nim (currently disabled)
from typetraits import `$` # checks fix for https://github.com/c-blake/cligen/issues/84
import typetraits
block: # isNamedTuple
type Foo1 = (a:1,).type
type Foo2 = (Field0:1,).type
type Foo3 = ().type
type Foo4 = object
doAssert (a:1,).type.isNamedTuple
doAssert Foo1.isNamedTuple
doAssert Foo2.isNamedTuple
doAssert not Foo3.isNamedTuple
doAssert not Foo4.isNamedTuple
doAssert not (1,).type.isNamedTuple