This commit returns to a bit less strict checking of the number of macro arguments, because some old immediate macros rely on a behavior where even the arity of the macro is not being checked. It may be better if such macros are just declared to use varargs[expr], but this remains for another day.
This commit is contained in:
parent
6e358e3187
commit
1be0022e7c
17 changed files with 134 additions and 4 deletions
17
tests/errmsgs/t5167_1.nim
Normal file
17
tests/errmsgs/t5167_1.nim
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
discard """
|
||||
errormsg: "'bar' doesn't have a concrete type, due to unspecified generic parameters."
|
||||
line: 16
|
||||
"""
|
||||
|
||||
proc foo[T]() =
|
||||
var y1 = foo[string]
|
||||
var y2 = foo[T]
|
||||
|
||||
proc bar[T]() =
|
||||
let x = 0
|
||||
|
||||
let good1 = foo[int]
|
||||
let good2 = bar[int]
|
||||
|
||||
let err = bar
|
||||
|
||||
12
tests/errmsgs/t5167_2.nim
Normal file
12
tests/errmsgs/t5167_2.nim
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
discard """
|
||||
cmd: "nim c --threads:on $file"
|
||||
errormsg: "'threadFunc' doesn't have a concrete type, due to unspecified generic parameters."
|
||||
line: 11
|
||||
"""
|
||||
|
||||
proc threadFunc[T]() {.thread.} =
|
||||
let x = 0
|
||||
|
||||
var thr: Thread[void]
|
||||
thr.createThread(threadFunc)
|
||||
|
||||
25
tests/errmsgs/t5167_3.nim
Normal file
25
tests/errmsgs/t5167_3.nim
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
discard """
|
||||
cmd: "nim c --threads:on $file"
|
||||
errormsg: "type mismatch"
|
||||
line: 24
|
||||
"""
|
||||
|
||||
type
|
||||
TGeneric[T] = object
|
||||
x: int
|
||||
|
||||
proc foo1[A, B, C, D](x: proc (a: A, b: B, c: C, d: D)) =
|
||||
echo "foo1"
|
||||
|
||||
proc foo2(x: proc(x: int)) =
|
||||
echo "foo2"
|
||||
|
||||
# The goal of this test is to verify that none of the generic parameters of the
|
||||
# proc will be marked as unused. The error message should be "type mismatch" instead
|
||||
# of "'bar' doesn't have a concrete type, due to unspecified generic parameters".
|
||||
proc bar[A, B, C, D](x: A, y: seq[B], z: array[4, TGeneric[C]], r: TGeneric[D]) =
|
||||
echo "bar"
|
||||
|
||||
foo1[int, seq[int], array[4, TGeneric[float]], TGeneric[string]] bar
|
||||
foo2 bar
|
||||
|
||||
20
tests/errmsgs/t5167_4.nim
Normal file
20
tests/errmsgs/t5167_4.nim
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
discard """
|
||||
errormsg: "type mismatch: got (proc [*missing parameters*](x: int) | proc (x: string){.gcsafe, locks: 0.})"
|
||||
line: 19
|
||||
"""
|
||||
|
||||
type
|
||||
TGeneric[T] = object
|
||||
x: int
|
||||
|
||||
proc foo[B](x: int) =
|
||||
echo "foo1"
|
||||
|
||||
proc foo(x: string) =
|
||||
echo "foo2"
|
||||
|
||||
proc bar(x: proc (x: int)) =
|
||||
echo "bar"
|
||||
|
||||
bar foo
|
||||
|
||||
25
tests/errmsgs/t5167_5.nim
Normal file
25
tests/errmsgs/t5167_5.nim
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
discard """
|
||||
cmd: "nim check $file"
|
||||
errormsg: "'m' has unspecified generic parameters"
|
||||
nimout: '''
|
||||
t5167_5.nim(20, 9) Error: 't' has unspecified generic parameters
|
||||
t5167_5.nim(21, 5) Error: 't' has unspecified generic parameters
|
||||
t5167_5.nim(23, 9) Error: 'm' has unspecified generic parameters
|
||||
t5167_5.nim(24, 5) Error: 'm' has unspecified generic parameters
|
||||
'''
|
||||
"""
|
||||
|
||||
template t[B]() =
|
||||
echo "foo1"
|
||||
|
||||
macro m[T]: stmt = nil
|
||||
|
||||
proc bar(x: proc (x: int)) =
|
||||
echo "bar"
|
||||
|
||||
let x = t
|
||||
bar t
|
||||
|
||||
let y = m
|
||||
bar m
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue