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
Negative-index Failure over-eagerly triggers even for Whatever-y indexings in Rakudo #2681
Comments
From @masak<felher> nom: my @array; say @array[4]; |
From @usev6The current error message is kind of funny and supports masak's assumption that * getting expanded as 0, and then the failure triggers (wrongly): $ perl6-m -e 'my @array; say @array[*-1]' (An exception of type X::Subscript::FromEnd is thrown.) |
1 similar comment
From @usev6The current error message is kind of funny and supports masak's assumption that * getting expanded as 0, and then the failure triggers (wrongly): $ perl6-m -e 'my @array; say @array[*-1]' (An exception of type X::Subscript::FromEnd is thrown.) |
@usev6 - Status changed from 'new' to 'open' |
From @pmichaudThe fact that an Exception is thrown is correct -- negative subscripts are not allowed unless the subscript has been declared modular (from S09). The Exception message needs to be changed. STD.pm6 has "in Perl 6 please use [*-1]" when it can statically determine that a negative subscript has been passed. For dynamically computed negative subscript, the message can hint that something like *-1 might be useful but definitely shouldn't recommend using the very thing that just failed. Better would be to produce a different error message when a negative subscript is generated from a Code (WhateverCode) object. Pm |
From @usev6TimToady++ recently worked on this (rakudo/rakudo@10aa8bf41c) and it should be in good shape now: $ perl6 -e 'my @array; say @array[*-1]' The exception is now of type X::Subscript::Negative and the error message no longer recommends to use [*-1]. It does so when using [-1]: $ perl6-m -e 'my @array; say @array[-1]' There are tests in S02-types/array.t. I'm closing this ticket now. |
1 similar comment
From @usev6TimToady++ recently worked on this (rakudo/rakudo@10aa8bf41c) and it should be in good shape now: $ perl6 -e 'my @array; say @array[*-1]' The exception is now of type X::Subscript::Negative and the error message no longer recommends to use [*-1]. It does so when using [-1]: $ perl6-m -e 'my @array; say @array[-1]' There are tests in S02-types/array.t. I'm closing this ticket now. |
@usev6 - Status changed from 'open' to 'resolved' |
From @lizmatOn 25 Nov 2014, at 22:37, Christian Bartolomaeus via RT <bugs-comment@bugs6.perl.org> wrote:
That’s because the first one is a run-time exception, at which time we don’t know anymore whether the calculated index involved * or not (a patch to that effect was reverted by TimToady++). So the error message cannot mention *, because it could have been used already. The second one is a compile time warning because you’re using a literal “-1”. That *clearly* doesn’t use a *, so it can be mentioned then. Liz |
Migrated from rt.perl.org#111924 (status was 'resolved')
Searchable as RT111924$
The text was updated successfully, but these errors were encountered: