summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorArne Döring <arne.doering@gmx.net>2018-11-09 12:15:00 +0100
committerGitHub <noreply@github.com>2018-11-09 12:15:00 +0100
commit573d02760ecf38082c5bae0bdc2b42e4c9f5e0d7 (patch)
tree1536cdd0a7555d9db715ea6eeaa484427825fb9a /lib
parent130c218ff9e6349060b83114b425be7d3fe4241a (diff)
downloadNim-573d02760ecf38082c5bae0bdc2b42e4c9f5e0d7.tar.gz
newLit works on enum (#9662)
* newLit works on enum

* remove debugging echo
Diffstat (limited to 'lib')
-rw-r--r--lib/core/macros.nim10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/core/macros.nim b/lib/core/macros.nim
index a146117d0..3011eaa67 100644
--- a/lib/core/macros.nim
+++ b/lib/core/macros.nim
@@ -696,6 +696,16 @@ proc newLit*[T](arg: seq[T]): NimNode {.compileTime.} =
     ),
     bracket
   )
+proc newLit*(arg: enum): NimNode {.compileTime.} =
+  result = newCall(
+    arg.type.getTypeInst[1],
+    newLit(int(arg))
+  )
+
+proc newLit*[T](s: set[T]): NimNode {.compileTime.} =
+  result = nnkCurly.newTree
+  for x in s:
+    result.add newLit(x)
 
 proc newLit*(arg: tuple): NimNode {.compileTime.} =
   result = nnkPar.newTree