tforwardgeneric.nim 637 B

1234567891011121314151617181920212223242526272829
  1. discard """
  2. output: "1.1 11\n42\n0"
  3. ccodecheck: "!@'ClEnv'"
  4. """
  5. proc p[T](a, b: T): T
  6. echo p(0.9, 0.1), " ", p(9, 1)
  7. proc p[T](a, b: T): T =
  8. let c = b
  9. result = a + b + c
  10. # https://github.com/nim-lang/Nim/issues/4908
  11. proc foo(t: typedesc[int]): int
  12. proc bar(): int = foo(int)
  13. proc foo(t: typedesc[int]): int =
  14. return 0
  15. # https://github.com/nim-lang/Nim/issues/4104
  16. proc print[T](t: T) # Error: implementation of 'print.print(t: int)' expected
  17. print 42 # moving this line after the implementation fixes the error,
  18. # but such behaviour makes forward declaration pointless
  19. proc print[T](t: T) =
  20. echo t
  21. echo bar()