From: Nicholas Clark Date: Fri, 23 Dec 2005 11:36:43 +0000 (+0000) Subject: Now that proxy subroutines can be unproxied in 2 places without X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2111d92849f8443baa1adfc372a6bedf4537f3e8;p=p5sagit%2Fp5-mst-13.2.git Now that proxy subroutines can be unproxied in 2 places without becoming the same newCONSTSUB, need an explicit check to avoid a warning about subroutines being redefined, as there has never been a warning when you assing the same subroutine to a glob's GvCV() p4raw-id: //depot/perl@26470 --- diff --git a/sv.c b/sv.c index 00261cd..1ad6636 100644 --- a/sv.c +++ b/sv.c @@ -3144,7 +3144,18 @@ Perl_sv_setsv_flags(pTHX_ SV *dstr, register SV *sstr, I32 flags) { /* Redefining a sub - warning is mandatory if it was a const and its value changed. */ - if (ckWARN(WARN_REDEFINE) + if (CvCONST(cv) && CvCONST((CV*)sref) + && cv_const_sv(cv) + == cv_const_sv((CV*)sref)) { + /* They are 2 constant subroutines + generated from the same constant. + This probably means that they are + really the "same" proxy subroutine + instantiated in 2 places. Most likely + this is when a constant is exported + twice. Don't warn. */ + } + else if (ckWARN(WARN_REDEFINE) || (CvCONST(cv) && (!CvCONST((CV*)sref) || sv_cmp(cv_const_sv(cv), diff --git a/t/op/gv.t b/t/op/gv.t index aa9383f..cf4108a 100755 --- a/t/op/gv.t +++ b/t/op/gv.t @@ -371,8 +371,7 @@ my $gr = eval '\*plunk' or die; my $w = ''; local $SIG{__WARN__} = sub { $w = $_[0] }; $result = *{$gr} = \&{"oonk"}; - like($w, qr/^Constant subroutine main::plunk redefined/, - "Redefining a constant sub should warn"); + is($w, '', "Redefining a constant sub to another constant sub with the same underlying value should not warn (It's just re-exporting, and that was always legal)"); } is (ref $::{oonk}, 'SCALAR', "Export doesn't affect original");