This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Restore autouse’s exemption from redef warnings
authorFather Chrysostomos <sprout@cpan.org>
Mon, 21 Nov 2011 07:46:48 +0000 (23:46 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 21 Nov 2011 08:32:32 +0000 (00:32 -0800)
commit799fd3b94fb5c431b24ee141e32a0b09d56f303c
tree5904101734c7d8b82fa4850ab89e14140768db5f
parent53e2b4984825f4be9303a134996decfc9fb895ed
Restore autouse’s exemption from redef warnings

This also restores the subroutine redefinition warning for newly-cre-
ated XSUBs outside the autouse package.  See below.

This commit added the exemption to fix a known bug, that loading a
module and importing from it would cause a redefinition warning if
there were an autouse stub:

perl-5.004_03-1092-g2f34f9d
commit 2f34f9d4825ac9262ece854fc4c50479f4838ff8
Author: Ilya Zakharevich <ilya@math.berkeley.edu>
Date:   Mon Mar 2 16:36:02 1998 -0500

    Make autouse -w-safe

    p4raw-id: //depot/perl@781

The subroutine redefinition warning occurs in three places.
This commit removed the autouse exemption from two
of them.  I can’t see how it wasn’t a mistake, as <5104D4DBC598D211B5FE0000F8FE7EB202D49EE9@mbtlipnt02.btlabs.bt.co.uk>
(the apparent source of the patch, makes no mention of it:

perl-5.005_02-2920-ge476b1b
commit e476b1b5c29f354cf8dad61a9fc6d855bdfb5b7d
Author: Gurusamy Sarathy <gsar@cpan.org>
Date:   Sun Feb 20 22:58:09 2000 +0000

    lexical warnings update, ability to inspect bitmask in calling
    scope, among other things (from Paul Marquess)

    p4raw-id: //depot/perl@5170

This commit refactored things to remove some compiler warnings, but
in doing so reversed the logic of the condition, causing redefini-
tion warnings for newly-created XSUBs to apply only to subs from the
autouse package:

perl-5.8.0-5131-g66a1b24
commit 66a1b24beb76ea873ad4caa57ee3ab9df945afbf
Author: Andy Lester <andy@petdance.com>
Date:   Mon Jun 6 05:11:07 2005 -0500

    Random cleanups #47
    Message-ID: <20050606151107.GC7022@petdance.com>

    p4raw-id: //depot/perl@24735

I’ve basically reinstated the changes in 2f34f9d4, but with tests
this time.

It may not make sense for autouse to be exempt for newATTRSUB and
newXS, but keeping the logic surrounding the warning as close as
possible to being the same could allow future refactorings to
merge them.
MANIFEST
dist/autouse/t/autouse.t
dist/autouse/t/lib/MyTestModule2.pm [new file with mode: 0644]
op.c
sv.c
t/op/stash.t