tgenerictmpl2.nim 507 B

1234567891011121314151617181920212223242526272829303132
  1. discard """
  2. output: '''1
  3. 1
  4. 1
  5. 1
  6. 999
  7. 999
  8. 999
  9. 2'''
  10. """
  11. # test if we can pass explicit generic arguments to generic templates
  12. # based on bug report #3496
  13. proc tproc[T](t: T = 999) = echo t
  14. template ttmpl[T](t: T = 999) = echo t
  15. tproc(1)
  16. tproc[int](1)
  17. ttmpl(1)
  18. ttmpl[int](1) #<- crash case #1
  19. tproc[int]()
  20. discard tproc[int]
  21. ttmpl[int]() #<- crash case #2
  22. ttmpl[int] #<- crash case #3
  23. # but still allow normal use of [] on non-generic templates
  24. template tarr: untyped = [1, 2, 3, 4]
  25. echo tarr[1]