File: tinferlambdareturn.nim

package info (click to toggle)
nim 2.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,911,644 kB
  • sloc: sh: 24,603; ansic: 1,761; python: 1,492; makefile: 1,013; sql: 298; asm: 141; xml: 13
file content (36 lines) | stat: -rw-r--r-- 928 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import std/[sugar, sequtils]

block: # issue #23200
  proc dosomething(iter: int -> (iterator: int)) =
    discard
  proc dosomething(iter: int -> seq[int]) =
    discard
  proc makeSeq(x: int): seq[int] =
    @[x]
  # Works fine with 1.6.12 and 1.6.14
  dosomething(makeSeq)
  # Works with 1.6.12, fails with 1.6.14
  dosomething((y) => makeSeq(y))
  dosomething(proc (y: auto): auto = makeSeq(y))
  proc foo(y: auto): auto = makeSeq(y)
  dosomething(foo)

block: # issue #18866
  proc somefn[T](list: openarray[T], op: proc (v: T): float) =
    discard op(list[0])

  type TimeD = object
    year:  Natural
    month: 1..12
    day:   1..31

  doAssert not compiles(@[TimeD()].somefn(proc (v: auto): auto =
    v
  ))
  @[TimeD()].somefn(proc (v: auto): auto =
    v.year.float
  )
  proc foo(v: auto): auto = v
  doAssert not compiles(@[TimeD()].somefn(foo))
  proc bar(v: auto): auto = v.year.float
  @[TimeD()].somefn(bar)