summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorxzfc <xzfc@users.noreply.github.com>2018-10-09 19:51:34 +0700
committerAndreas Rumpf <rumpf_a@web.de>2018-10-09 14:51:34 +0200
commit505ae14f4bcb265d9d6b115849c5bb5e36a1fabc (patch)
tree0eefa6b6f1c911db578e5cc6b939f076e165a1b0
parentb8d2f79ef094a3b825866a155d795e6c2b4a6c6a (diff)
downloadNim-505ae14f4bcb265d9d6b115849c5bb5e36a1fabc.tar.gz
Codegen fix for procs taking type(nil) (#9231)
-rw-r--r--compiler/ccgtypes.nim2
-rw-r--r--tests/ccgbugs/tnil_type.nim6
2 files changed, 7 insertions, 1 deletions
diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim
index 56a4704f9..8ae050605 100644
--- a/compiler/ccgtypes.nim
+++ b/compiler/ccgtypes.nim
@@ -290,7 +290,7 @@ proc getSimpleTypeDesc(m: BModule, typ: PType): Rope =
   of tyCString: result = typeNameOrLiteral(m, typ, "NCSTRING")
   of tyBool: result = typeNameOrLiteral(m, typ, "NIM_BOOL")
   of tyChar: result = typeNameOrLiteral(m, typ, "NIM_CHAR")
-  of tyNil: result = typeNameOrLiteral(m, typ, "0")
+  of tyNil: result = typeNameOrLiteral(m, typ, "void*")
   of tyInt..tyUInt64:
     result = typeNameOrLiteral(m, typ, NumericalTypeToStr[typ.kind])
   of tyDistinct, tyRange, tyOrdinal: result = getSimpleTypeDesc(m, typ.sons[0])
diff --git a/tests/ccgbugs/tnil_type.nim b/tests/ccgbugs/tnil_type.nim
new file mode 100644
index 000000000..44ecf1cc9
--- /dev/null
+++ b/tests/ccgbugs/tnil_type.nim
@@ -0,0 +1,6 @@
+discard """
+  targets: "c cpp"
+"""
+
+proc foo(v: type(nil)) = discard
+foo nil