summary refs log tree commit diff stats
path: root/tests/template
diff options
context:
space:
mode:
authorcooldome <ariabushenko@bk.ru>2018-06-06 23:41:19 +0100
committercooldome <ariabushenko@bk.ru>2018-06-06 23:41:19 +0100
commite03b3bdde75f5e82f9c5512fcd00033704de4a34 (patch)
treeca562440f4c978a3c060524fe1fe7c01f5069a02 /tests/template
parentbf394ed1a1d27d8d38d4bc386946e3442736cd75 (diff)
downloadNim-e03b3bdde75f5e82f9c5512fcd00033704de4a34.tar.gz
fixes 7980
Diffstat (limited to 'tests/template')
-rw-r--r--tests/template/tpattern_with_converter.nim27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/template/tpattern_with_converter.nim b/tests/template/tpattern_with_converter.nim
new file mode 100644
index 000000000..e0632552b
--- /dev/null
+++ b/tests/template/tpattern_with_converter.nim
@@ -0,0 +1,27 @@
+discard """
+  output: 10.0
+"""
+
+type
+  MyFloat = object
+    val: float
+
+converter to_myfloat*(x: float): MyFloat {.inline.} =
+  MyFloat(val: x)
+
+proc `+`(x1, x2: MyFloat): MyFloat =
+  MyFloat(val: x1.val + x2.val)
+
+proc `*`(x1, x2: MyFloat): MyFloat =
+    MyFloat(val: x1.val * x2.val)
+
+template optMul{`*`(a, 2.0)}(a: MyFloat): MyFloat =
+  a + a
+
+func floatMyFloat(x: MyFloat): MyFloat =
+  result = x * 2.0
+
+func floatDouble(x: float): float =
+  result = x * 2.0
+
+echo floatDouble(5)
\ No newline at end of file