From fd909433c74372968d34d9cad8f4458ab60e19b4 Mon Sep 17 00:00:00 2001 From: Vincent Pit Date: Sun, 3 Jan 2010 16:33:35 +0100 Subject: [PATCH] Allow "{sub f}" to compile --- t/comp/parser.t | 7 ++++++- toke.c | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) 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)); } -- 1.8.3.1