fixes #26088; StringStream.write regression (#26089)

fixes #26088
 
in https://github.com/nim-lang/Nim/pull/25772, `beginStores` requires
`newLen` to be passed for setting up the new length. So `streams.nim`
must make the string length exactly newLen.
This commit is contained in:
ringabout
2026-08-10 13:39:04 +08:00
committed by GitHub
parent 0ec8682abe
commit 708d9311e8
3 changed files with 23 additions and 1 deletions

View File

@@ -87,6 +87,20 @@ block:
ss.setPosition(0)
doAssert(ss.peekStr(5) == "hello")
# bug #26088 - Overwriting a string stream must not truncate it
block:
var short = newStringStream("0123456789ABCDEF")
short.setPosition(0)
short.write("XX")
doAssert short.data == "XX23456789ABCDEF"
doAssert not short.atEnd
var long = newStringStream("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")
long.setPosition(0)
long.write("XX")
doAssert long.data == "XX23456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
doAssert not long.atEnd
# bug #19716
static: # Ensure streams it doesnt break with nimscript on arc/orc #19716
let s = newStringStream("a")