From 9c42ae91b735bda29de9afbc1333da52a85b3297 Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Thu, 18 Jun 2020 13:36:45 -0700 Subject: add legacy workaround; improve test so that it actually tests for the bugfix --- lib/core/macros.nim | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/core/macros.nim b/lib/core/macros.nim index 04a85d355..1b0986d33 100644 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -801,12 +801,14 @@ proc newLit*[T](s: set[T]): NimNode {.compileTime.} = result = newCall(typ,result) proc isNamedTuple(T: typedesc): bool {.magic: "TypeTrait".} - ## See typetraits.isNamedTuple + ## See `typetraits.isNamedTuple` proc newLit*[T: tuple](arg: T): NimNode {.compileTime.} = + ## use -d:nimHasWorkaround14720 to restore behavior prior to PR, forcing + ## a named tuple even when `arg` is unnamed. result = nnkTupleConstr.newTree - when isNamedTuple(T): - for a,b in arg.fieldPairs: + when defined(nimHasWorkaround14720) or isNamedTuple(T): + for a, b in arg.fieldPairs: result.add nnkExprColonExpr.newTree(newIdentNode(a), newLit(b)) else: for b in arg.fields: -- cgit 1.4.1-2-gfad0