Skip to content

Commit

Permalink
fixes #10075 [backport]
Browse files Browse the repository at this point in the history
(cherry picked from commit aa7ad88)
  • Loading branch information
Araq authored and narimiran committed Jan 14, 2019
1 parent 98cdfe0 commit e21b578
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
3 changes: 1 addition & 2 deletions compiler/sigmatch.nim
Expand Up @@ -2239,8 +2239,7 @@ proc matchesAux(c: PContext, n, nOrig: PNode,

if n.sons[a].kind == nkHiddenStdConv:
doAssert n.sons[a].sons[0].kind == nkEmpty and
n.sons[a].sons[1].kind == nkArgList and
n.sons[a].sons[1].len == 0
n.sons[a].sons[1].kind in {nkBracket, nkArgList}
# Steal the container and pass it along
setSon(m.call, formal.position + 1, n.sons[a].sons[1])
else:
Expand Down
31 changes: 30 additions & 1 deletion tests/macros/tvarargsuntyped.nim
Expand Up @@ -3,7 +3,9 @@ discard """
(left: 2, r: 7, x: 8, height: 4, s: test, width: 3, y: 9, top: 1, g: 7, b: 8)
(left: 2, r: 7, x: 8, height: 4, s: text, width: 3, y: 9, top: 1, g: 7, b: 8)
(left: 2, r: 7, x: 8, height: 4, s: text, width: 3, y: 9, top: 4, g: 7, b: 8)
(left: 2, r: 7, x: 8, height: 4, s: test, width: 3, y: 9, top: 1, g: 7, b: 8)'''
(left: 2, r: 7, x: 8, height: 4, s: test, width: 3, y: 9, top: 1, g: 7, b: 8)
10
hello 18.0'''
"""

import macros
Expand Down Expand Up @@ -78,3 +80,30 @@ let width: cint = 3
let height: cint = 4

bar(rect(top, left, width, height), "test", point(8, 9), color(7,7,8))


# bug #10075

import macros

proc convert_hidden_stdconv(args: NimNode): NimNode =
var n = args
while n.len == 1 and n[0].kind == nnkHiddenStdConv:
n = n[0][1]
return n

macro t2(s: int, v: varargs[untyped]): untyped =
let v = convert_hidden_stdconv(v)
echo v.treeRepr
let (v1, v2) = (v[0], v[1])
quote do:
echo `v1`, " ", `v2`

template t1(s: int, v: varargs[typed]) =
#static:
# dumpTree v
echo s
t2(s, v)

when isMainModule:
t1(10, "hello", 18.0)

0 comments on commit e21b578

Please sign in to comment.