fixes #26143; Possible memory error (#26154)

fixes #26143

follows up https://github.com/nim-lang/Nim/pull/20307

(cherry picked from commit c36c527db3)
This commit is contained in:
ringabout
2026-08-29 04:26:18 +08:00
committed by narimiran
parent a84ae6f833
commit cf683229e9
2 changed files with 37 additions and 18 deletions

View File

@@ -35,6 +35,20 @@ proc bug20303() =
bug20303()
block: # bug #26143
var indexCalls = 0
proc nextIndex(): int =
result = indexCalls
inc indexCalls
proc consume(value: sink string) =
doAssert value == "A"
var values = @["A", "B"]
consume(values[nextIndex()])
doAssert indexCalls == 1
proc main() = # todo bug with templates
block: # bug #11267
var a: seq[char] = block: @[]