Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Perl-Critic CPAN distribution.

Report information
The Basics
Id: 65191
Status: new
Priority: 0/
Queue: Perl-Critic

People
Owner: Nobody in particular
Requestors: EDAVIS [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 1.111
Fixed in: (no value)



Subject: Suggested policy: forbid array on LHS of ~~
Download (untitled) / with headers
text/plain 712b
In perl 5.10.0, when smart matching was first introduced, you could say @a ~~ $x to test list membership (more or less). The semantics of this construct changed in 5.10.1 and now what it tests is whether $x contains a reference to the array @a. I suggest that the new behaviour is not particularly useful in itself (you can test C<ref($x) && $x eq \@a>, if that's what you really want, but you rarely do want that), and so code with the above smart match is most likely to be left over from perl 5.10.0 and will break with newer releases. Perlcritic should warn about C<@a ~~ $x> and suggest changing it to C<$x ~~ @a>, which will do what was probably intended under both 5.10.0 and newer perl versions.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.