From: Dave Mitchell Date: Thu, 16 Jan 2003 17:12:37 +0000 (+0000) Subject: Re: difference between my and our before introduction X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8716503d4f67eab8980805177dcbdf2c897aa42e;p=p5sagit%2Fp5-mst-13.2.git Re: difference between my and our before introduction Message-ID: <20030116171237.C420@fdgroup.com> (with a small test tweak) p4raw-id: //depot/perl@18571 --- diff --git a/pad.c b/pad.c index 0eea55c..09dd568 100644 --- a/pad.c +++ b/pad.c @@ -552,13 +552,8 @@ Perl_pad_findmy(pTHX_ char *name) continue; } else { - if ( - ( seq > (U32)I_32(SvNVX(sv)) /* min */ - && seq <= (U32)SvIVX(sv)) /* max */ - || - /* 'our' is visible before introduction */ - (!SvIVX(sv) && (SvFLAGS(sv) & SVpad_OUR)) - ) + if ( seq > (U32)I_32(SvNVX(sv)) /* min */ + && seq <= (U32)SvIVX(sv)) /* max */ return off; } } diff --git a/t/comp/our.t b/t/comp/our.t index 8029f61..69fbb03 100644 --- a/t/comp/our.t +++ b/t/comp/our.t @@ -6,7 +6,7 @@ BEGIN { require './test.pl'; } -print "1..6\n"; +print "1..7\n"; { package TieAll; @@ -48,3 +48,13 @@ is(TieAll->calls, '', 'our @x has no runtime effect'); {our (@x);} is(TieAll->calls, '', 'our (@x) has no runtime effect'); + + +$y = 1; +{ + my $y = 2; + { + our $y = $y; + is($y, 2, 'our shouldnt be visible until introduced') + } +} diff --git a/toke.c b/toke.c index 641e3e3..b879815 100644 --- a/toke.c +++ b/toke.c @@ -5279,7 +5279,9 @@ S_pending_ident(pTHX) */ if (!strchr(PL_tokenbuf,':')) { - if ((tmp = pad_findmy(PL_tokenbuf)) != NOT_IN_PAD) { + if (!PL_in_my) + tmp = pad_findmy(PL_tokenbuf); + if (tmp != NOT_IN_PAD) { /* might be an "our" variable" */ if (PAD_COMPNAME_FLAGS(tmp) & SVpad_OUR) { /* build ops for a bareword */