Skip to content
Permalink
Browse files

Handle Junctions in Bool context within grep

Fixes R#2975
  • Loading branch information...
lizmat committed Jun 22, 2019
1 parent 090f3f1 commit 865238697405b2b3dadffbde5b9141f6a5fc6ad8
Showing with 11 additions and 10 deletions.
  1. +11 −10 src/core/Any-iterable-methods.pm6
@@ -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)
,
@@ -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
})
}

0 comments on commit 8652386

Please sign in to comment.
You can’t perform that action at this time.