summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--op.c1
-rw-r--r--sv.c1
-rw-r--r--t/lib/warnings/op26
3 files changed, 18 insertions, 10 deletions
diff --git a/op.c b/op.c
index 97407ad81a..257e2214d3 100644
--- a/op.c
+++ b/op.c
@@ -6592,6 +6592,7 @@ Perl_newATTRSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block)
strEQ(hvname, "autouse"))
))
|| (CvCONST(cv)
+ && ckWARN_d(WARN_REDEFINE)
&& (!const_sv || sv_cmp(cv_const_sv(cv), const_sv))))
{
const line_t oldline = CopLINE(PL_curcop);
diff --git a/sv.c b/sv.c
index 0095e072e7..d4f0373b21 100644
--- a/sv.c
+++ b/sv.c
@@ -3833,6 +3833,7 @@ S_glob_assign_ref(pTHX_ SV *const dstr, SV *const sstr)
)
)
|| (CvCONST(cv)
+ && ckWARN_d(WARN_REDEFINE)
&& (!CvCONST((const CV *)sref)
|| sv_cmp(cv_const_sv(cv),
cv_const_sv((const CV *)
diff --git a/t/lib/warnings/op b/t/lib/warnings/op
index 1a1bb26b7f..6c1f1f1a6f 100644
--- a/t/lib/warnings/op
+++ b/t/lib/warnings/op
@@ -732,18 +732,28 @@ EXPECT
Constant subroutine fred redefined at - line 4.
########
# op.c
+sub fred () { 1 }
+sub fred () { 2 }
+EXPECT
+Constant subroutine fred redefined at - line 3.
+########
+# op.c
+sub fred () { 1 }
+*fred = sub () { 2 };
+EXPECT
+Constant subroutine main::fred redefined at - line 3.
+########
+# op.c
no warnings 'redefine' ;
sub fred () { 1 }
sub fred () { 2 }
EXPECT
-Constant subroutine fred redefined at - line 4.
########
# op.c
no warnings 'redefine' ;
sub fred () { 1 }
*fred = sub () { 2 };
EXPECT
-Constant subroutine main::fred redefined at - line 4.
########
# op.c
use warnings 'redefine' ;
@@ -1240,22 +1250,20 @@ EXPECT
Constant subroutine frèd redefined at - line 6.
########
# op.c
-no warnings 'redefine' ;
use utf8;
use open qw( :utf8 :std );
sub frèd () { 1 }
sub frèd () { 2 }
EXPECT
-Constant subroutine frèd redefined at - line 6.
+Constant subroutine frèd redefined at - line 5.
########
# op.c
-no warnings 'redefine' ;
use utf8;
use open qw( :utf8 :std );
sub frèd () { 1 }
*frèd = sub () { 2 };
EXPECT
-Constant subroutine main::frèd redefined at - line 6.
+Constant subroutine main::frèd redefined at - line 5.
########
# op.c
use warnings 'redefine' ;
@@ -1280,20 +1288,18 @@ EXPECT
Constant subroutine ᚠርƊ redefined at - line 6.
########
# op.c
-no warnings 'redefine' ;
use utf8;
use open qw( :utf8 :std );
sub ᚠርƊ () { 1 }
sub ᚠርƊ () { 2 }
EXPECT
-Constant subroutine ᚠርƊ redefined at - line 6.
+Constant subroutine ᚠርƊ redefined at - line 5.
########
# op.c
-no warnings 'redefine' ;
use utf8;
use open qw( :utf8 :std );
sub ᚠርƊ () { 1 }
*ᚠርƊ = sub () { 2 };
EXPECT
-Constant subroutine main::ᚠርƊ redefined at - line 6.
+Constant subroutine main::ᚠርƊ redefined at - line 5.
########