Sorry, the checks are only applied to the ref/next/prev primitives and derived procedures.
I'll add checks for substring/cursors.

--
Alex

On Sat, Feb 1, 2020 at 12:00 AM Duy Nguyen <xxxxxx@gmail.com> wrote:
On Fri, Jan 31, 2020 at 10:32 PM Alex Shinn <xxxxxx@gmail.com> wrote:
>
> On Tue, Jan 28, 2020 at 6:48 PM Duy Nguyen <xxxxxx@gmail.com> wrote:
>>
>> In the SRFI, "cursors are opaque objects that point into strings"
>> gives me the impression that cursors are tied to the string they
>> should only be used with that string. Using them on a different string
>> is undefined/error behavior.
>
>
> Correct.  I believe the only implementation which enforces this is Chibi,
> and only if you specify the -Dsafe-string-cursors command-line option.
> Otherwise it will let you use cursors on different strings, which can
> give unexpected behavior including utf8 decoding exceptions.

Thanks. I'm considering adding something like that to Gauche but was
not sure about the option name :)

Do I do it right with this, though, because it does not seem to work,
the two strings from substring and string-index... should be different
unless chibi deduplicates strings somehow.

$ <env...> ./chibi-scheme  -Dsafe-string-cursors ~/t/def.scm
"bc"
$ cat ~/t/def.scm
(import (srfi 130) (scheme write) (scheme base))
(write
 (substring/cursors (string-append "a" "bc")
                    (string-index->cursor "abc" 1)
                    (string-index->cursor "abc" 3)))

--
Duy