summary refs log tree commit diff stats
path: root/tests/template/t9534.nim
diff options
context:
space:
mode:
authorflywind <xzsflywind@gmail.com>2021-04-01 14:47:59 +0800
committerGitHub <noreply@github.com>2021-04-01 08:47:59 +0200
commit6f53579a8ceb7576fb1b31f72c9d584916b4b5d9 (patch)
tree53e0de75ae04f0179d3180c0555cca8d8fca1754 /tests/template/t9534.nim
parenta7bb973a24fb73d378230216a6bfcfd2f62e4e78 (diff)
downloadNim-6f53579a8ceb7576fb1b31f72c9d584916b4b5d9.tar.gz
close #9534 add testcase (#17607)
Diffstat (limited to 'tests/template/t9534.nim')
-rw-r--r--tests/template/t9534.nim21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/template/t9534.nim b/tests/template/t9534.nim
new file mode 100644
index 000000000..8d66f42a0
--- /dev/null
+++ b/tests/template/t9534.nim
@@ -0,0 +1,21 @@
+discard """
+  targets: "c cpp"
+"""
+
+# bug #9534
+type
+  Object = object
+    data: int
+
+template test() =
+  proc methodName(o: Object): int =
+    var p: pointer
+    doAssert o.data == 521
+    let f {.used.} = cast[proc (o: int): int {.nimcall.}](p)
+    doAssert o.data == 521
+    result = 1314
+
+  var a = Object(data: 521)
+  doAssert methodName(a) == 1314
+
+test()