From 3cbf59336d6b9838dbf534f8e55fdfc8e7ab6954 Mon Sep 17 00:00:00 2001 From: solo989 Date: Mon, 15 Jun 2020 00:15:17 -0700 Subject: [PATCH] Update newLit set[T] to work when set is empty. (#14662) * Update macros.nim * Update lib/core/macros.nim Co-authored-by: Clyybber Co-authored-by: Clyybber --- lib/core/macros.nim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/core/macros.nim b/lib/core/macros.nim index 3590a162bf77c..27ff063a76312 100644 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -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