summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Gasper <felipe@felipegasper.com>2022-10-31 16:34:11 -0400
committerPaul Evans <leonerd@leonerd.org.uk>2022-11-16 17:54:31 +0000
commit20d507b5869b116c3b1f8aeea48fbfbf68dfce60 (patch)
tree83ce8d7f4abe25013c9ef1dad3258da56d82e48f
parenteae81231471af18d22af6f186f0af65ce46dafb1 (diff)
downloadperl-20d507b5869b116c3b1f8aeea48fbfbf68dfce60.tar.gz
Fail attempts to pass anonsub to \$ prototype.
Issue #20384
-rw-r--r--op.c2
-rw-r--r--t/comp/proto.t23
2 files changed, 23 insertions, 2 deletions
diff --git a/op.c b/op.c
index 55f8c6adcb..428364a6b1 100644
--- a/op.c
+++ b/op.c
@@ -3453,7 +3453,7 @@ Perl_op_lvalue_flags(pTHX_ OP *o, I32 type, U32 flags)
* set flag here.
* See also https://github.com/Perl/perl5/issues/20384
*/
- goto do_next;
+ goto nomod;
}
/* [20011101.069 (#7861)] File test operators interpret OPf_REF to mean that
diff --git a/t/comp/proto.t b/t/comp/proto.t
index 39891b44dd..48ae0d2ec0 100644
--- a/t/comp/proto.t
+++ b/t/comp/proto.t
@@ -18,7 +18,7 @@ BEGIN {
# strict
use strict;
-print "1..215\n";
+print "1..216\n";
my $i = 1;
@@ -892,3 +892,24 @@ $_ = sub ($$$$$$$) {};
@_ = (1, 2, 3, prototype(), 4, 5, 6);
print "not " unless "@_" eq '1 2 3 $$$$$$$ 4 5 6';
print "ok ", $i++, " - [perl #123514] (got @_)\n";
+
+{
+ my $weird_failure = q<>;
+
+ if (eval 'sub scalarref (\$) { }; scalarref( sub {} ); 1') {
+ print "not ok $i: Unexpected scalarref success!\n";
+ }
+ else {
+ if ($@ !~ m/anonymous subroutine/ || $@ !~ m/scalarref/) {
+ $weird_failure = $@;
+
+ $weird_failure =~ s/^/# /m;
+
+ print "# Unexpected error (or none):$/$weird_failure";
+ }
+
+ print( ($weird_failure ? 'not ok' : 'ok') . " $i - anonsub passed to \\\$\n" );
+ }
+
+ $i++;
+}