# New Ticket Created by Alex Jakimenko # Please include the string: [perl #126802] # in the subject line of all future correspondence about this issue. # <URL: https://rt.perl.org/Ticket/Display.html?id=126802 >
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!