tbind1.nim 431 B

12345678910111213141516171819202122
  1. discard """
  2. file: "tbind1.nim"
  3. output: "3"
  4. """
  5. # Test the new ``bind`` keyword for templates
  6. proc p1(x: int8, y: int): int = return x + y
  7. template tempBind(x, y): untyped =
  8. bind p1
  9. p1(x, y)
  10. proc p1(x: int, y: int8): int = return x - y
  11. # This is tricky: the call to ``p1(1'i8, 2'i8)`` should not fail in line 6,
  12. # because it is not ambiguous there. But it is ambiguous after line 8.
  13. echo tempBind(1'i8, 2'i8) #OUT 3