develooper Front page | perl.perl5.porters | Postings from January 2018

Re: [perl #132783] Blead Breaks CPAN: ADAMK/SQL-String-0.02.tar.gz

Thread Previous | Thread Next
January 31, 2018 12:16
Re: [perl #132783] Blead Breaks CPAN: ADAMK/SQL-String-0.02.tar.gz
Message ID:
Dave Mitchell writes:

> The test case reduces to 
>     use warnings; 
>     package Foo { use overload '.=' => sub  { return "foo"; }; } 
>     my $s = bless [], 'Foo'; 
>     my $x; 
>     $s .= $x; 
> which used to be silent, but now emits: 
>     Use of uninitialized value $x in concatenation (.) or string 
> I'll look into this further when I can find some time. 

Why is it wrong for that to warn?

$x is undef, and is being supplied to the concatenation operator. Admittedly an overloaded operator that in this case doesn't care that it's undef, but why should Perl start presuming that undef-s are acceptable simply because an operator has been overloaded?

I couldn't see anything in overload or in perldiag mentioning that this warning doesn't apply to an overloaded operation. Many uses of overloading are intended to be largely transparent to the user, so they may be surprised to not get a warning that they requested.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About