summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorArne Döring <arne.doering@gmx.net>2019-12-04 08:33:01 +0100
committercooldome <cdome@bk.ru>2019-12-04 07:33:01 +0000
commitb0c06aa7110fc46d3158b620f07aba33b6cd9976 (patch)
tree8d8fe7852d637ac8438f6b64f8c8784b8600fb45 /compiler
parent3383985c44d6f9b1cd12160295134345e9c21830 (diff)
downloadNim-b0c06aa7110fc46d3158b620f07aba33b6cd9976.tar.gz
fix #12740 (#12774)
* fix #12740

* A different kind of a hack

* proper fix

* fix typo
Diffstat (limited to 'compiler')
-rw-r--r--compiler/renderer.nim23
1 files changed, 16 insertions, 7 deletions
diff --git a/compiler/renderer.nim b/compiler/renderer.nim
index 698d84de6..d9d4a9bc9 100644
--- a/compiler/renderer.nim
+++ b/compiler/renderer.nim
@@ -451,7 +451,11 @@ proc lsub(g: TSrcGen; n: PNode): int =
     result = lcomma(g, n, 0, - 3)
     if n[^2].kind != nkEmpty: result = result + lsub(g, n[^2]) + 2
     if n[^1].kind != nkEmpty: result = result + lsub(g, n[^1]) + 3
-  of nkVarTuple: result = lcomma(g, n, 0, - 3) + len("() = ") + lsub(g, lastSon(n))
+  of nkVarTuple:
+    if n[^1].kind == nkEmpty:
+      result = lcomma(g, n, 0, - 2) + len("()")
+    else:
+      result = lcomma(g, n, 0, - 3) + len("() = ") + lsub(g, lastSon(n))
   of nkChckRangeF: result = len("chckRangeF") + 2 + lcomma(g, n)
   of nkChckRange64: result = len("chckRange64") + 2 + lcomma(g, n)
   of nkChckRange: result = len("chckRange") + 2 + lcomma(g, n)
@@ -1119,12 +1123,17 @@ proc gsub(g: var TSrcGen, n: PNode, c: TContext) =
       putWithSpace(g, tkEquals, "=")
       gsub(g, n[^1], c)
   of nkVarTuple:
-    put(g, tkParLe, "(")
-    gcomma(g, n, 0, -3)
-    put(g, tkParRi, ")")
-    put(g, tkSpaces, Space)
-    putWithSpace(g, tkEquals, "=")
-    gsub(g, lastSon(n), c)
+    if n[^1].kind == nkEmpty:
+      put(g, tkParLe, "(")
+      gcomma(g, n, 0, -2)
+      put(g, tkParRi, ")")
+    else:
+      put(g, tkParLe, "(")
+      gcomma(g, n, 0, -3)
+      put(g, tkParRi, ")")
+      put(g, tkSpaces, Space)
+      putWithSpace(g, tkEquals, "=")
+      gsub(g, lastSon(n), c)
   of nkExprColonExpr:
     gsub(g, n, 0)
     putWithSpace(g, tkColon, ":")