diff options
author | Arne Döring <arne.doering@gmx.net> | 2018-11-09 12:15:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-09 12:15:00 +0100 |
commit | 573d02760ecf38082c5bae0bdc2b42e4c9f5e0d7 (patch) | |
tree | 1536cdd0a7555d9db715ea6eeaa484427825fb9a /lib | |
parent | 130c218ff9e6349060b83114b425be7d3fe4241a (diff) | |
download | Nim-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.nim | 10 |
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 |