This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #46947] Parse method-BLOCK arguments as a term
authorFather Chrysostomos <sprout@cpan.org>
Mon, 11 Aug 2014 16:51:34 +0000 (09:51 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Wed, 13 Aug 2014 01:00:51 +0000 (18:00 -0700)
commitb5b6210a9764d431c3ac672d95f351856885b7fe
tree771ce7b622e509f8e2fc9ccc23e20c542d0bdde0
parent48bbb9f89ad796281ab8c7a122d14c2d8d7bc579
[perl #46947] Parse method-BLOCK arguments as a term

(C.f. bug #114222 and commit 52d0e95b, which did the same thing
for ‘use’.)

When parsing the arguments following a method name and a block (for
‘method { $obj } LIST‘ syntax), the lexer was using heuristics to
determine whether an opening brace was a hash constructor or a block,
as it does at the beginning of a statement.  In every case in which it
determined it was a block, the parser would them throw a syntax error.

In this case, the lexer should not be trying to guess, since we *know*
it can only be a hash here.

This was the result:

$ perl -e 'method {$obj} {$foo=>undef}'
syntax error at -e line 1, near "} {"
Execution of -e aborted due to compilation errors.

Now we get this:

$ ./miniperl -e 'method {$obj} {$foo=>undef}'
Can't call method "method" on an undefined value at -e line 1.

as expected.
perl.h
t/comp/parser.t
toke.c