summaryrefslogtreecommitdiff
path: root/op.c
diff options
context:
space:
mode:
authorTomasz Konojacki <me@xenu.pl>2020-12-30 14:03:02 +0100
committerKarl Williamson <khw@cpan.org>2020-12-30 07:29:22 -0700
commit07319fdbb283f93cb655c3106b5237cbc7272038 (patch)
tree4f15778ae23dce3cfd771ef03559906725de556d /op.c
parent4cfbe5474a5c5f852a6dbf0138dc796c2800be93 (diff)
downloadperl-07319fdbb283f93cb655c3106b5237cbc7272038.tar.gz
op.c: croak on "my $_" when "use utf8" is in effect
Fixes #18449
Diffstat (limited to 'op.c')
-rw-r--r--op.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/op.c b/op.c
index b2e12dd0c0..dce844d297 100644
--- a/op.c
+++ b/op.c
@@ -730,6 +730,7 @@ PADOFFSET
Perl_allocmy(pTHX_ const char *const name, const STRLEN len, const U32 flags)
{
PADOFFSET off;
+ bool is_idfirst, is_default;
const bool is_our = (PL_parser->in_my == KEY_our);
PERL_ARGS_ASSERT_ALLOCMY;
@@ -738,14 +739,15 @@ Perl_allocmy(pTHX_ const char *const name, const STRLEN len, const U32 flags)
Perl_croak(aTHX_ "panic: allocmy illegal flag bits 0x%" UVxf,
(UV)flags);
+ is_idfirst = flags & SVf_UTF8
+ ? isIDFIRST_utf8_safe((U8*)name + 1, name + len)
+ : isIDFIRST_A(name[1]);
+
+ /* $_, @_, etc. */
+ is_default = len == 2 && name[1] == '_';
+
/* complain about "my $<special_var>" etc etc */
- if ( len
- && !( is_our
- || isALPHA(name[1])
- || ( (flags & SVf_UTF8)
- && isIDFIRST_utf8_safe((U8 *)name+1, name + len))
- || (name[1] == '_' && len > 2)))
- {
+ if (!is_our && (!is_idfirst || is_default)) {
const char * const type =
PL_parser->in_my == KEY_sigvar ? "subroutine signature" :
PL_parser->in_my == KEY_state ? "\"state\"" : "\"my\"";