Generic pointer procs now error if no types supplied (#18832)
* more precise logic for pointer procs * added test for generic pointer procs * Fixed generic getting bracket expr if erroring
This commit is contained in:
parent
66e53bdd7b
commit
5d1608c976
3 changed files with 30 additions and 2 deletions
28
tests/generics/tpointerprocs.nim
Normal file
28
tests/generics/tpointerprocs.nim
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
discard """
|
||||
cmd: "nim check $options --hints:off $file"
|
||||
action: "reject"
|
||||
nimout:'''
|
||||
tpointerprocs.nim(15, 11) Error: 'foo' doesn't have a concrete type, due to unspecified generic parameters.
|
||||
tpointerprocs.nim(27, 11) Error: cannot instantiate: 'foo[int]'; got 1 typeof(s) but expected 2
|
||||
tpointerprocs.nim(27, 14) Error: expression 'foo[int]' has no type (or is ambiguous)
|
||||
tpointerprocs.nim(28, 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue