10 run_multiple_progs('', \*DATA);
12 foreach my $code ('sub;', 'sub ($) ;', '{ $x = sub }', 'sub ($) && 1') {
14 like($@, qr/^Illegal declaration of anonymous subroutine at/,
15 "'$code' is illegal");
20 $::TODO = 'RT #17589 not completely resolved';
21 # Here's a patch. It makes "sub;" and similar report an error immediately
22 # from the lexer. However the solution is not complete, it doesn't
23 # handle the case "sub ($) : lvalue;" (marked as a TODO test), because
24 # it's handled by the lexer in separate tokens, hence more difficult to
26 my $code = 'sub ($) : lvalue;';
28 like($@, qr/^Illegal declaration of anonymous subroutine at/,
29 "'$code' is illegal");
32 eval "sub #foo\n{print 1}";
51 my $dummy = $n; # eval can't close on $n without internal reference
64 eval 'sub { print $n }';
76 eval 'sub Y { my $p = shift; $p->() }';
84 print sub { return "ok 1\n" } -> ();