tmethodcall.nim 433 B

12345678910111213141516171819202122232425
  1. # bug #5909
  2. type
  3. Vec2[T] = tuple
  4. x,y: T
  5. Vec2f = Vec2[float32]
  6. proc vec2f(x,y: float): Vec2f =
  7. result.x = x
  8. result.y = y
  9. proc `-`[T](a,b: Vec2[T]): Vec2[T] =
  10. result.x = a.x - b.x
  11. result.y = a.y - b.y
  12. proc foo[T](a: Vec2[T]): Vec2[T] =
  13. result = a
  14. block:
  15. # this being called foo is a problem when calling .foo()
  16. var foo = true
  17. let a = vec2f(1.0,0.0)
  18. let b = vec2f(3.0,1.0)
  19. let c = (a - b).foo() # breaks