fixes #20422; emit nimPrepareStrMutationV2 for toOpenArray to keep th… (#21459)

fixes #20422; emit nimPrepareStrMutationV2 for toOpenArray to keep the abstraction of mutable strings which have immutable string literals
This commit is contained in:
Andreas Rumpf 2023-03-02 08:36:02 +01:00 • committed by GitHub
commit 50baf21eac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 2 deletions

View file

@ -6,6 +6,8 @@ Nim
'''
matrix: "--gc:arc -d:useMalloc; --gc:arc"
"""
{.experimental: "views".}
block: # bug 18627
proc setPosition(params: openArray[string]) =
for i in params.toOpenArray(0, params.len - 1):
@ -38,3 +40,13 @@ block: # bug #20954
var v: seq[int]
echo len(toOpenArray(v, 20, 30))
# bug #20422
proc f(a: var string) =
var v = a.toOpenArray(1, 3)
v[0] = 'a'
var a = "Hello"
f(a)
doAssert a == "Hallo"