StringStreams no longer errors when intialized with literals on arc/orc (#19708)

(cherry picked from commit 26acc97864)
This commit is contained in:
Jason Beetham
2022-04-11 06:27:12 -06:00
committed by narimiran
parent d38177b11f
commit fcd05bd031
2 changed files with 4 additions and 0 deletions

View File

@@ -1271,6 +1271,8 @@ else: # after 1.3 or JS not defined
new(result)
result.data = s
when defined(gcOrc) or defined(gcArc):
prepareMutation(result.data) # Allows us to mutate using `addr` logic like `copyMem`, otherwise it errors.
result.pos = 0
result.closeImpl = ssClose
result.atEndImpl = ssAtEnd

View File

@@ -74,3 +74,5 @@ block:
doAssert(ss.peekLine(str))
doAssert(str == "uick brown fox jumped over the lazy dog.")
doAssert(ss.getPosition == 5) # haven't moved
ss.setPosition(0) # Ensure we dont error with writing over literals on arc/orc #19707
ss.write("hello")