From: Vincent Pit Date: Sun, 3 Jan 2010 15:33:35 +0000 (+0100) Subject: Allow "{sub f}" to compile X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fd909433c74372968d34d9cad8f4458ab60e19b4;p=p5sagit%2Fp5-mst-13.2.git Allow "{sub f}" to compile --- diff --git a/t/comp/parser.t b/t/comp/parser.t index 05c8d65..65315bc 100644 --- a/t/comp/parser.t +++ b/t/comp/parser.t @@ -3,7 +3,7 @@ # Checks if the parser behaves correctly in edge cases # (including weird syntax errors) -print "1..117\n"; +print "1..118\n"; sub failed { my ($got, $expected, $name) = @_; @@ -333,6 +333,11 @@ like($@, qr/BEGIN failed--compilation aborted/, 'BEGIN 7' ); like($@, qr/Identifier too long/, "too long id ticket case"); } +{ + eval qq[ {sub zlonk} ]; + is($@, '', 'sub declaration followed by a closing curly'); +} + # Add new tests HERE: # More awkward tests for #line. Keep these at the end, as they will screw diff --git a/toke.c b/toke.c index cec8ac2..4950958 100644 --- a/toke.c +++ b/toke.c @@ -7432,7 +7432,7 @@ Perl_yylex(pTHX) else if (*s != '{' && key == KEY_sub) { if (!have_name) Perl_croak(aTHX_ "Illegal declaration of anonymous subroutine"); - else if (*s != ';') + else if (*s != ';' && *s != '}') Perl_croak(aTHX_ "Illegal declaration of subroutine %"SVf, SVfARG(PL_subname)); }