Make (??{$tied_ovrld}) see the right $1
I can return $1 from a regexp code block and it refers to the last
match *within* the block:
"aab" =~ /(a)((??{"b" =~ m|(.)|; $1}))/;
print "[$1 $2]\n";
Output:
[a b]
Even via a tied variable’s FETCH method:
sub ReEvalTieTest::TIESCALAR {bless[], "ReEvalTieTest"}
sub ReEvalTieTest::FETCH { "$1" }
tie my $t, "ReEvalTieTest";
"aab" =~ /(a)((??{"b" =~ m|(.)|; $t}))/;
print "[$1 $2]\n";
Output:
[a b]
But not if I assign a reference to an overloaded object to the tied
variable first:
sub ReEvalTieTest::TIESCALAR {bless[], "ReEvalTieTest"}
sub ReEvalTieTest::STORE{}
sub ReEvalTieTest::FETCH { "$1" }
tie my $t, "ReEvalTieTest";
{ package o; use overload '""'=>sub { "abc" } }
$t = bless [], "o";
"aab" =~ /(a)((??{"b" =~ m|(.)|; $t}))/;
print "[$1 $2]\n";
Output:
[a a]
$1 now refers to the outer pattern, not the inner pattern.
The code that handles the return value of code blocks was not check-
ing get-magic before overloading.
This commit fixes it to do that.