Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rakudo doesn't fail to accept [-1] (but STD does) #801

Closed
p6rt opened this issue Mar 19, 2009 · 7 comments
Closed

Rakudo doesn't fail to accept [-1] (but STD does) #801

p6rt opened this issue Mar 19, 2009 · 7 comments

Comments

@p6rt
Copy link

p6rt commented Mar 19, 2009

Migrated from rt.perl.org#63986 (status was 'resolved')

Searchable as RT63986$

@p6rt
Copy link
Author

p6rt commented Mar 19, 2009

From @masak

<amoc> rakudo​: my @​a = <one two>; @​a[-1] = 'zero'; @​a.perl
<p6eval> rakudo f8b6ae​: RESULT«"[\"one\", \"two\"]"»
<amoc> it is a bug, right?
<masak> amoc​: [*-1]
<amoc> rakudo​: my @​a = <one two>; @​a[*-1] = 'zero'; @​a.perl
<p6eval> rakudo f8b6ae​: RESULT«"[\"one\", \"zero\"]"»
<masak> S09.
<jnthn> I think -1 is meant to be a syntax error these days.
<masak> jnthn​: why?
<masak> it's just out of bounds.
<jnthn> std​: @​foo[-1]
<p6eval> std 25906​: OUTPUT«##### PARSE FAILED #####␤Obsolete use of
[-1] subscript to access final element; in Perl 6 please use [*-1]
instead [...]
<amoc> from http://perlcabal.org/syn/S09.html#Negative_and_differential_subscripts
<masak> oh.
<amoc> it says​: "Using a standard index less than zero prepends the
corresponding number of elements to the start of the array and then
maps the negative index back to zero"?
<jnthn> masak​: Because STD.pm says so. But yes, you can declare an
array with different indexes too...
<jnthn> So I'm not sure what'd happen there.
<masak> shall I report this as a rakudobug?
<jnthn> You can. We're inconsistent with STD.pm there, so it's
probably worthy of a ticket.
<masak> someone put together an example for STD with a
different-indexes array, and see what it says! :)
* masak submits

@p6rt
Copy link
Author

p6rt commented Jul 27, 2010

From @coke

On Thu Mar 19 06​:28​:19 2009, masak wrote​:

<amoc> rakudo​: my @​a = <one two>; @​a[-1] = 'zero'; @​a.perl
<p6eval> rakudo f8b6ae​: RESULT«"[\"one\", \"two\"]"»
<amoc> it is a bug, right?
<masak> amoc​: [*-1]
<amoc> rakudo​: my @​a = <one two>; @​a[*-1] = 'zero'; @​a.perl
<p6eval> rakudo f8b6ae​: RESULT«"[\"one\", \"zero\"]"»
<masak> S09.
<jnthn> I think -1 is meant to be a syntax error these days.
<masak> jnthn​: why?
<masak> it's just out of bounds.
<jnthn> std​: @​foo[-1]
<p6eval> std 25906​: OUTPUT«##### PARSE FAILED #####␤Obsolete use of
[-1] subscript to access final element; in Perl 6 please use [*-1]
instead [...]
<amoc> from
http://perlcabal.org/syn/S09.html#Negative_and_differential_subscripts
<masak> oh.
<amoc> it says​: "Using a standard index less than zero prepends the
corresponding number of elements to the start of the array and then
maps the negative index back to zero"?
<jnthn> masak​: Because STD.pm says so. But yes, you can declare an
array with different indexes too...
<jnthn> So I'm not sure what'd happen there.
<masak> shall I report this as a rakudobug?
<jnthn> You can. We're inconsistent with STD.pm there, so it's
probably worthy of a ticket.
<masak> someone put together an example for STD with a
different-indexes array, and see what it says! :)
* masak submits

This currently fails, but not in the same manner as STD​:

17​:26 < [Coke]> rakudo​: my @​a = <one two>; @​a[-1] = 'zero'; @​a.perl
17​:26 <+p6eval> rakudo ac8a2a​: OUTPUT«Cannot modify readonly value␤ in
  '&infix​:<=>' at line 1␤ in main program body at line
  22​:/tmp/Udd9hXZOxN␤»

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Jul 27, 2010

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Jan 11, 2012

From @coke

On Tue Jul 27 14​:27​:33 2010, coke wrote​:

On Thu Mar 19 06​:28​:19 2009, masak wrote​:

<amoc> rakudo​: my @​a = <one two>; @​a[-1] = 'zero'; @​a.perl
<p6eval> rakudo f8b6ae​: RESULT«"[\"one\", \"two\"]"»
<amoc> it is a bug, right?
<masak> amoc​: [*-1]
<amoc> rakudo​: my @​a = <one two>; @​a[*-1] = 'zero'; @​a.perl
<p6eval> rakudo f8b6ae​: RESULT«"[\"one\", \"zero\"]"»
<masak> S09.
<jnthn> I think -1 is meant to be a syntax error these days.
<masak> jnthn​: why?
<masak> it's just out of bounds.
<jnthn> std​: @​foo[-1]
<p6eval> std 25906​: OUTPUT«##### PARSE FAILED #####␤Obsolete use of
[-1] subscript to access final element; in Perl 6 please use [*-1]
instead [...]
<amoc> from
http://perlcabal.org/syn/S09.html#Negative_and_differential_subscripts
<masak> oh.
<amoc> it says​: "Using a standard index less than zero prepends the
corresponding number of elements to the start of the array and then
maps the negative index back to zero"?
<jnthn> masak​: Because STD.pm says so. But yes, you can declare an
array with different indexes too...
<jnthn> So I'm not sure what'd happen there.
<masak> shall I report this as a rakudobug?
<jnthn> You can. We're inconsistent with STD.pm there, so it's
probably worthy of a ticket.
<masak> someone put together an example for STD with a
different-indexes array, and see what it says! :)
* masak submits

This currently fails, but not in the same manner as STD​:

17​:26 < [Coke]> rakudo​: my @​a = <one two>; @​a[-1] = 'zero'; @​a.perl
17​:26 <+p6eval> rakudo ac8a2a​: OUTPUT«Cannot modify readonly value␤ in
'&infix​:<=>' at line 1␤ in main program body at line
22​:/tmp/Udd9hXZOxN␤»

Another slight change​:

20​:08 < [Coke]> rakudo​: my @​a = <one two>; @​a[-1] = 'zero'; @​a.perl
20​:08 <+p6eval> rakudo 38165a​: OUTPUT«Cannot assign to a non-container␤ in
  block <anon> at /tmp/55lCbf7U7p​:1␤ in <anon> at
  /tmp/55lCbf7U7p​:1␤»

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented May 29, 2012

From @diakopter

On Tue Jan 10 17​:09​:46 2012, coke wrote​:

On Tue Jul 27 14​:27​:33 2010, coke wrote​:

On Thu Mar 19 06​:28​:19 2009, masak wrote​:

<amoc> rakudo​: my @​a = <one two>; @​a[-1] = 'zero'; @​a.perl
<p6eval> rakudo f8b6ae​: RESULT«"[\"one\", \"two\"]"»
<amoc> it is a bug, right?
<masak> amoc​: [*-1]
<amoc> rakudo​: my @​a = <one two>; @​a[*-1] = 'zero'; @​a.perl
<p6eval> rakudo f8b6ae​: RESULT«"[\"one\", \"zero\"]"»
<masak> S09.
<jnthn> I think -1 is meant to be a syntax error these days.
<masak> jnthn​: why?
<masak> it's just out of bounds.
<jnthn> std​: @​foo[-1]
<p6eval> std 25906​: OUTPUT«##### PARSE FAILED #####␤Obsolete use
of
[-1] subscript to access final element; in Perl 6 please use [*-1]
instead [...]
<amoc> from

http://perlcabal.org/syn/S09.html#Negative_and_differential_subscripts

<masak> oh.
<amoc> it says​: "Using a standard index less than zero prepends
the
corresponding number of elements to the start of the array and
then
maps the negative index back to zero"?
<jnthn> masak​: Because STD.pm says so. But yes, you can declare an
array with different indexes too...
<jnthn> So I'm not sure what'd happen there.
<masak> shall I report this as a rakudobug?
<jnthn> You can. We're inconsistent with STD.pm there, so it's
probably worthy of a ticket.
<masak> someone put together an example for STD with a
different-indexes array, and see what it says! :)
* masak submits

This currently fails, but not in the same manner as STD​:

17​:26 < [Coke]> rakudo​: my @​a = <one two>; @​a[-1] = 'zero'; @​a.perl
17​:26 <+p6eval> rakudo ac8a2a​: OUTPUT«Cannot modify readonly value␤
in
'&infix​:<=>' at line 1␤ in main program body at
line
22​:/tmp/Udd9hXZOxN␤»

Another slight change​:

20​:08 < [Coke]> rakudo​: my @​a = <one two>; @​a[-1] = 'zero'; @​a.perl
20​:08 <+p6eval> rakudo 38165a​: OUTPUT«Cannot assign to a non-
container␤ in
block <anon> at /tmp/55lCbf7U7p​:1␤ in <anon> at
/tmp/55lCbf7U7p​:1␤»

This is now fixed. marking testneeded.

@p6rt
Copy link
Author

p6rt commented May 30, 2012

From @diakopter

On Tue May 29 15​:09​:25 2012, diakopter wrote​:

On Tue Jan 10 17​:09​:46 2012, coke wrote​:

On Tue Jul 27 14​:27​:33 2010, coke wrote​:

On Thu Mar 19 06​:28​:19 2009, masak wrote​:

<amoc> rakudo​: my @​a = <one two>; @​a[-1] = 'zero'; @​a.perl
<p6eval> rakudo f8b6ae​: RESULT«"[\"one\", \"two\"]"»
<amoc> it is a bug, right?
<masak> amoc​: [*-1]
<amoc> rakudo​: my @​a = <one two>; @​a[*-1] = 'zero'; @​a.perl
<p6eval> rakudo f8b6ae​: RESULT«"[\"one\", \"zero\"]"»
<masak> S09.
<jnthn> I think -1 is meant to be a syntax error these days.
<masak> jnthn​: why?
<masak> it's just out of bounds.
<jnthn> std​: @​foo[-1]
<p6eval> std 25906​: OUTPUT«##### PARSE FAILED #####␤Obsolete
use
of
[-1] subscript to access final element; in Perl 6 please use
[*-1]
instead [...]
<amoc> from

http://perlcabal.org/syn/S09.html#Negative_and_differential_subscripts

<masak> oh.
<amoc> it says​: "Using a standard index less than zero prepends
the
corresponding number of elements to the start of the array and
then
maps the negative index back to zero"?
<jnthn> masak​: Because STD.pm says so. But yes, you can declare
an
array with different indexes too...
<jnthn> So I'm not sure what'd happen there.
<masak> shall I report this as a rakudobug?
<jnthn> You can. We're inconsistent with STD.pm there, so it's
probably worthy of a ticket.
<masak> someone put together an example for STD with a
different-indexes array, and see what it says! :)
* masak submits

This currently fails, but not in the same manner as STD​:

17​:26 < [Coke]> rakudo​: my @​a = <one two>; @​a[-1] = 'zero';
@​a.perl
17​:26 <+p6eval> rakudo ac8a2a​: OUTPUT«Cannot modify readonly
value␤
in
'&infix​:<=>' at line 1␤ in main program body at
line
22​:/tmp/Udd9hXZOxN␤»

Another slight change​:

20​:08 < [Coke]> rakudo​: my @​a = <one two>; @​a[-1] = 'zero'; @​a.perl
20​:08 <+p6eval> rakudo 38165a​: OUTPUT«Cannot assign to a non-
container␤ in
block <anon> at /tmp/55lCbf7U7p​:1␤ in <anon> at
/tmp/55lCbf7U7p​:1␤»

This is now fixed. marking testneeded.

added test in a9a75b0; resolving.

@p6rt
Copy link
Author

p6rt commented May 30, 2012

@diakopter - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed May 30, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant