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 /compiler/ccgexprs.nim | |
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 'compiler/ccgexprs.nim')
-rw-r--r-- | compiler/ccgexprs.nim | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index fe7cb252e..f428324b7 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -2408,7 +2408,10 @@ proc genDispose(p: BProc; n: PNode) = lineCg(p, cpsStmts, ["#nimDestroyAndDispose($#)", rdLoc(a)]) proc genSlice(p: BProc; e: PNode; d: var TLoc) = - let (x, y) = genOpenArraySlice(p, e, e.typ, e.typ.lastSon) + let (x, y) = genOpenArraySlice(p, e, e.typ, e.typ.lastSon, + prepareForMutation = e[1].kind == nkHiddenDeref and + e[1].typ.skipTypes(abstractInst).kind == tyString and + p.config.selectedGC in {gcArc, gcOrc}) if d.k == locNone: getTemp(p, e.typ, d) linefmt(p, cpsStmts, "$1.Field0 = $2; $1.Field1 = $3;$n", [rdLoc(d), x, y]) when false: |