# Do a basic test on all the tied methods of Tie::Hash::NamedCapture
-print "1..13\n";
+plan(tests => 21);
# PL_curpm->paren_names can be a null pointer. See that this succeeds anyway.
'x' =~ /(.)/;
# SCALAR
is(scalar(%+), 3, "SCALAR");
is(scalar(%-), 3, "SCALAR");
+
+# Abuse all methods with undef as the first argument (RT #71828 and then some):
+
+is(Tie::Hash::NamedCapture::FETCH(undef, undef), undef, 'FETCH with undef');
+eval {Tie::Hash::NamedCapture::STORE(undef, undef, undef)};
+like($@, qr/Modification of a read-only value attempted/, 'STORE with undef');
+eval {Tie::Hash::NamedCapture::DELETE(undef, undef)};
+like($@, , qr/Modification of a read-only value attempted/,
+ 'DELETE with undef');
+eval {Tie::Hash::NamedCapture::CLEAR(undef)};
+like($@, qr/Modification of a read-only value attempted/, 'CLEAR with undef');
+is(Tie::Hash::NamedCapture::EXISTS(undef, undef), undef, 'EXISTS with undef');
+is(Tie::Hash::NamedCapture::FIRSTKEY(undef), undef, 'FIRSTKEY with undef');
+is(Tie::Hash::NamedCapture::NEXTKEY(undef, undef), undef, 'NEXTKEY with undef');
+is(Tie::Hash::NamedCapture::SCALAR(undef), undef, 'SCALAR with undef');
rx = PL_curpm ? PM_GETRE(PL_curpm) : NULL;
- if (!rx)
+ if (!rx || !SvROK(ST(0)))
XSRETURN_UNDEF;
SP -= items;
rx = PL_curpm ? PM_GETRE(PL_curpm) : NULL;
- if (!rx) {
+ if (!rx || !SvROK(ST(0))) {
if (!PL_localizing)
Perl_croak(aTHX_ "%s", PL_no_modify);
else
if (items != 2)
croak_xs_usage(cv, "$key, $flags");
- if (!rx)
+ if (!rx || !SvROK(ST(0)))
Perl_croak(aTHX_ "%s", PL_no_modify);
SP -= items;
rx = PL_curpm ? PM_GETRE(PL_curpm) : NULL;
- if (!rx)
+ if (!rx || !SvROK(ST(0)))
Perl_croak(aTHX_ "%s", PL_no_modify);
SP -= items;
rx = PL_curpm ? PM_GETRE(PL_curpm) : NULL;
- if (!rx)
+ if (!rx || !SvROK(ST(0)))
XSRETURN_UNDEF;
SP -= items;
rx = PL_curpm ? PM_GETRE(PL_curpm) : NULL;
- if (!rx)
+ if (!rx || !SvROK(ST(0)))
XSRETURN_UNDEF;
SP -= items;
rx = PL_curpm ? PM_GETRE(PL_curpm) : NULL;
- if (!rx)
+ if (!rx || !SvROK(ST(0)))
XSRETURN_UNDEF;
SP -= items;
rx = PL_curpm ? PM_GETRE(PL_curpm) : NULL;
- if (!rx)
+ if (!rx || !SvROK(ST(0)))
XSRETURN_UNDEF;
SP -= items;