Update newLit set[T] to work when set is empty. (#14662)

* Update macros.nim

* Update lib/core/macros.nim

Co-authored-by: Clyybber <darkmine956@gmail.com>

Co-authored-by: Clyybber <darkmine956@gmail.com>
This commit is contained in:
solo989
2020-06-15 00:15:17 -07:00
committed by GitHub
parent 571bc011ea
commit 3cbf59336d

View File

@@ -793,6 +793,10 @@ proc newLit*[T](s: set[T]): NimNode {.compileTime.} =
result = nnkCurly.newTree
for x in s:
result.add newLit(x)
if result.len == 0:
# add type cast for empty set
var typ = getTypeInst(typeof(s))[1]
result = newCall(typ,result)
proc newLit*(arg: tuple): NimNode {.compileTime.} =
result = nnkPar.newTree