improve test

This commit is contained in:
Andrii Riabushenko 2018-12-07 22:25:32 +00:00
commit 43c70a6b12
2 changed files with 17 additions and 8 deletions

View file

@ -441,7 +441,11 @@ proc pArg(arg: PNode; c: var Con; isSink: bool): PNode =
elif arg.kind == nkSym and isSinkParam(arg.sym): elif arg.kind == nkSym and isSinkParam(arg.sym):
# mark the sink parameter as used: # mark the sink parameter as used:
result = destructiveMoveSink(arg, c) result = destructiveMoveSink(arg, c)
elif arg.kind in {nkStmtListExpr, nkBlockExpr, nkBlockStmt}: elif arg.kind in {nkBlockExpr, nkBlockStmt}:
result = copyNode(arg)
result.add arg[0]
result.add pArg(arg[1], c, isSink)
elif arg.kind == nkStmtListExpr:
result = copyNode(arg) result = copyNode(arg)
for i in 0..arg.len-2: for i in 0..arg.len-2:
result.add p(arg[i], c) result.add p(arg[i], c)

View file

@ -116,7 +116,12 @@ proc myfunc2(x, y: int): tuple[a: MySeqNonCopyable, b:int, c:MySeqNonCopyable] =
elif x > 5: raise newException(ValueError, "new error") elif x > 5: raise newException(ValueError, "new error")
else: newMySeq(x, 1.0), else: newMySeq(x, 1.0),
b: 0, b: 0,
c: if y > 0: move(cc) else: newMySeq(1, 3.0)) c: block:
var tmp = if y > 0: move(cc) else: newMySeq(1, 3.0)
tmp[0] = 5
tmp
)
let (seq1, seq2) = myfunc(2, 3) let (seq1, seq2) = myfunc(2, 3)
doAssert seq1.len == 2 doAssert seq1.len == 2