Skip to content

Commit

Permalink
Update newLit set[T] to work when set is empty. (nim-lang#14662)
Browse files Browse the repository at this point in the history
* Update macros.nim

* Update lib/core/macros.nim

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

Co-authored-by: Clyybber <darkmine956@gmail.com>
  • Loading branch information
solo989 and Clyybber authored Jun 15, 2020
1 parent 571bc01 commit 3cbf593
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/core/macros.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3cbf593

Please sign in to comment.