summary refs log tree commit diff stats
path: root/tests/overload/tparam_forwarding.nim
blob: b0eea42c7142a6e006ef25b24f20c2260822fefd (plain) (blame)
1
2
3
4
5
6
7
8
9
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .g
discard """
output: '''baz
10
100
1000
a
b
c
x: 1, y: test 1
x: 2, y: test 2
x: 10, y: test 3
x: 4, y: test 4
'''
"""

type
  Foo = object
    x: int

proc stringVarargs*(strings:
ss="n">void = for s in strings: echo s proc fooVarargs*(foos: varargs[Foo]) = for f in foos: echo f.x template templateForwarding*(callable: untyped, condition: bool, forwarded: varargs[untyped]): untyped = if condition: callable(forwarded) proc procForwarding(args: varargs[string]) = stringVarargs(args) templateForwarding stringVarargs, 17 + 4 < 21, "foo", "bar", 100 templateForwarding stringVarargs, 10 < 21, "baz" templateForwarding fooVarargs, "test".len > 3, Foo(x: 10), Foo(x: 100), Foo(x: 1000) procForwarding "a", "b", "c" proc hasKeywordArgs(x = 10, y = "y") = echo "x: ", x, ", y: ", y proc hasRegularArgs(x: int, y: string) = echo "x: ", x, ", y: ", y templateForwarding(hasRegularArgs, true, 1, "test 1") templateForwarding hasKeywordArgs, true, 2, "test 2" templateForwarding(hasKeywordArgs, true, y = "test 3") templateForwarding hasKeywordArgs, true, y = "test 4", x = 4