An optimisation for %hash in boolean context, as introduced with
867fa1e2da145229b4db2c6e8d5b51700c15f114
could falsely optimise constructs that shoudn't be.
Original bug report and fix suggestion were by Goro Fuji.
Include a test to cover the case which was mis-optimised (although
coverage still seems low to me).
Additionally correct B::Deparse (just swap a line, it was using a
variable before it was defined).
my($op, $cx, $name) = @_;
my $kid;
if ($op->flags & OPf_KIDS) {
+ $kid = $op->first;
if (not $name) {
# this deals with 'boolkeys' right now
return $self->deparse($kid,$cx);
}
- $kid = $op->first;
my $builtinname = $name;
$builtinname =~ /^CORE::/ or $builtinname = "CORE::$name";
if (defined prototype($builtinname)
){
OP * nop = o;
OP * lop = o;
- if (!(nop->op_flags && OPf_WANT_VOID)) {
+ if (!((nop->op_flags & OPf_WANT) == OPf_WANT_VOID)) {
while (nop && nop->op_next) {
switch (nop->op_next->op_type) {
case OP_NOT:
}
}
}
- if (lop->op_flags && OPf_WANT_VOID) {
+ if ((lop->op_flags & OPf_WANT) == OPf_WANT_VOID) {
if (fop->op_type == OP_PADHV || fop->op_type == OP_RV2HV)
cLOGOP->op_first = opt_scalarhv(fop);
if (sop && (sop->op_type == OP_PADHV || sop->op_type == OP_RV2HV))
require './test.pl';
}
-plan tests => 52;
+plan tests => 54;
$h{'abc'} = 'ABC';
$h{'def'} = 'DEF';
is($rest,3,"Got the expect number of keys");
my $hsv=1 && %foo;
like($hsv,'/',"Got bucket stats from %foo in scalar assignment context");
+ my @arr=%foo&&%foo;
+ is(@arr,10,"Got expected number of elements in list context");
}
{
our %foo=(1..10);
is($rest,3,"Got the expect number of keys");
my $hsv=1 && %foo;
like($hsv,'/',"Got bucket stats from %foo in scalar assignment context");
+ my @arr=%foo&&%foo;
+ is(@arr,10,"Got expected number of elements in list context");
}