nimhcr_2_1.nim 760 B

123456789101112131415161718192021222324252627282930313233
  1. import hotcodereloading
  2. type
  3. Type2 = ref object of RootObj
  4. data*: int
  5. let g_2* = @[Type2(data: 2), Type2(data: 3)][1..^1] # should have a length of 1
  6. const c_2* = [1, 2, 3] # testing that a complext const object is properly exported
  7. var a: tuple[str: string, i: int]
  8. a.str = " 2: random string"
  9. echo a.str
  10. beforeCodeReload:
  11. echo " 2: before!"
  12. # testing a construct of 2 functions in the same module which reference each other
  13. # https://github.com/nim-lang/Nim/issues/11608
  14. proc rec_1(depth: int)
  15. proc rec_2(depth: int) =
  16. rec_1(depth + 1)
  17. proc rec_1(depth: int) =
  18. if depth < 3:
  19. rec_2(depth)
  20. else:
  21. echo("max mutual recursion reached!")
  22. # https://github.com/nim-lang/Nim/issues/11996
  23. let rec_2_func_ref = rec_2
  24. rec_2_func_ref(0)