Merge branch 'devel' of github.com:nim-lang/Nim into devel
This commit is contained in:
commit
65f69d5515
3 changed files with 42 additions and 2 deletions
|
|
@ -1651,7 +1651,7 @@ proc matchesAux(c: PContext, n, nOrig: PNode,
|
||||||
if a >= formalLen-1 and formal != nil and formal.typ.isVarargsUntyped:
|
if a >= formalLen-1 and formal != nil and formal.typ.isVarargsUntyped:
|
||||||
incl(marker, formal.position)
|
incl(marker, formal.position)
|
||||||
if container.isNil:
|
if container.isNil:
|
||||||
container = newNodeIT(nkBracket, n.sons[a].info, arrayConstr(c, n.info))
|
container = newNodeIT(nkArgList, n.sons[a].info, arrayConstr(c, n.info))
|
||||||
setSon(m.call, formal.position + 1, container)
|
setSon(m.call, formal.position + 1, container)
|
||||||
else:
|
else:
|
||||||
incrIndexType(container.typ)
|
incrIndexType(container.typ)
|
||||||
|
|
@ -1739,7 +1739,7 @@ proc matchesAux(c: PContext, n, nOrig: PNode,
|
||||||
|
|
||||||
if formal.typ.isVarargsUntyped:
|
if formal.typ.isVarargsUntyped:
|
||||||
if container.isNil:
|
if container.isNil:
|
||||||
container = newNodeIT(nkBracket, n.sons[a].info, arrayConstr(c, n.info))
|
container = newNodeIT(nkArgList, n.sons[a].info, arrayConstr(c, n.info))
|
||||||
setSon(m.call, formal.position + 1, container)
|
setSon(m.call, formal.position + 1, container)
|
||||||
else:
|
else:
|
||||||
incrIndexType(container.typ)
|
incrIndexType(container.typ)
|
||||||
|
|
|
||||||
37
tests/overload/tparam_forwarding.nim
Normal file
37
tests/overload/tparam_forwarding.nim
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
discard """
|
||||||
|
output: '''baz
|
||||||
|
10
|
||||||
|
100
|
||||||
|
1000
|
||||||
|
a
|
||||||
|
b
|
||||||
|
c
|
||||||
|
'''
|
||||||
|
"""
|
||||||
|
|
||||||
|
type
|
||||||
|
Foo = object
|
||||||
|
x: int
|
||||||
|
|
||||||
|
proc stringVarargs*(strings: varargs[string, `$`]): 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"
|
||||||
|
|
||||||
|
|
@ -23,6 +23,9 @@ Changes affecting backwards compatibility
|
||||||
pointer. Now the hash is calculated from the contents of the string, assuming
|
pointer. Now the hash is calculated from the contents of the string, assuming
|
||||||
``cstring`` is a null-terminated string. Equal ``string`` and ``cstring``
|
``cstring`` is a null-terminated string. Equal ``string`` and ``cstring``
|
||||||
values produce an equal hash value.
|
values produce an equal hash value.
|
||||||
|
- Macros accepting `varargs` arguments will now receive a node having the
|
||||||
|
`nkArgList` node kind. Previous code expecting the node kind to be `nkBracket`
|
||||||
|
may have to be updated.
|
||||||
- ``memfiles.open`` now closes file handleds/fds by default. Passing
|
- ``memfiles.open`` now closes file handleds/fds by default. Passing
|
||||||
``allowRemap=true`` to ``memfiles.open`` recovers the old behavior. The old
|
``allowRemap=true`` to ``memfiles.open`` recovers the old behavior. The old
|
||||||
behavior is only needed to call ``mapMem`` on the resulting ``MemFile``.
|
behavior is only needed to call ``mapMem`` on the resulting ``MemFile``.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue