The first part of the ticket was resolved in
https://github.com/rakudo/rakudo/commit/46dca95547949bc3d791efb2620d362a68176fdc

So you can no longer create an array using 0.5.

But you can still create an array with any fractional value that's larger than
1, and it will blow up later.

♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥
For SQUASHathoners:
♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥

The commit mentioned above gives a clue on what part of the code can be changed
to resolve the issue.
https://github.com/rakudo/rakudo/blob/cef3bf3e75411a5a664f93ea72209637eaaf5e3d/src/core/Rakudo/Internals.pm#L357-L362

I *think* that calling .Int on it will resolve the issue, but this of course
won't produce a Failure which was recommended by TimToady. Either way the issue
should be easy to approach.

On 2015-12-03 19:32:19, alex.jakime...@gmail.com wrote:
> My previous bug report was about overflow associated with negative sizes
> (RT #126800)
>
> This time it is a little bit different:
> my @a[0.5]; say @a.perl;
>
> Result:
> Index 0 for dimension 1 out of range (must be 0..-1)
> in block <unit> at -e:1
>
>
> Actually, it only accepts values that can unbox to a native integer. “0.5”
> is not an integer, so perhaps it should fail earlier?
>
> That being said, I think sometimes it could be useful to create an array if
> you have a num value without rounding it down first. So maybe it should not
> be forbidden, but then it should not be buggy.
>
> Interestingly, it is not only about “-1” sneaking in:
> my @a[5.5]; say @a.perl
>
> Result:
> Index 5 for dimension 1 out of range (must be 0..4)
> in block <unit> at -e:1
>
>
> Perhaps it should just round it down to an integer internally? … but why
> not up?
>
>
> <AlexDaniel> TimToady: “my @a[5.5]” – what should it mean? [5], [6] or
> error?
> <TimToady> AlexDaniel: I think an error would be appropriate if .narrow
> doesn't get an Int
> <TimToady> since a dynamic 5.5 might well indicate that you need 6, but
> maybe not
> <TimToady> and we should force them to put ceiling if they mean that
>
> Well, hmm… Go figure!

Reply via email to