[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Perl::Critic Tests
- Subject: Re: Perl::Critic Tests
- From: Nick Prater <..hidden..>
- Date: Sat, 22 Apr 2017 07:37:25 +0100
To summarise discussion about Perl::Critic policy
ProhibitExplicitReturnUndef...
Matt Trout raised an issue that this policy leads to surprising
behaviour when a function is used in a hash assignment. This has lead to
security issues in other projects.
As an example conside the following code:
----
sub get_value {
return;
}
my %hash = (
row => get_value(),
id => 1
);
use Data::Dumper;
print Dumper \%hash;
----
which returns:
$VAR1 = {
'1' => undef,
'row' => 'id'
};
There was also discussion in the chat room:
https://matrix.to/#/!qyoLumPqusaXqFJNyK:matrix.org/$14924265961896415gvdcN:matrix.org
I prefer an explicit "return undef;" as I think it's clearer, more
obvious about the intention and less magical. Eric suggests we problably
want to switch from "no return at all" to "return undef".
I therefore propose that we do not enforce the
ProhibitExplicitReturnUndef policy and will add a comment to the tests
to explain why.
Thanks to k-man and dcg_mx for initiating and sharing the discussion
with Matt Trout.
Nick
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Ledger-smb-devel mailing list
..hidden..
https://lists.sourceforge.net/lists/listinfo/ledger-smb-devel