[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.