Rafael Garcia-Suarez wrote:
> > > There's already the warning ""our" variable %s redeclared" that can be
> > > re-used for this.
> > 
> > Right.  Do we want the 
> > 
> >     "\t(Did you mean \"local\" instead of \"our\"?)\n"
> > 
> > part for this?  It is unlikely that the programmer meant local in this
> > case.
> 
> Good suggestion.

Implemented by :

Change 25187 by [EMAIL PROTECTED] on 2005/07/19 14:12:38

        Extend the the "our variable redeclared" warning to the case:
            our $x; our $x;
        and add more tests

Affected files ...

... //depot/perl/pad.c#68 edit
... //depot/perl/t/lib/strict/vars#7 edit
... //depot/perl/t/lib/warnings/pad#8 edit

Differences ...

==== //depot/perl/pad.c#68 (text) ====

@@ -515,9 +515,10 @@
            && sv != &PL_sv_undef
            && !SvFAKE(sv)
            && (SvIVX(sv) == PAD_MAX || SvIVX(sv) == 0)
-           && !(is_our && (SvFLAGS(sv) & SVpad_OUR))
            && strEQ(name, SvPVX_const(sv)))
        {
+           if (is_our && (SvFLAGS(sv) & SVpad_OUR))
+               break; /* "our" masking "our" */
            Perl_warner(aTHX_ packWARN(WARN_MISC),
                "\"%s\" variable %s masks earlier declaration in same %s",
                (is_our ? "our" : "my"),
@@ -540,8 +541,9 @@
            {
                Perl_warner(aTHX_ packWARN(WARN_MISC),
                    "\"our\" variable %s redeclared", name);
-               Perl_warner(aTHX_ packWARN(WARN_MISC),
-                   "\t(Did you mean \"local\" instead of \"our\"?)\n");
+               if (off <= PL_comppad_name_floor)
+                   Perl_warner(aTHX_ packWARN(WARN_MISC),
+                       "\t(Did you mean \"local\" instead of \"our\"?)\n");
                break;
            }
        } while ( off-- > 0 );

==== //depot/perl/t/lib/strict/vars#7 (text) ====
[... rest trimmed, cf APC for full text ...]

Reply via email to