mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-31 10:22:15 +00:00
failing test case demonstrating how generic arguments are preferred to
openarray and varargs arguments
This commit is contained in:
26
tests/run/tvarargs_vs_generic.nim
Normal file
26
tests/run/tvarargs_vs_generic.nim
Normal file
@@ -0,0 +1,26 @@
|
||||
discard """
|
||||
output: "direct\nopenarray\nvarargs"
|
||||
"""
|
||||
|
||||
proc withDirectType(args: string) =
|
||||
echo "direct"
|
||||
|
||||
proc withDirectType[T](arg: T) =
|
||||
echo "generic"
|
||||
|
||||
proc withOpenArray(args: openarray[string]) =
|
||||
echo "openarray"
|
||||
|
||||
proc withOpenArray[T](arg: T) =
|
||||
echo "generic"
|
||||
|
||||
proc withVarargs(args: varargs[string]) =
|
||||
echo "varargs"
|
||||
|
||||
proc withVarargs[T](arg: T) =
|
||||
echo "generic"
|
||||
|
||||
withDirectType "string"
|
||||
withOpenArray "string"
|
||||
withVarargs "string"
|
||||
|
||||
Reference in New Issue
Block a user