diff options
-rw-r--r-- | pad.c | 9 | ||||
-rw-r--r-- | t/comp/our.t | 12 | ||||
-rw-r--r-- | toke.c | 4 |
3 files changed, 16 insertions, 9 deletions
@@ -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 8029f613c5..69fbb03121 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') + } +} @@ -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 */ |