Re: subseq behaviour if end is out of range? not an error for vectors

Shiro Kawai <[email protected]> Fri, 8 May 2026 00:20:15 -1000
Newsgroups gmane.lisp.scheme.gauche
Message-ID <CALN0JNH3sA35crVeVVbcegDLRtqwmG_+HFvBCEjfnEcRJY8A0Q@mail.gmail.com>
--===============6311566837782248709==
Content-Type: multipart/alternative; boundary="000000000000cce94806514bbe99"

--000000000000cce94806514bbe99
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Fix pushed.   It is because vector-copy explicitly allows out-of-bound
start/end, and subseq delegated to it unconditionally.  Now subseq checks
the range.


On Thu, May 7, 2026 at 11:51=E2=80=AFPM Shiro Kawai <[email protected]>=
 wrote:

> I think that's due to my sloppiness.  I think it should raise an error,
> for the silently returning garbage is worse.
>
>
>
> On Thu, May 7, 2026 at 9:09=E2=80=AFPM Jens Thiele <[email protected]> wrote=
:
>
>> Hi,
>>
>> The manual doesn't define the behaviour of subseq if end is out of range
>> but I was suprised by the behaviour with vectors:
>> $ src/gosh -ftest -V
>> Gauche scheme shell, version 0.9.16_pre2 [utf-8,pthreads],
>> x86_64-pc-linux-gnu
>> (version "0.9.16_pre2")
>> (command "gosh")
>> (scheme.id gauche)
>> (languages scheme r5rs r7rs)
>> (encodings utf-8)
>> (website "https://practical-scheme.net/gauche")
>> (build.platform "x86_64-pc-linux-gnu")
>> (build.configure)
>> (build.gosh-version "0.9.16_pre2")
>> (scheme.path "/tmp/Gauche/src/../lib" "/tmp/Gauche/src/../libsrc"
>> "/tmp/Gauche/src/../src" "/usr/local/share/gauche-0.98/site/lib"
>> "/usr/local/share/gauche-0.98/0.9.16_pre2/lib")
>> (threads pthreads)
>> (gauche.net.tls)
>> $ src/gosh -ftest
>> gosh$ (use gauche.sequence)
>> gosh$ (use gauche.uvector)
>> gosh$ (subseq '(0) 0 2)
>> *** ASSERTION-VIOLATION: v is supposed to be of type pair, but got ()
>> Stack Trace:
>> _______________________________________
>>   0  (report-error e)
>>   1  (next)
>>   2  (add! (next))
>>   3  (eval expr env)
>>         at "/tmp/Gauche/src/../lib/gauche/interactive.scm":407
>>   4  (evaluator exp (vm-current-module))
>>   5  (with-error-handler (^e (report-error e) #t) (^ () (let loop2 ...
>> gosh$ (subseq #u8(0) 0 2)
>> *** ERROR: end argument out of range: 2
>> Stack Trace:
>> _______________________________________
>>   0  (report-error e)
>>   1  (eval expr env)
>>         at "/tmp/Gauche/src/../lib/gauche/interactive.scm":407
>>   2  (evaluator exp (vm-current-module))
>>   3  (with-error-handler (^e (report-error e) #t) (^ () (let loop2 ...
>> gosh$ (subseq #*0 0 2)
>> *** ERROR: end argument out of range: 2
>> Stack Trace:
>> _______________________________________
>>   0  (report-error e)
>>   1  (eval expr env)
>>         at "/tmp/Gauche/src/../lib/gauche/interactive.scm":407
>>   2  (evaluator exp (vm-current-module))
>>   3  (with-error-handler (^e (report-error e) #t) (^ () (let loop2 ...
>> gosh$ (subseq #(0) 0 2)
>> #(0 #<undef>)
>>
>> jens
>>
>>
>> _______________________________________________
>> Gauche-devel mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/gauche-devel
>>
>

--000000000000cce94806514bbe99
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_default" style=3D"font-size:large">Fix=
 pushed.=C2=A0 =C2=A0It is because vector-copy explicitly allows out-of-bou=
nd start/end, and subseq delegated to it unconditionally.=C2=A0 Now subseq =
checks the range.</div><div class=3D"gmail_default" style=3D"font-size:larg=
e"><br></div></div><br><div class=3D"gmail_quote gmail_quote_container"><di=
v dir=3D"ltr" class=3D"gmail_attr">On Thu, May 7, 2026 at 11:51=E2=80=AFPM =
Shiro Kawai &lt;<a href=3D"mailto:[email protected]">shiro.kawai@gmail.=
com</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"marg=
in:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1e=
x"><div dir=3D"ltr"><div class=3D"gmail_default" style=3D"font-size:large">=
I think that&#39;s due to my sloppiness.=C2=A0 I think it should raise an e=
rror, for the silently returning garbage is worse.</div><div class=3D"gmail=
_default" style=3D"font-size:large"><br></div><div class=3D"gmail_default" =
style=3D"font-size:large"><br></div></div><br><div class=3D"gmail_quote"><d=
iv dir=3D"ltr" class=3D"gmail_attr">On Thu, May 7, 2026 at 9:09=E2=80=AFPM =
Jens Thiele &lt;<a href=3D"mailto:[email protected]" target=3D"_blank">karme@k=
arme.de</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"=
margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-lef=
t:1ex">Hi,<br>
<br>
The manual doesn&#39;t define the behaviour of subseq if end is out of rang=
e<br>
but I was suprised by the behaviour with vectors:<br>
$ src/gosh -ftest -V<br>
Gauche scheme shell, version 0.9.16_pre2 [utf-8,pthreads], x86_64-pc-linux-=
gnu<br>
(version &quot;0.9.16_pre2&quot;)<br>
(command &quot;gosh&quot;)<br>
(<a href=3D"http://scheme.id" rel=3D"noreferrer" target=3D"_blank">scheme.i=
d</a> gauche)<br>
(languages scheme r5rs r7rs)<br>
(encodings utf-8)<br>
(website &quot;<a href=3D"https://practical-scheme.net/gauche" rel=3D"noref=
errer" target=3D"_blank">https://practical-scheme.net/gauche</a>&quot;)<br>
(build.platform &quot;x86_64-pc-linux-gnu&quot;)<br>
(build.configure)<br>
(build.gosh-version &quot;0.9.16_pre2&quot;)<br>
(scheme.path &quot;/tmp/Gauche/src/../lib&quot; &quot;/tmp/Gauche/src/../li=
bsrc&quot; &quot;/tmp/Gauche/src/../src&quot; &quot;/usr/local/share/gauche=
-0.98/site/lib&quot; &quot;/usr/local/share/gauche-0.98/0.9.16_pre2/lib&quo=
t;)<br>
(threads pthreads)<br>
(gauche.net.tls)<br>
$ src/gosh -ftest<br>
gosh$ (use gauche.sequence)<br>
gosh$ (use gauche.uvector)<br>
gosh$ (subseq &#39;(0) 0 2)<br>
*** ASSERTION-VIOLATION: v is supposed to be of type pair, but got ()<br>
Stack Trace:<br>
_______________________________________<br>
=C2=A0 0=C2=A0 (report-error e)<br>
=C2=A0 1=C2=A0 (next)<br>
=C2=A0 2=C2=A0 (add! (next))<br>
=C2=A0 3=C2=A0 (eval expr env)<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 at &quot;/tmp/Gauche/src/../lib/gauche/interact=
ive.scm&quot;:407<br>
=C2=A0 4=C2=A0 (evaluator exp (vm-current-module))<br>
=C2=A0 5=C2=A0 (with-error-handler (^e (report-error e) #t) (^ () (let loop=
2 ...<br>
gosh$ (subseq #u8(0) 0 2)<br>
*** ERROR: end argument out of range: 2<br>
Stack Trace:<br>
_______________________________________<br>
=C2=A0 0=C2=A0 (report-error e)<br>
=C2=A0 1=C2=A0 (eval expr env)<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 at &quot;/tmp/Gauche/src/../lib/gauche/interact=
ive.scm&quot;:407<br>
=C2=A0 2=C2=A0 (evaluator exp (vm-current-module))<br>
=C2=A0 3=C2=A0 (with-error-handler (^e (report-error e) #t) (^ () (let loop=
2 ...<br>
gosh$ (subseq #*0 0 2)<br>
*** ERROR: end argument out of range: 2<br>
Stack Trace:<br>
_______________________________________<br>
=C2=A0 0=C2=A0 (report-error e)<br>
=C2=A0 1=C2=A0 (eval expr env)<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 at &quot;/tmp/Gauche/src/../lib/gauche/interact=
ive.scm&quot;:407<br>
=C2=A0 2=C2=A0 (evaluator exp (vm-current-module))<br>
=C2=A0 3=C2=A0 (with-error-handler (^e (report-error e) #t) (^ () (let loop=
2 ...<br>
gosh$ (subseq #(0) 0 2)<br>
#(0 #&lt;undef&gt;)<br>
<br>
jens<br>
<br>
<br>
_______________________________________________<br>
Gauche-devel mailing list<br>
<a href=3D"mailto:[email protected]" target=3D"_blank">Gau=
[email protected]</a><br>
<a href=3D"https://lists.sourceforge.net/lists/listinfo/gauche-devel" rel=
=3D"noreferrer" target=3D"_blank">https://lists.sourceforge.net/lists/listi=
nfo/gauche-devel</a><br>
</blockquote></div>
</blockquote></div>

--000000000000cce94806514bbe99--


--===============6311566837782248709==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


--===============6311566837782248709==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Gauche-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gauche-devel

--===============6311566837782248709==--