Skip to content
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

LTA error message when indexing .[Inf] of an array #1560

Closed
p6rt opened this issue Mar 1, 2010 · 11 comments
Closed

LTA error message when indexing .[Inf] of an array #1560

p6rt opened this issue Mar 1, 2010 · 11 comments

Comments

@p6rt
Copy link

p6rt commented Mar 1, 2010

Migrated from rt.perl.org#73184 (status was 'resolved')

Searchable as RT73184$

@p6rt
Copy link
Author

p6rt commented Mar 1, 2010

From @masak

<masak> rakudo​: my @​a=0..*; @​a[Inf]=3; say @​a[Inf]; # found by lue
<masak> I mean lue++
<p6eval> rakudo 588a34​: OUTPUT«Cannot use negative index on arrays [...]
<masak> rakudo​: my @​a; say @​a[Inf];
<p6eval> rakudo 588a34​: OUTPUT«Cannot use negative index on arrays [...]
* masak submits rakudobug

@p6rt
Copy link
Author

p6rt commented Feb 20, 2011

From @tadzik

On the current Rakudo the code hangs. It's disputable whether it should
warn the user or not, yet there's no LTA error message anymore.

@p6rt
Copy link
Author

p6rt commented Feb 20, 2011

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Sep 13, 2011

From @bbkr

NOM​: code does not hang now, but PMCArray is leaking somehow.

bbkr​:nom bbkr$ ./perl6 -e 'my @​a=0..*; @​a[Inf]=3; say @​a[Inf];'
ResizablePMCArray​: index out of bounds!
  in method STORE_AT_POS at src/gen/CORE.setting​:4067

@p6rt
Copy link
Author

p6rt commented May 29, 2012

From @diakopter

On Tue Sep 13 15​:18​:33 2011, bbkr wrote​:

NOM​: code does not hang now, but PMCArray is leaking somehow.

bbkr​:nom bbkr$ ./perl6 -e 'my @​a=0..*; @​a[Inf]=3; say @​a[Inf];'
ResizablePMCArray​: index out of bounds!
in method STORE_AT_POS at src/gen/CORE.setting​:4067

New behavior, which I think is right. marking testneeded.

15​:14 < diakopter> rakudo​: my @​a=0..*; @​a[Inf]=3; say @​a[Inf];
15​:14 <+p6eval> rakudo 223419​: OUTPUT«This type cannot unbox to a native
integer� in
  method at_pos at src/gen/CORE.setting​:5723â�¤ in method
postcircumfix​:<[ ]>
  at src/gen/CORE.setting​:1184â�¤ in block <anon> at
/tmp/JkBszJpFDN​:1â�¤â�¤Â»

@p6rt
Copy link
Author

p6rt commented Jul 15, 2012

From @bbkr

Tests in

Raku/roast@4d397514e2

@p6rt
Copy link
Author

p6rt commented Jul 15, 2012

@bbkr - Status changed from 'open' to 'resolved'

@p6rt
Copy link
Author

p6rt commented Jul 16, 2012

From @bbkr

IRC discussion revealed test is written in the wrong way and error message is not corect​:

bbkr how to write tests for LTA error messages like this one​:
https://github.com/perl6/roast/blob/094220d50153c285c15fb3fa47b0b63e95bd6b5a/S02-
types/array.t#L338 to avoid conflicts with other implementations? 09​:17
moritz the first step is to determine what the proper error message would be
09​:24
moritz then define an exception class for it 09​:26
moritz and then use throws_like from Test​::Util 09​:26
moritz the current tests are certainly wrong 09​:26
moritz my class X​::Index is Exception { has $.aggregate; has $.index; method
message() { "Cannot index {$.aggregate.^name} with $.index" } } 09​:26
moritz or so 09​:27
bbkr every error should throw some kind of exception? 09​:28
prettyrobots left the room (quit​: Quit​: Computer has gone to sleep.). 09​:29
moritz some should fail(), some should throw exceptions 09​:29
moritz I'm not quite sure when to do what, but it's usually OK to start with die()
09​:29
moritz and yes, all errors (except internal errors) should end up being of a proper
exception class 09​:30
bbkr this example above throws X​:AdHoc - is is something temporary (that should not
be put in test)? 09​:30
moritz X​::AdHoc is what you get when the throwing location doesn't pass an
Exception to &die 09​:31
moritz so, not something you should test for in this context 09​:31
moritz (and the error message is certainly wrong) 09​:31
moritz probaly needs an if nqp​::isnanorinf($index) { ... } check at some point

@p6rt
Copy link
Author

p6rt commented Jul 16, 2012

@bbkr - Status changed from 'resolved' to 'open'

@p6rt
Copy link
Author

p6rt commented Dec 18, 2012

From @timo

Added a typed Exception X​::Item like moritz suggested in rakudo​: 358f486
and tested for it in roast​: f4ba6865..4aa7777

Marking as resolved.

@p6rt
Copy link
Author

p6rt commented Dec 18, 2012

@timo - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant