bugfix: allow tuple constructors in generic code
This commit is contained in:
parent
7e44015491
commit
698785ef5e
2 changed files with 7 additions and 0 deletions
|
|
@ -306,6 +306,9 @@ proc semGenericStmt(c: PContext, n: PNode,
|
||||||
n.sons[bodyPos] = semGenericStmtScope(c, body, flags, toBind)
|
n.sons[bodyPos] = semGenericStmtScope(c, body, flags, toBind)
|
||||||
closeScope(c.tab)
|
closeScope(c.tab)
|
||||||
of nkPragma, nkPragmaExpr: nil
|
of nkPragma, nkPragmaExpr: nil
|
||||||
|
of nkExprColonExpr:
|
||||||
|
checkMinSonsLen(n, 2)
|
||||||
|
result.sons[1] = semGenericStmt(c, n.sons[1], flags, toBind)
|
||||||
else:
|
else:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in countup(0, sonsLen(n) - 1):
|
||||||
result.sons[i] = semGenericStmt(c, n.sons[i], flags, toBind)
|
result.sons[i] = semGenericStmt(c, n.sons[i], flags, toBind)
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,16 @@ discard """
|
||||||
import typetraits
|
import typetraits
|
||||||
|
|
||||||
proc plus(a, b): auto = a + b
|
proc plus(a, b): auto = a + b
|
||||||
|
proc makePair(a, b): auto = (first: a, second: b)
|
||||||
|
|
||||||
proc `+`(a, b: string): seq[string] = @[a, b]
|
proc `+`(a, b: string): seq[string] = @[a, b]
|
||||||
|
|
||||||
var i = plus(10, 20)
|
var i = plus(10, 20)
|
||||||
var s = plus("A", "B")
|
var s = plus("A", "B")
|
||||||
|
|
||||||
|
var p = makePair("key", 100)
|
||||||
|
static: assert p[0].type is string
|
||||||
|
|
||||||
echo i.type.name
|
echo i.type.name
|
||||||
echo s.type.name
|
echo s.type.name
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue