From 505ae14f4bcb265d9d6b115849c5bb5e36a1fabc Mon Sep 17 00:00:00 2001 From: xzfc Date: Tue, 9 Oct 2018 19:51:34 +0700 Subject: [PATCH] Codegen fix for procs taking type(nil) (#9231) --- compiler/ccgtypes.nim | 2 +- tests/ccgbugs/tnil_type.nim | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 tests/ccgbugs/tnil_type.nim 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