Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[perl #40102] [BUG] Using splice with an out-of-range array index gives bad error

7 views
Skip to first unread message

Matt Diephouse

unread,
Aug 6, 2006, 11:43:07 PM8/6/06
to bugs-bi...@rt.perl.org
# New Ticket Created by Matt Diephouse
# Please include the string: [perl #40102]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=40102 >


mini:~/Projects/parrot mdiep$ cat test.pir
.sub main :main
$P0 = new .Array
$P0 = 0
$P1 = new .Array
$P1 = 1
$P2 = new .String
$P2 = 'Foo'
$P1[0] = $P2
splice $P0, $P1, 20, 0

end
.end

mini:~/Projects/parrot mdiep$ parrot test.pir
list structure chaos!

That's an awful error. It should say "Array index out of bounds" or
anything more useful than "list structure chaos!".

--
Matt Diephouse

Leopold Toetsch

unread,
Aug 7, 2006, 8:59:08 AM8/7/06
to perl6-i...@perl.org
Am Montag, 7. August 2006 05:43 schrieb Matt Diephouse:

>      splice $P0, $P1, 20, 0

>    mini:~/Projects/parrot mdiep$ parrot test.pir


>    list structure chaos!
>
> That's an awful error. It should say "Array index out of bounds" or  
> anything more useful than "list structure chaos!".

Well, a missing bounds check was causing "list structure chaos!" - that's it.
Anyway, this should be fixed now (r13890). But please note that the list.c
code does allow splicing beyond the end. It's probably up to array.pmc to
impose some limits (and up to PerlArray to not to do so).

leo

0 new messages