/* This function is called from three places, sv_compile_2op, pp_return
* and pp_entereval. These can be distinguished as follows:
* sv_compile_2op - startop is non-null
- * pp_require - startop is null; in_require is true
- * pp_entereval - stortop is null; in_require is false
+ * pp_require - startop is null; saveop is not entereval
+ * pp_entereval - startop is null; saveop is entereval
*/
STATIC bool
CLEAR_ERRSV();
if (!startop) {
+ bool clear_hints = saveop->op_type != OP_ENTEREVAL;
SAVEHINTS();
- if (in_require) {
+ if (clear_hints) {
PL_hints = 0;
hv_clear(GvHV(PL_hintgv));
}
}
}
SAVECOMPILEWARNINGS();
- if (in_require) {
+ if (clear_hints) {
if (PL_dowarn & G_WARN_ALL_ON)
PL_compiling.cop_warnings = pWARN_ALL ;
else if (PL_dowarn & G_WARN_ALL_OFF)
@x = sub { if (0){} else { 0; @a } }->();
is("@x", "24 25 26 27", 'if (0){} else { ...; @a } receives caller list context');
+# [rt.cpan.org #72767] do "string" should not propagate warning hints
+SKIP: {
+ skip_if_miniperl("no in-memory files under miniperl", 1);
+
+ my $code = '42; 1';
+ # Based on Eval::WithLexicals::_eval_do
+ local @INC = (sub {
+ if ($_[1] eq '/eval_do') {
+ open my $fh, '<', \$code;
+ $fh;
+ } else {
+ ();
+ }
+ }, @INC);
+ local $^W;
+ use warnings;
+ my $w;
+ local $SIG{__WARN__} = sub { warn shift; ++$w };
+ do '/eval_do' or die $@;
+ is($w, undef, 'do STRING does not propagate warning hints');
+}
+
done_testing();