Add sfGenSym for (_).

This commit is contained in:
Dominik Picheta
2015-04-23 00:29:16 +01:00
parent 9e69e4e078
commit f0f0062a5d
2 changed files with 22 additions and 12 deletions

View File

@@ -442,6 +442,8 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
var v = semIdentDef(c, a.sons[j], symkind)
if sfGenSym notin v.flags and
not isDiscardUnderscore(a.sons[j]): addInterfaceDecl(c, v)
if isDiscardUnderscore(a.sons[j]):
v.flags.incl(sfGenSym)
when oKeepVariableNames:
if c.inUnrolledContext > 0: v.flags.incl(sfShadowed)
else:

View File

@@ -3,19 +3,27 @@ discard """
output: ""
exitcode: 0
"""
proc foo(): tuple[x, y, z: int] =
return (4, 2, 3)
var (x, _, y) = foo()
doAssert x == 4
doAssert y == 3
proc main() =
var (a, _, _) = foo()
doAssert a == 4
proc foo(): tuple[x, y, z: int] =
return (4, 2, 3)
iterator bar(): tuple[x, y, z: int] =
yield (1,2,3)
var (x, _, y) = foo()
doAssert x == 4
doAssert y == 3
for x, y, _ in bar():
doAssert x == 1
doAssert y == 2
var (a, _, _) = foo()
doAssert a == 4
var (a, _, _xx) = foo()
doAssert a == 4
iterator bar(): tuple[x, y, z: int] =
yield (1,2,3)
for x, y, _ in bar():
doAssert x == 1
doAssert y == 2
main()