The following code crashes the console:
data: " 123 "
repend data [trim data]
If trim is removed, it works as expected.
See also https://github.com/red/red/issues/3340
Temporary workaround:
data: " 123 "
append data reduce [trim data]
== "123123"
Minimal code to reproduce the crash:
data: " 123 "
insert tail data reduce [trim data]
Caused by insert not handling properly the case of same string series used for both arguments.
Crash happens in string/alter in:
if mode = MODE_INSERT [
move-memory
(as byte-ptr! s1/offset) + h1 + offset + size
(as byte-ptr! s1/offset) + h1 + offset
(as-integer s1/tail - s1/offset) - h1
]
The last argument to move-memory is negative (-6 in above case), because trim data makes the tail data reference become "past-end".
The fix for this issue should be part of the general solution for handling past-end series internally.
@hiiamboris I will process the pending PRs once the lexer branch is merged into master.