File: tpointerprocs.nim

package info (click to toggle)
nim 2.2.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,951,164 kB
  • sloc: sh: 24,599; ansic: 1,771; python: 1,493; makefile: 1,013; sql: 298; asm: 141; xml: 13
file content (35 lines) | stat: -rw-r--r-- 976 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
discard """
cmd: "nim check $options --hints:off $file"
action: "reject"
nimout:'''
tpointerprocs.nim(22, 11) Error: 'foo' doesn't have a concrete type, due to unspecified generic parameters.
tpointerprocs.nim(34, 14) Error: type mismatch: got <int>
but expected one of:
proc foo(x: int | float; y: int or string): float
  first type mismatch at position: 2 in generic parameters
  missing generic parameter: y:type

expression: foo[int]
tpointerprocs.nim(34, 14) Error: cannot instantiate: 'foo[int]'
tpointerprocs.nim(34, 14) Error: expression 'foo[int]' has no type (or is ambiguous)
tpointerprocs.nim(35, 11) Error: expression 'bar' has no type (or is ambiguous)
'''
"""

block:
  proc foo(x: int | float): float = result = 1.0
  let
    bar = foo
    baz = bar

block:
  proc foo(x: int | float): float = result = 1.0
  let
    bar = foo[int]
    baz = bar

block:
  proc foo(x: int | float, y: int or string): float = result = 1.0
  let
    bar = foo[int]
    baz = bar