summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2016-07-08 10:52:04 +0200
committerAndreas Rumpf <rumpf_a@web.de>2016-07-08 10:52:04 +0200
commit857b0c8d4c79d44fc0580df4658d1b17121dceed (patch)
tree4432240f3f992716af4abb85d17204c2174739f1
parentb47d9b7b917202ab3b7f1632f8d9462c5f76e869 (diff)
downloadNim-857b0c8d4c79d44fc0580df4658d1b17121dceed.tar.gz
fixes #4462
-rw-r--r--compiler/vmgen.nim8
-rw-r--r--tests/vm/tvmmisc.nim12
2 files changed, 16 insertions, 4 deletions
diff --git a/compiler/vmgen.nim b/compiler/vmgen.nim
index b8c206bb3..abb88b7b9 100644
--- a/compiler/vmgen.nim
+++ b/compiler/vmgen.nim
@@ -518,9 +518,9 @@ proc genCall(c: PCtx; n: PNode; dest: var TDest) =
   # varargs need 'opcSetType' for the FFI support:
   let fntyp = skipTypes(n.sons[0].typ, abstractInst)
   for i in 0.. <n.len:
-    if i > 0 and i < sonsLen(fntyp):
-      let paramType = fntyp.n.sons[i]
-      if paramType.typ.isCompileTimeOnly: continue
+    #if i > 0 and i < sonsLen(fntyp):
+    #  let paramType = fntyp.n.sons[i]
+    #  if paramType.typ.isCompileTimeOnly: continue
     var r: TRegister = x+i
     c.gen(n.sons[i], r)
     if i >= fntyp.len:
@@ -1797,6 +1797,8 @@ proc gen(c: PCtx; n: PNode; dest: var TDest; flags: TGenFlags = {}) =
       genConv(c, n, n.sons[1], dest, opcCast)
     else:
       globalError(n.info, errGenerated, "VM is not allowed to 'cast'")
+  of nkTypeOfExpr:
+    genTypeLit(c, n.typ, dest)
   else:
     globalError(n.info, errGenerated, "cannot generate VM code for " & $n)
 
diff --git a/tests/vm/tvmmisc.nim b/tests/vm/tvmmisc.nim
index e935013c4..b7112b099 100644
--- a/tests/vm/tvmmisc.nim
+++ b/tests/vm/tvmmisc.nim
@@ -1,5 +1,15 @@
 
-# 4412
+
+# bug #4462
+import macros
+
+proc foo(t: typedesc) {.compileTime.} =
+  echo getType(t).treeRepr
+
+static:
+  foo(int)
+
+# #4412
 proc default[T](t: typedesc[T]): T {.inline.} = discard
 
 static: