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
nicer error message for 12345[1] (number scalar indexed with .[]) #227
Comments
From @masakr30166: So: * For some reason, a literal integer followed by an array index makes * A Parrot error is thrown once the code is run. Even if code like * Some magical limit between 999999 and 1000000 makes the error start Perl 5.8 has a simple solution to array indexing of integers: $ perl -e 1[1]' |
From @pmichaudOn Mon, Aug 11, 2008 at 12:08:21AM -0700, Carl Mäsak wrote:
AFAICT, according to the grammar it's valid standard Perl 6 syntax.
At present Rakudo doesn't try to interpret all exceptions that Parrot
I think this has to do with the way that integers are interpreted Pm |
The RT System itself - Status changed from 'new' to 'open' |
From @TimToadyOn Thu, Aug 14, 2008 at 02:32:29AM -0500, Patrick R. Michaud wrote: At least in pugs, 42[0] is legal, and produces the value 42, on Larry |
From @moritzCarl MXXsak (via RT) wrote:
Yes. Imagine class Int is also { method postcircumfix:<[ ]> { ... } } In general .[] and .{} are just method calls with a fancy syntax, so Cheers, -- |
From @masak<PhatEddy> rakudo: 1000000[1] |
@masak - Status changed from 'open' to 'resolved' |
From @ronaldxsOn Thu Apr 02 07:02:55 2009, masak wrote:
After further discussion this output was noted as an improvement but For now an improvement to behavior similar to that displayed below was <PhatEddy> rakudo: say "abc"[0] |
@masak - Status changed from 'resolved' to 'open' |
From @ronaldxsThe attached patch should generate the desired error message. If |
From @ronaldxsPositional_trap_elements.patch--- a/src/classes/Positional.pir
+++ b/src/classes/Positional.pir
@@ -105,9 +105,24 @@ Returns a list element or slice.
.param pmc invocant
.param pmc argsblock
.param pmc options :slurpy :named
+
+ # if elements fails we can probably count on postcfix to err adequately
+ push_eh call_and_throw_err
$I0 = elements invocant
$P0 = box $I0
set_hll_global ['Whatever'], '$!slice', $P0
+ goto just_call
+
+call_and_throw_err:
+ .const string NO_ELEMENTS_MARKER = "elements() not implemented"
+ .get_results ($P0)
+ $I0 = length NO_ELEMENTS_MARKER
+ $S0 = $P0
+ $S0 = substr $S0, 0, $I0
+ if $S0 == NO_ELEMENTS_MARKER goto just_call
+ rethrow $P0
+
+just_call:
.local pmc args
args = argsblock()
args = 'list'(args)
|
From @ShimmerFairyAs a convenience, the error generated now is: |
From @cokeOn Tue Apr 06 17:31:42 2010, lue wrote:
With Altanta: $ ./perl6
-- |
From @ShimmerFairyThe attached patch changes the error message from a `fail' message to a |
From @ShimmerFairy |
From @pmichaudI'm fairly certain that Rakudo's current behavior (returning a Failure I'm declaring this ticket "fixed" and can be resolved when we have Pm |
1 similar comment
From @pmichaudI'm fairly certain that Rakudo's current behavior (returning a Failure I'm declaring this ticket "fixed" and can be resolved when we have Pm |
From @moritzTested in S02-builtin_data_types/array.t |
@moritz - Status changed from 'open' to 'resolved' |
From @kylehaThis is an automatically generated mail to inform you that tests are now available in S02-builtin_data_types/array.t commit 5ca3dae8bbf33a3e051a2e5389bea2c68c1b3448 test for RT #57790, scalars indexed with [1] should return a Failure Inline Patchdiff --git a/S02-builtin_data_types/array.t b/S02-builtin_data_types/array.t
index b6685e7..8283e98 100644
--- a/S02-builtin_data_types/array.t
+++ b/S02-builtin_data_types/array.t
@@ -2,7 +2,7 @@ use v6;
use Test;
-plan 102;
+plan 103;
#L<S02/Mutable types/Array>
@@ -329,7 +329,7 @@ my @array2 = ("test", 1, Mu);
is [][].elems, 0, '[][] returns empty list/array';
}
-# RT #58372
+# RT #58372 and RT #57790
# by current group understanding of #perl6, postcircumifx:<[ ]> is actually
# defined in Any, so that .[0] is the identity operation for non-Positional
# types
@@ -337,6 +337,7 @@ my @array2 = ("test", 1, Mu);
is 1[0], 1, '.[0] is identiity operation for scalars (Int)';
is 'abc'[0], 'abc', '.[0] is identiity operation for scalars (Str)';
nok 'abc'[1].defined, '.[1] on a scalar is not defined';
+ isa_ok 1[1], Failure, 'indexing a scalar with other than 0 returns a Failure';
dies_ok { Mu.[0] }, 'but Mu has no .[]';
}
|
Migrated from rt.perl.org#57790 (status was 'resolved')
Searchable as RT57790$
The text was updated successfully, but these errors were encountered: