summary refs log tree commit diff stats
path: root/tests/lookups/tbind_for_generics.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lookups/tbind_for_generics.nim')
-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))