summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2016-01-26 16:24:15 +0100
committerAndreas Rumpf <rumpf_a@web.de>2016-01-26 16:24:15 +0100
commit1a2867146b7af5871d9e9d1a926aa88cba193cfd (patch)
tree757d7055485309a0dafa056dee28520308a7d296 /compiler
parent1fbeedaba25af170bfb3ad00de1ccad1f8da1546 (diff)
downloadNim-1a2867146b7af5871d9e9d1a926aa88cba193cfd.tar.gz
make rendering of typeof operator clearer; refs #3710
Diffstat (limited to 'compiler')
-rw-r--r--compiler/renderer.nim6
1 files changed, 4 insertions, 2 deletions
diff --git a/compiler/renderer.nim b/compiler/renderer.nim
index 8e4aa1831..34688c798 100644
--- a/compiler/renderer.nim
+++ b/compiler/renderer.nim
@@ -438,7 +438,7 @@ proc lsub(n: PNode): int =
         len("if_:_")
   of nkElifExpr: result = lsons(n) + len("_elif_:_")
   of nkElseExpr: result = lsub(n.sons[0]) + len("_else:_") # type descriptions
-  of nkTypeOfExpr: result = (if n.len > 0: lsub(n.sons[0]) else: 0)+len("type_")
+  of nkTypeOfExpr: result = (if n.len > 0: lsub(n.sons[0]) else: 0)+len("type()")
   of nkRefTy: result = (if n.len > 0: lsub(n.sons[0])+1 else: 0) + len("ref")
   of nkPtrTy: result = (if n.len > 0: lsub(n.sons[0])+1 else: 0) + len("ptr")
   of nkVarTy: result = (if n.len > 0: lsub(n.sons[0])+1 else: 0) + len("var")
@@ -1030,8 +1030,10 @@ proc gsub(g: var TSrcGen, n: PNode, c: TContext) =
     putWithSpace(g, tkColon, ":")
     gsub(g, n.sons[0])
   of nkTypeOfExpr:
-    putWithSpace(g, tkType, "type")
+    put(g, tkType, "type")
+    put(g, tkParLe, "(")
     if n.len > 0: gsub(g, n.sons[0])
+    put(g, tkParRi, ")")
   of nkRefTy:
     if sonsLen(n) > 0:
       putWithSpace(g, tkRef, "ref")