summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2020-06-18 13:36:45 -0700
committerAndreas Rumpf <rumpf_a@web.de>2020-06-19 09:53:06 +0200
commit9c42ae91b735bda29de9afbc1333da52a85b3297 (patch)
treeb482018131516e2d7cf8db841c537c7f63c51e03 /lib
parent408518c9fed9757fd1cc246e3ced05ecbb3bcaab (diff)
downloadNim-9c42ae91b735bda29de9afbc1333da52a85b3297.tar.gz
add legacy workaround; improve test so that it actually tests for the bugfix
Diffstat (limited to 'lib')
-rw-r--r--lib/core/macros.nim8
1 files changed, 5 insertions, 3 deletions
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: