summary refs log tree commit diff stats
path: root/tests/lookups/tbind_for_generics.nim
blob: db5fbebbc562ddd5ad6d34fc3ecd311c0f6d80d0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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))