summary refs log tree commit diff stats
path: root/lib/pure
diff options
context:
space:
mode:
authorMiran <narimiran@disroot.org>2019-03-13 15:59:09 +0100
committerAndreas Rumpf <rumpf_a@web.de>2019-03-13 15:59:09 +0100
commit84d3f3d448aa59c86084c94b9a71435529ba48cd (patch)
treeccf33b235c8ad5ff4fdb8aaa57bc7f0776f896ab /lib/pure
parentb270917de1d5fbda2f5d4127e1513793a88391d3 (diff)
downloadNim-84d3f3d448aa59c86084c94b9a71435529ba48cd.tar.gz
move system.dollars in a separate file (#10829)
Diffstat (limited to 'lib/pure')
-rw-r--r--lib/pure/typetraits.nim18
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/pure/typetraits.nim b/lib/pure/typetraits.nim
index b6cbaf558..940b5e9fe 100644
--- a/lib/pure/typetraits.nim
+++ b/lib/pure/typetraits.nim
@@ -10,10 +10,6 @@
 ## This module defines compile-time reflection procs for
 ## working with types.
 
-include "system/helpers" # for `isNamedTuple`
-
-export system.`$`
-export isNamedTuple
 
 proc name*(t: typedesc): string {.magic: "TypeTrait".}
   ## Returns the name of the given type.
@@ -63,6 +59,20 @@ proc supportsCopyMem*(t: typedesc): bool {.magic: "TypeTrait".}
   ##
   ## Other languages name a type like these `blob`:idx:.
 
+proc isNamedTuple*(T: typedesc): bool =
+  ## Return true for named tuples, false for any other type.
+  when T isnot tuple: result = false
+  else:
+    var t: T
+    for name, _ in t.fieldPairs:
+      when name == "Field0":
+        return compiles(t.Field0)
+      else:
+        return true
+    # empty tuple should be un-named,
+    # see https://github.com/nim-lang/Nim/issues/8861#issue-356631191
+    return false
+
 
 when isMainModule:
   static: