which were previously erroneously recognized as compound statements. It also fixes the original compound regression test, added in 0f74bdc1aa05fd5732c85d44e315046568e65641 as a failing test (since eval is not a compound statement as per perlsyn).
The logic is based on the assumption that curly braces inside parentheses are constructors unless they are arguments to one of the block built-ins (map, grep, sort and eval). Subs with the & prototype do not compile with parentheses and neither do loose blocks:
$ perl -e 'sub foo (&) { $_[0]->() } foo({ print "Hello" })'
Type of arg 1 to main::foo must be block or sub {} (not anonymous hash ({})) at -e line 1, near "})"
Execution of -e aborted due to compilation errors.
$ perl -e '({ print "Hello"; })'
syntax error at -e line 1, near "; }"
Execution of -e aborted due to compilation errors.
This change fixes parsing of constructs like these:
which were previously erroneously recognized as compound statements. It also fixes the original compound regression test, added in 0f74bdc1aa05fd5732c85d44e315046568e65641 as a failing test (since eval is not a compound statement as per perlsyn).
The logic is based on the assumption that curly braces inside parentheses are constructors unless they are arguments to one of the block built-ins (map, grep, sort and eval). Subs with the & prototype do not compile with parentheses and neither do loose blocks:
This also fixes issue #68.