*startop = PL_eval_root;
} else
SAVEFREEOP(PL_eval_root);
- if (gimme & G_VOID)
+ if (gimme & G_VOID && ! PL_in_eval & EVAL_INREQUIRE)
+ /*
+ * EVAL_INREQUIRE (the code is being required) is special-cased :
+ * in this case we want scalar context to be forced, instead
+ * of void context, so a proper return value is returned from
+ * C<require> via this leaveeval op.
+ */
scalarvoid(PL_eval_root);
else if (gimme & G_ARRAY)
list(PL_eval_root);
my $Is_EBCDIC = (ord('A') == 193) ? 1 : 0;
my $Is_UTF8 = (${^OPEN} || "") =~ /:utf8/;
-my $total_tests = 23;
-if ($Is_EBCDIC || $Is_UTF8) { $total_tests = 20; }
+my $total_tests = 29;
+if ($Is_EBCDIC || $Is_UTF8) { $total_tests = 26; }
print "1..$total_tests\n";
sub do_require {
sub dofile { do "bleah.do"; };
print $x;
+# Test that scalar context is forced for require
+
+write_file('bleah.pm', <<'**BLEAH**'
+print "not " if !defined wantarray || wantarray ne '';
+print "ok $i - require() context\n";
+1;
+**BLEAH**
+);
+ delete $INC{"bleah.pm"}; ++$::i;
+$foo = eval q{require bleah}; delete $INC{"bleah.pm"}; ++$::i;
+@foo = eval q{require bleah}; delete $INC{"bleah.pm"}; ++$::i;
+ eval q{require bleah}; delete $INC{"bleah.pm"}; ++$::i;
+$foo = eval {require bleah}; delete $INC{"bleah.pm"}; ++$::i;
+@foo = eval {require bleah}; delete $INC{"bleah.pm"}; ++$::i;
+ eval {require bleah};
+
# UTF-encoded things - skipped on EBCDIC machines and on UTF-8 input
if ($Is_EBCDIC || $Is_UTF8) { exit; }