On Tue, 06 Dec 2016 16:16:28 -0800, alex.jakime...@gmail.com wrote:
> Code:
> say 1.pick(-1)
> 
> Result:
> MVMArray: Index out of bounds
>   in block <unit> at -e line 1
> 
> 
> There's no “index” in my code, that's a number of elements. We
> probably want an error message that is not so low-level-ish.


I've added an interim-fix[^1] to stop it crashing like that (and instead 
complain that it goes a non-UInt), but there doesn't yet seem to be a 
consensus[^2] on whether we should throw on negatives or treat them as zero 
(same applies to .roll). For example, `match` throws on negative :nth(), and so 
does `[][-1]`, but `42 xx -1` treats the negative as zero.

So I'd like to examine more of these methods and routines to come up with some 
sort of consistency on what we do with out-of-bounds args.


[1] https://github.com/rakudo/rakudo/commit/f367e4edc1
[2] https://irclog.perlgeek.de/perl6/2016-12-07#i_13698488

Reply via email to