bug#79479: Issue with substring/shared
Nikolaos Chatzikonstantinou <[email protected]> Thu, 9 Oct 2025 13:32:06 -0400
| Newsgroups | gmane.lisp.guile.bugs |
|---|---|
| Message-ID | <CAAQmekc0SpKEtiRWdDd_1kjnwHSyvAVfZ-8y3DozES1zRDxPEg@mail.gmail.com> |
On Thu, Oct 9, 2025 at 11:24=E2=80=AFAM Nikolaos Chatzikonstantinou <[email protected]> wrote: > > On Thu, Oct 9, 2025 at 7:26=E2=80=AFAM Nikolaos Chatzikonstantinou > <[email protected]> wrote: > > > > On Sun, Sep 21, 2025 at 12:47=E2=80=AFAM Nikolaos Chatzikonstantinou > > <[email protected]> wrote: > > > > > > Hello bug-guile, > > > > > > I have a structure (srfi srfi-9 gnu) that keeps parts of strings in a > > > binary tree (it's a rope). The intention was to have it immutable, so > > > I used substring/shared. I kept getting errors on my unit tests when = I > > > referenced individual characters; I could not replicate these errors > > > on the REPL. Eventually I realized that substring/shared caused them. > > > > I want to offer a small (<100 LoC) reproducible example now. I'm using > > 3.0.10. Try to run the test suite with autocompilation disabled > > (--no-auto-compile), and you should get failure (if success, try > > running again, rarely it succeeds.) If you compile the test.scm file, > > then it should work fine. > > > > I am not sure that I can figure this one out myself further, but > > somehow it is related to my projects tests being left uncompiled. Does > > anyone have an insight to the problem here? > > Here is an even smaller reproducible example [..] I rounded it down to a one-liner: ---------------------test.scm--------------------- (use-modules (ice-9 local-eval)) (let ((proc (local-compile '(lambda (s) (string-ref s 0)) (the-environment))) (s (local-compile '(substring/shared "hello" 0 2) (the-environment)))) (format #t "This should print #\\h but instead it prints: ~S~%" (proc s))) ------------------end of test.scm----------------- If you then do `guile --no-auto-compile test.scm` you will see that #\nul is printed instead of #\h. Note that moving `substring/shared` into another local-compile will make the above work as expected instead. Regards, Nikolaos Chatzikonstantinou