tinferlambdareturn.nim 928 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import std/[sugar, sequtils]
  2. block: # issue #23200
  3. proc dosomething(iter: int -> (iterator: int)) =
  4. discard
  5. proc dosomething(iter: int -> seq[int]) =
  6. discard
  7. proc makeSeq(x: int): seq[int] =
  8. @[x]
  9. # Works fine with 1.6.12 and 1.6.14
  10. dosomething(makeSeq)
  11. # Works with 1.6.12, fails with 1.6.14
  12. dosomething((y) => makeSeq(y))
  13. dosomething(proc (y: auto): auto = makeSeq(y))
  14. proc foo(y: auto): auto = makeSeq(y)
  15. dosomething(foo)
  16. block: # issue #18866
  17. proc somefn[T](list: openarray[T], op: proc (v: T): float) =
  18. discard op(list[0])
  19. type TimeD = object
  20. year: Natural
  21. month: 1..12
  22. day: 1..31
  23. doAssert not compiles(@[TimeD()].somefn(proc (v: auto): auto =
  24. v
  25. ))
  26. @[TimeD()].somefn(proc (v: auto): auto =
  27. v.year.float
  28. )
  29. proc foo(v: auto): auto = v
  30. doAssert not compiles(@[TimeD()].somefn(foo))
  31. proc bar(v: auto): auto = v.year.float
  32. @[TimeD()].somefn(bar)