summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2016-12-22 16:43:37 +0100
committerAraq <rumpf_a@web.de>2016-12-22 16:43:37 +0100
commit0ef6815529a59d4dfd7bd15a87b24dde7d4456b0 (patch)
tree6ca11dba21695a9a10478b9bf7610c358a437247 /tests
parent237e2664e0f4f091bc7d1d288291287440f41fbd (diff)
downloadNim-0ef6815529a59d4dfd7bd15a87b24dde7d4456b0.tar.gz
fixes #5140
Diffstat (limited to 'tests')
-rw-r--r--tests/cpp/tdont_init_instantiation.nim28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/cpp/tdont_init_instantiation.nim b/tests/cpp/tdont_init_instantiation.nim
new file mode 100644
index 000000000..7d4bf322a
--- /dev/null
+++ b/tests/cpp/tdont_init_instantiation.nim
@@ -0,0 +1,28 @@
+discard """
+  cmd: "nim cpp $file"
+  output: ''''''
+"""
+
+# bug #5140
+{.emit:"""
+#import <cassert>
+
+template <typename X> class C {
+  public:
+    int d;
+
+    C(): d(1) { }
+
+    C<X>& operator=(const C<X> other) {
+      assert(d == 1);
+    }
+};
+""".}
+
+type C{.importcpp, header: "<stdio.h>", nodecl.} [X] = object
+proc mkC[X]: C[X] {.importcpp: "C<'*0>()", constructor, nodecl.}
+
+proc foo(): C[int] =
+  result = mkC[int]()
+
+discard foo()