Skip to content

Commit

Permalink
throw X::Item for @A[NaN] or Inf.
Browse files Browse the repository at this point in the history
Signed-off-by: Moritz Lenz <moritz@faui2k3.org>
  • Loading branch information
timo authored and moritz committed Dec 18, 2012
1 parent 7794edf commit 358f486
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/core/Array.pm
@@ -1,3 +1,5 @@
my class X::Item { ... };

class Array { class Array {
# Has attributes and parent List declared in BOOTSTRAP. # Has attributes and parent List declared in BOOTSTRAP.


Expand All @@ -8,6 +10,9 @@ class Array {
} }


multi method at_pos(Array:D: $pos) is rw { multi method at_pos(Array:D: $pos) is rw {
if nqp::isnanorinf($pos) {
X::Item.new(aggregate => self, index => $pos).throw;
}
my int $p = nqp::unbox_i($pos.Int); my int $p = nqp::unbox_i($pos.Int);
my Mu $items := nqp::p6listitems(self); my Mu $items := nqp::p6listitems(self);
# hotpath check for element existence (RT #111848) # hotpath check for element existence (RT #111848)
Expand Down
5 changes: 5 additions & 0 deletions src/core/Exception.pm
Expand Up @@ -1095,6 +1095,11 @@ my class X::NoSuchSymbol is Exception {
method message { "No such symbol '$.symbol'" } method message { "No such symbol '$.symbol'" }
} }


my class X::Item is Exception {
has $.aggregate;
has $.index;
method message { "Cannot index {$.aggregate.^name} with $.index" }
}


{ {
my %c_ex; my %c_ex;
Expand Down

0 comments on commit 358f486

Please sign in to comment.