fix bogus redeclaration warning for "our" variables in different
authorGurusamy Sarathy <gsar@cpan.org>
Sun, 28 May 2000 08:46:10 +0000 (08:46 +0000)
committerGurusamy Sarathy <gsar@cpan.org>
Sun, 28 May 2000 08:46:10 +0000 (08:46 +0000)
scopes

p4raw-id: //depot/perl@6137

op.c
t/pragma/strict-vars

diff --git a/op.c b/op.c
index 3275d0e..6e77fde 100644 (file)
--- a/op.c
+++ b/op.c
@@ -162,6 +162,7 @@ Perl_pad_allocmy(pTHX_ char *name)
            do {
                if ((sv = svp[off])
                    && sv != &PL_sv_undef
+                   && (SvIVX(sv) == PAD_MAX || SvIVX(sv) == 0)
                    && ((SvFLAGS(sv) & SVpad_OUR) && GvSTASH(sv) == ourstash)
                    && strEQ(name, SvPVX(sv)))
                {
index a764fb2..5ba579d 100644 (file)
@@ -387,6 +387,8 @@ EXPECT
 # multiple our declarations in same scope, same package, warning
 use strict 'vars';
 use warnings;
+{ our $x = 1 }
+{ our $x = 0 }
 our $foo;
 {
     our $foo;
@@ -394,9 +396,9 @@ our $foo;
     our $foo;
 }
 EXPECT
-"our" variable $foo redeclared at - line 7.
+"our" variable $foo redeclared at - line 9.
        (Did you mean "local" instead of "our"?)
-Name "Foo::foo" used only once: possible typo at - line 9.
+Name "Foo::foo" used only once: possible typo at - line 11.
 ########
 
 # Make sure the strict vars failure still occurs