want = o->op_flags & OPf_WANT;
if ((want && want != OPf_WANT_SCALAR)
|| (PL_parser && PL_parser->error_count)
- || o->op_type == OP_RETURN)
+ || o->op_type == OP_RETURN || o->op_type == OP_REQUIRE)
{
return o;
}
case OP_ENTEREVAL:
scalarkids(o);
break;
- case OP_REQUIRE:
- /* all requires must return a boolean value */
- o->op_flags &= ~OPf_WANT;
- /* FALL THROUGH */
case OP_SCALAR:
return scalar(o);
}
}
PL_curcop = &PL_compiling;
break;
- case OP_REQUIRE:
- /* all requires must return a boolean value */
- o->op_flags &= ~OPf_WANT;
- return scalar(o);
}
return o;
}
return newop;
}
- return ck_fun(o);
+ return scalar(ck_fun(o));
}
OP *
SAVEFREEOP(PL_eval_root);
/* Set the context for this new optree.
- * If the last op is an OP_REQUIRE, force scalar context.
- * Otherwise, propagate the context from the eval(). */
- if (PL_eval_root->op_type == OP_LEAVEEVAL
- && cUNOPx(PL_eval_root)->op_first->op_type == OP_LINESEQ
- && cLISTOPx(cUNOPx(PL_eval_root)->op_first)->op_last->op_type
- == OP_REQUIRE)
- scalar(PL_eval_root);
- else if ((gimme & G_WANT) == G_VOID)
+ * Propagate the context from the eval(). */
+ if ((gimme & G_WANT) == G_VOID)
scalarvoid(PL_eval_root);
else if ((gimme & G_WANT) == G_ARRAY)
list(PL_eval_root);
# Test that scalar context is forced for require
write_file('bleah.pm', <<'**BLEAH**'
-my $TODO = $i == 38 ? " # TODO " : "";
print "not " if !defined wantarray || wantarray ne '';
-print "ok $i - require() context $TODO\n";
+print "ok $i - require() context\n";
1;
**BLEAH**
);