mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-18 13:30:33 +00:00
fixes #24141
This commit is contained in:
@@ -511,7 +511,12 @@ proc transformAddrDeref(c: PTransf, n: PNode, kinds: TNodeKinds): PNode =
|
||||
if n[0].kind in kinds and
|
||||
not (n[0][0].kind == nkSym and n[0][0].sym.kind == skForVar and
|
||||
n[0][0].typ.skipTypes(abstractVar).kind == tyTuple
|
||||
): # elimination is harmful to `for tuple unpack` because of newTupleAccess
|
||||
) and not (n[0][0].kind == nkSym and n[0][0].sym.kind == skParam and
|
||||
n.typ.kind == tyVar and
|
||||
n.typ.skipTypes(abstractVar).kind == tyOpenArray and
|
||||
n[0][0].typ.skipTypes(abstractVar).kind == tyString)
|
||||
: # elimination is harmful to `for tuple unpack` because of newTupleAccess
|
||||
# it is also harmful to openArrayLoc (var openArray) for strings
|
||||
# addr ( deref ( x )) --> x
|
||||
result = n[0][0]
|
||||
if n.typ.skipTypes(abstractVar).kind != tyOpenArray:
|
||||
|
||||
@@ -820,3 +820,17 @@ block: # bug #23973
|
||||
doAssert t == a
|
||||
|
||||
n()
|
||||
|
||||
block: # bug #24141
|
||||
func reverse(s: var openArray[char]) =
|
||||
s[0] = 'f'
|
||||
|
||||
func rev(s: var string) =
|
||||
s.reverse
|
||||
|
||||
proc main =
|
||||
var abc = "abc"
|
||||
abc.rev
|
||||
doAssert abc == "fbc"
|
||||
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user