summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--op.c5
-rw-r--r--pad.c2
-rw-r--r--t/op/lexsub.t16
3 files changed, 19 insertions, 4 deletions
diff --git a/op.c b/op.c
index d44a7ea08b..0bb41401cd 100644
--- a/op.c
+++ b/op.c
@@ -7935,7 +7935,8 @@ Perl_newMYSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block)
CvNAME_HEK_set(*spot, hek =
share_hek(
PadnamePV(name)+1,
- PadnameLEN(name)-1 * (PadnameUTF8(name) ? -1 : 1), hash
+ (PadnameLEN(name)-1) * (PadnameUTF8(name) ? -1 : 1),
+ hash
)
);
CvLEXICAL_on(*spot);
@@ -8092,7 +8093,7 @@ Perl_newMYSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block)
U32 hash;
PERL_HASH(hash, PadnamePV(name)+1, PadnameLEN(name)-1);
hek = share_hek(PadnamePV(name)+1,
- PadnameLEN(name)-1 * (PadnameUTF8(name) ? -1 : 1),
+ (PadnameLEN(name)-1) * (PadnameUTF8(name) ? -1 : 1),
hash);
}
CvNAME_HEK_set(cv, hek);
diff --git a/pad.c b/pad.c
index 9da55362aa..a9581f8179 100644
--- a/pad.c
+++ b/pad.c
@@ -2128,7 +2128,7 @@ S_cv_clone_pad(pTHX_ CV *proto, CV *cv, CV *outside, bool newcv)
CvNAME_HEK_set(
sv,
share_hek(SvPVX_const(namesv)+1,
- SvCUR(namesv) - 1
+ (SvCUR(namesv) - 1)
* (SvUTF8(namesv) ? -1 : 1),
hash)
);
diff --git a/t/op/lexsub.t b/t/op/lexsub.t
index e170555517..32f8bc7eac 100644
--- a/t/op/lexsub.t
+++ b/t/op/lexsub.t
@@ -7,7 +7,7 @@ BEGIN {
*bar::is = *is;
*bar::like = *like;
}
-plan 144;
+plan 146;
# -------------------- Errors with feature disabled -------------------- #
@@ -424,6 +424,13 @@ is runperl(switches => ['-lXMfeature=:all'],
" - no 'No comma allowed' after state sub\n";
curr_test(curr_test()+1);
}
+{
+ use utf8;
+ state sub φου;
+ eval { φου };
+ like $@, qr/^Undefined subroutine &φου called at /,
+ 'state sub with utf8 name';
+}
# -------------------- my -------------------- #
@@ -793,6 +800,13 @@ is runperl(switches => ['-lXMfeature=:all'],
my sub y :prototype() {$x};
is y, 43, 'my sub that looks like constant closure';
}
+{
+ use utf8;
+ my sub φου;
+ eval { φου };
+ like $@, qr/^Undefined subroutine &φου called at /,
+ 'my sub with utf8 name';
+}
# -------------------- Interactions (and misc tests) -------------------- #