11 run_multiple_progs('', \*DATA);
13 foreach my $code ('sub;', 'sub ($) ;', '{ $x = sub }', 'sub ($) && 1') {
15 like($@, qr/^Illegal declaration of anonymous subroutine at/,
16 "'$code' is illegal");
21 $::TODO = 'RT #17589 not completely resolved';
22 # Here's a patch. It makes "sub;" and similar report an error immediately
23 # from the lexer. However the solution is not complete, it doesn't
24 # handle the case "sub ($) : lvalue;" (marked as a TODO test), because
25 # it's handled by the lexer in separate tokens, hence more difficult to
27 my $code = 'sub ($) : lvalue;';
29 like($@, qr/^Illegal declaration of anonymous subroutine at/,
30 "'$code' is illegal");
33 eval "sub #foo\n{print 1}";
52 my $dummy = $n; # eval can't close on $n without internal reference
65 eval 'sub { print $n }';
77 eval 'sub Y { my $p = shift; $p->() }';
85 print sub { return "ok 1\n" } -> ();
92 local $SIG{'__WARN__'} = sub { push @void_warnings, @_ };
98 Useless use of anonymous subroutine in void context at - line 5.
100 # [perl #71154] undef &$code makes $code->() die with: Not a CODE reference
101 sub __ANON__ { print "42\n" }
105 Undefined subroutine called at - line 4.
107 # NAME anon constant clobbering __ANON__
108 sub __ANON__ { "42\n" }
114 # NAME undef &anon giving it a freed GV
116 delete $::{__ANON__};
117 undef &$_; # SvREFCNT_dec + inc on a GV with a refcnt of 1
118 # so now SvTYPE(CvGV(anon)) is 0xff == freed
119 if (!eval { require B }) { # miniperl, presumably
122 print B::svref_2object($_)->GV->NAME, "\n";