Skip to content

Commit

Permalink
Handle Junctions in Bool context within grep
Browse files Browse the repository at this point in the history
Fixes R#2975
  • Loading branch information
lizmat committed Jun 22, 2019
1 parent 090f3f1 commit 8652386
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/core/Any-iterable-methods.pm6
Expand Up @@ -962,13 +962,13 @@ Consider using a block if any of these are necessary for your mapping code."
sequential-map(
self.iterator,
{
my \result := $test($_);
nqp::if(
nqp::istype(result, Regex) || nqp::istype(result, Junction)
?? result.ACCEPTS($_)
!! result,
$_,
Empty)
(nqp::istype((my \result := $test($_)),Regex)
?? result.ACCEPTS($_)
!! nqp::istype(result,Junction)
?? result.Bool
!! result
) ?? $_
!! Empty
},
Any)
,
Expand Down Expand Up @@ -1144,9 +1144,10 @@ Consider using a block if any of these are necessary for your mapping code."

method !wrap-callable-for-grep($test) {
({
my \result := $test($_);
nqp::istype(result, Regex) || nqp::istype(result, Junction)
?? result.ACCEPTS($_)
nqp::istype((my \result := $test($_)),Regex)
?? result.ACCEPTS($_)
!! nqp::istype(result,Junction)
?? result.Bool
!! result
})
}
Expand Down

0 comments on commit 8652386

Please sign in to comment.