Skip to content

Commit

Permalink
RakuAST: fix smartmatch on $_ containing a regex boolifying result
Browse files Browse the repository at this point in the history
Looking at the old compiler frontend, it seems like we don't need the
special smartmatch handling if the right hand side is a plain variable.
While it worked in most cases anyway, things got confusing when that
variable was $_. Then temporarization of that variable disturbed the
check whether the right hand side was a Regex (which doesn't want its
result to be boolified). Avoid the whole thing by just compiling to
a call to infix:sym<~~> for variables. Just like the old frontend.
  • Loading branch information
niner committed Jan 29, 2023
1 parent 0ccec24 commit 8f9a54e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Raku/ast/expressions.rakumod
Expand Up @@ -219,7 +219,7 @@ class RakuAST::Infix is RakuAST::Infixish is RakuAST::Lookup {
nqp::die('Cannot compile bind to ' ~ $left.HOW.name($left));
}
}
elsif nqp::existskey(OP-SMARTMATCH, $op) {
elsif nqp::existskey(OP-SMARTMATCH, $op) && !nqp::istype($right, RakuAST::Var) {
self.IMPL-SMARTMATCH-QAST($context, $left, $right, nqp::atkey(OP-SMARTMATCH, $op));
}
else {
Expand Down

0 comments on commit 8f9a54e

Please sign in to comment.