-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
anon hashref after operator treated as code block #34
Comments
Request for comments: are there more operators that dictate that what follows them must be a hash constructor and not a block? %PPI::Lexer::CURLY_CLASSES contains, among other things, operators that cannot be immediately followed by a code block. Some of those, like '+' and 'return', are documented as such; others like 'bless' and (I assume) '||=' were determined experimentally. Have there been problems in the past trying to expand the list of operators trusted to not be followed by blocks? Can PPI take another bite out of the block/hash constructor ambiguity problem via these operators? E.g., these compile (under 5.16.3 and 5.8.8):
and these don't:
The number of operators that don't accept a block on the right side appears to be large: ||, &&, &&=, //, //=, to name a few. |
Doing it manually this way is not strictly right. There are plenty of So I tend to ignore those cases. Adam
|
Currently PPI disambiguates hashes and blocks by checking for a few cases where a hash interpretation of {} compiles and a block interpretation does not: 'scalar', '||=', ',', '=', '=>'. In practical terms:
Are you asserting (1) or (2)? If not, is there any reason to not pursue (3)? |
My general rule is that pp I should be able to correctly match all real Adam
|
from Perl-Critic/Perl-Critic#192 , hash constructor parses as a code block
At least some other operators do not parse it as a block:
The text was updated successfully, but these errors were encountered: