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
@a[0,1] is not the same as @a[^2] #3782
Comments
From @lizmatSlicing handles ranges differently from lists, even if the range is not infinite. my @a; This becomes even more troublesome when used as a left value: @a[0,1] = 42,43 # (42,43) This I find to be a real bug. The problems are really cause by the fact that slices create a Parcel is rw, and ranges look at the @a.gimme information to fill in entries. So @a[^2] creates an empty Parcel, in which into the values are assigned into oblivion, like any extra values would. |
From @pmichaudOn Thu Apr 16 09:50:05 2015, elizabeth wrote:
It's not a rakudobug -- rakudo is following S09 here. Quoting S09: For subscripts containing range or sequence iterators extending beyond @array[0..*] merely returns C<()> if C<@array> happens to be empty. So, first file this as a design change request (http://github.com/perl6/specs/issues) and then we can update Rakudo to match. Pm |
The RT System itself - Status changed from 'new' to 'open' |
From @cokeOn Thu Apr 16 09:50:05 2015, elizabeth wrote:
No change to this behavior in GLR for the first bit... 15:31 < [Coke]> m: my @a; say @a[0,1].perl; say @a[^2].perl; Second bit looks like the behavior changed in camelia slightly, but is also unchanged in GLR. 15:35 < [Coke]> m: my @a; my @b; @a[0,1] = 42,43; say @a.perl; @b[^2] = 42,43; -- |
From @jnthnOn Thu Apr 16 09:50:05 2015, elizabeth wrote:
We've now changed it so that @a[^2] will be the same as @a[0,1], to avoid this common gotcha. Infinite ranges still auto-truncate. The existing auto-truncating behavior is still available as @a[lazy ^2]. A bunch of tests were updated, and there's an explicit test for this case in S03-operators/assign.t. |
@jnthn - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#124316 (status was 'resolved')
Searchable as RT124316$
The text was updated successfully, but these errors were encountered: