tclosure_issues.nim 881 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. discard """
  2. output: '''true'''
  3. """
  4. block tissue600:
  5. for i in 1..1:
  6. var reported = false
  7. proc report() =
  8. reported = true
  9. import sequtils
  10. block tissue1502def:
  11. let xs: seq[tuple[key: string, val: seq[string]]] = @[("foo", @["bar"])]
  12. let maps = xs.map(
  13. proc(x: auto): tuple[typ: string, maps: seq[string]] =
  14. (x.key, x.val.map(proc(x: string): string = x)))
  15. block tissue1642:
  16. var i = 0
  17. proc p() = inc(i)
  18. block tissue1846:
  19. type
  20. TBinOp[T] = proc (x,y: T): bool
  21. THeap[T] = object
  22. cmp: TBinOp[T]
  23. proc less[T](x,y: T): bool =
  24. x < y
  25. proc initHeap[T](cmp: TBinOp[T]): THeap[T] =
  26. result.cmp = cmp
  27. var h = initHeap[int](less[int])
  28. echo h.cmp(2,3)
  29. block tissue1911:
  30. proc foo(x: int) : auto =
  31. proc helper() : int = x
  32. proc bar() : int = helper()
  33. proc baz() : int = helper()
  34. return (bar, baz)