Subject: | bless {} probably contains a hash constructor, not a block |
PPI parses 'bless {}' as
PPI::Document
PPI::Statement
[ 1, 1, 1 ] PPI::Token::Word 'bless'
PPI::Structure::Block { ... }
The bless documentation says that the first argument is a reference.
While a block can certainly yield a reference, 'bless {; +{}}' (forcing
the outer curlys to be a block, and the inner to be a hash constructor)
fails to parse in Perl 5.6.2, 5.8.9, 5.10.1, 5.12.2, and 5.13.8, so I
conclude that in any working Perl of semi-recent vintage, 'bless {...}'
must contain an anonymous hash, not a block. But I am a little nervous
about the conclusion, since I can not find in the docs anything that
says unequivocally that the first argument to bless() can not be a block.
A patch is in preparation, but I wanted to get the RT ticket filed
first, so I could reference it in the commit comment. The related
Perl::Critic ticket is https://rt.cpan.org/Ticket/Display.html?id=64132
If you would like to see more support for the proposed change, I can
think of three things to do:
* Scavenge CPAN, and use B::Concise to try to figure out what Perl is doing;
* Submit a wishlist to Perl, asking for clarification;
* Read the code.
I don't really hold much hope for the last, since generally when I try
it my brain just bounces off. But I will certainly attempt to gather any
further supporting information you would like to see.