diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2023-03-02 08:36:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-02 08:36:02 +0100 |
commit | 50baf21eacfaf1c9d6949bf2b2e9f931b0e1509c (patch) | |
tree | aabb4a67bbac56d530ab6f7fa828b7a17fd27eb9 /tests/arc | |
parent | 612abda4f40b2a0fd8dd0e4ad119c4415b9c34cb (diff) | |
download | Nim-50baf21eacfaf1c9d6949bf2b2e9f931b0e1509c.tar.gz |
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
Diffstat (limited to 'tests/arc')
-rw-r--r-- | tests/arc/topenarray.nim | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/arc/topenarray.nim b/tests/arc/topenarray.nim index 47c26a11f..0e45f3ec7 100644 --- a/tests/arc/topenarray.nim +++ b/tests/arc/topenarray.nim @@ -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" |