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:
parent
571bc011ea
commit
3cbf59336d
1 changed files with 4 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue