On Thu Apr 16 09:50:05 2015, elizabeth wrote: > Slicing handles ranges differently from lists, even if the range is > not infinite. > > > my @a; > say @a[0,1].perl; # (Any,Any) > say @a[^2].perl; # () > > > This becomes even more troublesome when used as a left value: > > @a[0,1] = 42,43 # (42,43) > @a[^2] = 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.
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.