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

[perl #133776] Carp.pm useless warning "Use of uninitialized value$error[1] in join or string"

Thread Previous
From:
Chris Wagner via RT
Date:
January 25, 2019 05:52
Subject:
[perl #133776] Carp.pm useless warning "Use of uninitialized value$error[1] in join or string"
Message ID:
rt-4.0.24-30500-1548024515-1196.133776-15-0@perl.org
On Sat, 19 Jan 2019 08:03:37 -0800, jkeenan wrote:
> OTOH, filtering out the arguments which are undefined values would be
> consistent with the 'warn' and 'die' built-ins which 'carp' and
> 'croak' emulate.
> 
> #####
> $ perl -e 'warn("alpha", undef, "beta") unless 1 == 0;'
> alphabeta at -e line 1.
> 
> $ perl -e 'die("alpha", undef, "beta") unless 1 == 0;'
> alphabeta at -e line 1.
> #####

Eh, warn() and die() are not that nice. :)
$ perl -w
warn("alpha", undef, "beta");
Use of uninitialized value in warn at - line 1.
alphabeta at - line 1.

$ perl -w
die("alpha", undef, "beta");
Use of uninitialized value in die at - line 1.
alphabeta at - line 1.

I say we just add the defined check because undef()'s just smash down to blank anyway.

We "could":
sub ret_backtrace {
    my ( $i, @error ) = @_;
    my $mess;
-    my $err = join '', @error;
+    if (warnings::enabled("uninitialized") && scalar grep {!defined} @error) {
+        carp "Use of  unititialized....";
+    }
+    my $err = join '', grep defined, @error;
    $i++;


Thanks.






---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=133776

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About