tdefaultprocparam.nim 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. discard """
  2. output: '''
  3. hi
  4. hi
  5. topLevel|topLevel|
  6. topLevel2|topLevel2|
  7. inProc|inProc|
  8. inProc2|inProc2|
  9. topLevel|9
  10. topLevel2|10
  11. inProc|7
  12. inProc2|8
  13. must have been the wind..
  14. I'm there
  15. must have been the wind..
  16. I'm there
  17. symbol'a'symbol'a'
  18. symbol'b'symbol'b'
  19. symbol'a'symbol'b'
  20. symbol'a'9
  21. symbol'b'9
  22. symbol'a'0
  23. '''
  24. """
  25. import mdefaultprocparam
  26. p()
  27. proc testP =
  28. p()
  29. testP()
  30. proc p2(s: string, count = s): string = s & count
  31. proc testP2 =
  32. echo p2 """inProc|"""
  33. echo p2 """inProc2|"""
  34. echo p2 """topLevel|"""
  35. echo p2 """topLevel2|"""
  36. testP2()
  37. import macros
  38. macro dTT(a: typed) = echo a.treeRepr
  39. proc p3(s: string, count = len(s)): string = s & $count
  40. proc testP3 =
  41. echo p3 """inProc|"""
  42. echo p3 """inProc2|"""
  43. echo p3 """topLevel|"""
  44. echo p3 """topLevel2|"""
  45. testP3()
  46. proc cut(s: string, c = len(s)): string =
  47. s[0..<s.len-c]
  48. echo "must have been the wind.." & cut "I'm gone"
  49. echo cut("I'm gone", 4) & "there"
  50. proc testCut =
  51. echo "must have been the wind.." & cut "I'm gone"
  52. echo cut("I'm gone", 4) & "there"
  53. testCut()
  54. var a = "symbol'a'"
  55. var b = "symbol'b'"
  56. block:
  57. echo p2(a)
  58. block:
  59. echo p2(b)
  60. block:
  61. echo p2(a, b)
  62. block:
  63. echo p3(a)
  64. echo p3(b)
  65. echo p3(a, 0)
  66. # bug #12252
  67. proc foo(a = 0, b = a.high, c = high(typeof(a))) =
  68. discard
  69. foo()
  70. import std/strformat
  71. block: # issue #18074
  72. proc somefn[T](query: string, _: type[T], message = query) = discard
  73. somefn(fmt"", string)