From 1df5cfba52ccc71e3c69b6cd7d08cebd70bbb187 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Sat, 12 Sep 2020 23:11:38 +0200 Subject: [PATCH] fixes #15147 (#15315) --- compiler/varpartitions.nim | 2 +- tests/arc/topt_no_cursor.nim | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/compiler/varpartitions.nim b/compiler/varpartitions.nim index bbde68cbe5..87424c4bea 100644 --- a/compiler/varpartitions.nim +++ b/compiler/varpartitions.nim @@ -396,7 +396,7 @@ proc deps(c: var Partitions; dest, src: PNode) = (src.sym.kind in {skLet, skParam, skForVar} and hasDisabledAsgn(src.sym.typ))): c.s[vid].flags.incl preventCursor - if hasDestructor(src.typ): + if src.kind == nkSym and hasDestructor(src.typ): rhsIsSink(c, src) proc traverse(c: var Partitions; n: PNode) = diff --git a/tests/arc/topt_no_cursor.nim b/tests/arc/topt_no_cursor.nim index fe63e7585e..8a33cb2ee6 100644 --- a/tests/arc/topt_no_cursor.nim +++ b/tests/arc/topt_no_cursor.nim @@ -171,3 +171,24 @@ proc encodedQuery = elem.tt() encodedQuery() + +# bug #15147 + +proc s(input: string): (string, string) = + result = (";", "") + +proc charmatch(input: string): (string, string) = + result = ("123", input[0 .. input.high]) + +proc plus(input: string) = + var + lvalue, rvalue: string # cursors + lnext: string # must be cursor!!! + rnext: string # cursor + let lresult = charmatch(input) + (lvalue, lnext) = lresult + + let rresult = s(lnext) + (rvalue, rnext) = rresult + +plus("123;")