From e7d404340628ef2ca6170744a7df33e20cd0fc1a Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Tue, 11 Sep 2018 17:03:21 +0200 Subject: [PATCH] Always emit hti object types if needed (#8940) The compiler is now smart enough to emit types only if needed without all the importc tricks. This also fixes a codegen bug where, if all the stars align correctly, typeinfo doesn't include any definition of `TNimType` but uses it. Found by @skilchen in #8938 --- lib/system/hti.nim | 2 +- tests/ccgbugs/thtiobj.nim | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 tests/ccgbugs/thtiobj.nim diff --git a/lib/system/hti.nim b/lib/system/hti.nim index bb3769ac46..9931fa11ed 100644 --- a/lib/system/hti.nim +++ b/lib/system/hti.nim @@ -11,7 +11,7 @@ when declared(ThisIsSystem): # we are in system module: {.pragma: codegenType, compilerproc.} else: - {.pragma: codegenType, importc.} + {.pragma: codegenType.} type # This should be the same as ast.TTypeKind diff --git a/tests/ccgbugs/thtiobj.nim b/tests/ccgbugs/thtiobj.nim new file mode 100644 index 0000000000..7a656905fb --- /dev/null +++ b/tests/ccgbugs/thtiobj.nim @@ -0,0 +1,8 @@ +discard """ + targets: "c cpp" +""" + +import typeinfo + +var x = "" +discard (getPointer(toAny(x)))