summary refs log tree commit diff stats
path: root/tests/lookups
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2020-06-07 09:55:56 +0200
committerGitHub <noreply@github.com>2020-06-07 09:55:56 +0200
commit66c50c2ffcfdd31f9f1eecfaf23b1b58b22d3a36 (patch)
tree6b20a4fea12283ae5ec7f08004f7dc4bca3ba6e8 /tests/lookups
parent51b71e35f2c0000def4f35d65ceb28ecdeb7ee10 (diff)
downloadNim-66c50c2ffcfdd31f9f1eecfaf23b1b58b22d3a36.tar.gz
implement the 'bind' statement for generics, it was an oversight that this was never implemented (#14584)
Diffstat (limited to 'tests/lookups')
-rw-r--r--tests/lookups/tbind_for_generics.nim17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/lookups/tbind_for_generics.nim b/tests/lookups/tbind_for_generics.nim
new file mode 100644
index 000000000..db5fbebbc
--- /dev/null
+++ b/tests/lookups/tbind_for_generics.nim
@@ -0,0 +1,17 @@
+discard """
+  errormsg: "type mismatch: got <Foo, Foo>"
+  line: 8
+"""
+proc g[T](x: T) =
+  bind `+`
+  # because we bind `+` here, we must not find the `+` for 'Foo' below:
+  echo x + x
+
+type
+  Foo = object
+    a: int
+
+proc `+`(a, b: Foo): Foo = Foo(a: a.a+b.a)
+
+g(3)
+g(Foo(a: 8))