From: Gurusamy Sarathy Date: Wed, 8 Mar 2000 18:35:48 +0000 (+0000) Subject: do FILE should not see outside lexicals (from Rick Delaney X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=faa7e5bbaa1a624cf61859998ab6ab0a1323ed35;p=p5sagit%2Fp5-mst-13.2.git do FILE should not see outside lexicals (from Rick Delaney ) p4raw-id: //depot/perl@5620 --- diff --git a/op.c b/op.c index bc07904..689fc18 100644 --- a/op.c +++ b/op.c @@ -356,8 +356,9 @@ S_pad_findlex(pTHX_ char *name, PADOFFSET newoff, U32 seq, CV* startcv, if (CxREALEVAL(cx)) saweval = i; break; + case OP_DOFILE: case OP_REQUIRE: - /* require must have its own scope */ + /* require/do must have their own scope */ return 0; } break; diff --git a/pp_ctl.c b/pp_ctl.c index edbe7b1..42811f5 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -2727,8 +2727,11 @@ S_doeval(pTHX_ int gimme, OP** startop) av_store(comppadlist, 1, (SV*)PL_comppad); CvPADLIST(PL_compcv) = comppadlist; - if (!saveop || saveop->op_type != OP_REQUIRE) + if (!saveop || + (saveop->op_type != OP_REQUIRE && saveop->op_type != OP_DOFILE)) + { CvOUTSIDE(PL_compcv) = (CV*)SvREFCNT_inc(caller); + } SAVEFREESV(PL_compcv); diff --git a/t/comp/require.t b/t/comp/require.t index efce899..1d92687 100755 --- a/t/comp/require.t +++ b/t/comp/require.t @@ -7,7 +7,7 @@ BEGIN { # don't make this lexical $i = 1; -print "1..19\n"; +print "1..20\n"; sub do_require { %INC = (); @@ -113,7 +113,18 @@ do_require "1"; print "# $@\nnot " if $@; print "ok ",$i++,"\n"; -END { 1 while unlink 'bleah.pm'; } +# do FILE shouldn't see any outside lexicals +my $x = "ok $i\n"; +write_file("bleah.do", <