Skip to content

Commit

Permalink
Allow native @A[*-4 .. *..2] to work
Browse files Browse the repository at this point in the history
This was apparently broken a little while ago, and nobody noticed.
Basically, Callable candidates must handle Callables that take more
than a single argument, and that may return something else than an
Int.
  • Loading branch information
lizmat committed Jan 2, 2021
1 parent f898632 commit 8150a28
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
30 changes: 18 additions & 12 deletions src/core.c/native_array.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -3706,7 +3706,7 @@ multi sub postcircumfix:<[ ]>(array:D \SELF, Range:D \range ) is raw {
}

#- start of postcircumfix candidates of strarray -------------------------------
#- Generated on 2020-12-07T00:08:19+01:00 by tools/build/makeNATIVE_CANDIDATES.raku
#- Generated on 2021-01-02T18:39:56+01:00 by ./tools/build/makeNATIVE_CANDIDATES.raku
#- PLEASE DON'T CHANGE ANYTHING BELOW THIS LINE

#?if !jvm
Expand Down Expand Up @@ -3813,9 +3813,11 @@ multi sub postcircumfix:<[ ]>(
multi sub postcircumfix:<[ ]>(
array::strarray:D \SELF, Callable:D $pos
) is raw {
nqp::islt_i((my int $got = $pos(nqp::elems(nqp::decont(SELF)))),0)
?? X::OutOfRange.new(:what<Index>, :$got, :range<0..^Inf>).throw
!! nqp::atposref_s(nqp::decont(SELF),$got)
nqp::istype((my $got := $pos.POSITIONS(SELF)),Int)
?? nqp::islt_i($got,0)
?? X::OutOfRange.new(:what<Index>, :$got, :range<0..^Inf>).throw
!! nqp::atposref_s(nqp::decont(SELF),$got)
!! postcircumfix:<[ ]>(SELF, $got)
}

multi sub postcircumfix:<[ ]>(
Expand Down Expand Up @@ -3897,7 +3899,7 @@ multi sub postcircumfix:<[ ]>(
#- end of postcircumfix candidates of strarray ---------------------------------

#- start of postcircumfix candidates of numarray -------------------------------
#- Generated on 2020-12-07T00:08:19+01:00 by tools/build/makeNATIVE_CANDIDATES.raku
#- Generated on 2021-01-02T18:39:56+01:00 by ./tools/build/makeNATIVE_CANDIDATES.raku
#- PLEASE DON'T CHANGE ANYTHING BELOW THIS LINE

#?if !jvm
Expand Down Expand Up @@ -4004,9 +4006,11 @@ multi sub postcircumfix:<[ ]>(
multi sub postcircumfix:<[ ]>(
array::numarray:D \SELF, Callable:D $pos
) is raw {
nqp::islt_i((my int $got = $pos(nqp::elems(nqp::decont(SELF)))),0)
?? X::OutOfRange.new(:what<Index>, :$got, :range<0..^Inf>).throw
!! nqp::atposref_n(nqp::decont(SELF),$got)
nqp::istype((my $got := $pos.POSITIONS(SELF)),Int)
?? nqp::islt_i($got,0)
?? X::OutOfRange.new(:what<Index>, :$got, :range<0..^Inf>).throw
!! nqp::atposref_n(nqp::decont(SELF),$got)
!! postcircumfix:<[ ]>(SELF, $got)
}

multi sub postcircumfix:<[ ]>(
Expand Down Expand Up @@ -4088,7 +4092,7 @@ multi sub postcircumfix:<[ ]>(
#- end of postcircumfix candidates of numarray ---------------------------------

#- start of postcircumfix candidates of intarray -------------------------------
#- Generated on 2020-12-07T00:08:19+01:00 by tools/build/makeNATIVE_CANDIDATES.raku
#- Generated on 2021-01-02T18:39:56+01:00 by ./tools/build/makeNATIVE_CANDIDATES.raku
#- PLEASE DON'T CHANGE ANYTHING BELOW THIS LINE

#?if !jvm
Expand Down Expand Up @@ -4195,9 +4199,11 @@ multi sub postcircumfix:<[ ]>(
multi sub postcircumfix:<[ ]>(
array::intarray:D \SELF, Callable:D $pos
) is raw {
nqp::islt_i((my int $got = $pos(nqp::elems(nqp::decont(SELF)))),0)
?? X::OutOfRange.new(:what<Index>, :$got, :range<0..^Inf>).throw
!! nqp::atposref_i(nqp::decont(SELF),$got)
nqp::istype((my $got := $pos.POSITIONS(SELF)),Int)
?? nqp::islt_i($got,0)
?? X::OutOfRange.new(:what<Index>, :$got, :range<0..^Inf>).throw
!! nqp::atposref_i(nqp::decont(SELF),$got)
!! postcircumfix:<[ ]>(SELF, $got)
}

multi sub postcircumfix:<[ ]>(
Expand Down
8 changes: 5 additions & 3 deletions tools/build/makeNATIVE_CANDIDATES.raku
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,11 @@ multi sub postcircumfix:<[ ]>(
multi sub postcircumfix:<[ ]>(
array::#type#array:D \SELF, Callable:D $pos
) is raw {
nqp::islt_i((my int $got = $pos(nqp::elems(nqp::decont(SELF)))),0)
?? X::OutOfRange.new(:what<Index>, :$got, :range<0..^Inf>).throw
!! nqp::atposref_#postfix#(nqp::decont(SELF),$got)
nqp::istype((my $got := $pos.POSITIONS(SELF)),Int)
?? nqp::islt_i($got,0)
?? X::OutOfRange.new(:what<Index>, :$got, :range<0..^Inf>).throw
!! nqp::atposref_#postfix#(nqp::decont(SELF),$got)
!! postcircumfix:<[ ]>(SELF, $got)
}
multi sub postcircumfix:<[ ]>(
Expand Down

0 comments on commit 8150a28

Please sign in to comment.