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
commit 3cbf59336d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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