Branch: refs/heads/blead
Home: https://github.com/Perl/perl5
Commit: 4a414abba40e6797ad6349011f8c20eac14c2b8d
https://github.com/Perl/perl5/commit/4a414abba40e6797ad6349011f8c20eac14c2b8d
Author: Lukas Mai <[email protected]>
Date: 2024-02-08 (Thu, 08 Feb 2024)
Changed paths:
M sv.c
M t/lib/warnings/9uninit
Log Message:
-----------
mention length() in "uninitialized value" warnings
When perl looks for the source of "uninitialized value" warnings, it
treats length() as transparent: length(X) is undef iff X is undef, so it
makes sense to ignore length() when looking for the origin of the undef
value. However, this makes for misleading diagnostics: If $x is undef,
then 'length($x) == 0' triggers a "Use of uninitialized value $x in
numeric eq (==)" warning. This is correct insofar as (==) encountered an
undef value and $x is its origin, but incorrect in that $x is not one of
the operands of (==) in the source code.
This patch skips over length() when looking for the origin of undef (as
before), but adds "length(...)" around the name of the variable found,
if any.
Before:
$ perl -we 'my $x; $_ = length $x == 0'
Use of uninitialized value $x in numeric eq (==) at -e line 1.
(Misleading: $x is not an operand of (==).)
After:
$ perl -we 'my $x; $_ = length $x == 0'
Use of uninitialized value length($x) in numeric eq (==) at -e line 1.
Fixes #21930.
Commit: 1b0ae1279c041daa07b860f7bcbcfce62123bfd2
https://github.com/Perl/perl5/commit/1b0ae1279c041daa07b860f7bcbcfce62123bfd2
Author: Lukas Mai <[email protected]>
Date: 2024-02-08 (Thu, 08 Feb 2024)
Changed paths:
M sv.c
Log Message:
-----------
special-case shift/pop/splice in "uninitialized value" warnings
Before the preceding commit, this warning was halfway correct:
$ perl -we 'my @x; $_ = length(shift @x) == 0;'
Use of uninitialized value within @x in numeric eq (==) at -e line 1.
The "uninitialized value" did come from @x (sort of), but it was never
an element of @x, and no element of @x was used as an operand of (==).
After the preceding commit, we get:
Use of uninitialized value length(within @x) in numeric eq (==) at -e line
1.
... which is invalid code. With this commit, we get:
Use of uninitialized value length(shift(@x)) in numeric eq (==) at -e line
1.
(The same logic applies to pop().)
Also, splice() was overly optimistic in assigning blame:
$ perl -we 'my @x = 42; $_ = splice(@x, 0, 0) == 0'
Use of uninitialized value within @x in numeric eq (==) at -e line 1.
@x doesn't contain any undefs. The undef encountered by (==) was
returned from splice itself; it didn't come from any of splice's
arguments, so mentioning @x was just wrong.
With this commit we get:
Use of uninitialized value in numeric eq (==) at -e line 1.
Commit: fd43d22ccafc3c907561cebbc48338b362006df4
https://github.com/Perl/perl5/commit/fd43d22ccafc3c907561cebbc48338b362006df4
Author: Lukas Mai <[email protected]>
Date: 2024-02-08 (Thu, 08 Feb 2024)
Changed paths:
M t/lib/warnings/9uninit
Log Message:
-----------
add tests for new "uninitialized value" warnings
Commit: a8d986b30eb356a56fa467c8753af0d122b0fcd7
https://github.com/Perl/perl5/commit/a8d986b30eb356a56fa467c8753af0d122b0fcd7
Author: Lukas Mai <[email protected]>
Date: 2024-02-08 (Thu, 08 Feb 2024)
Changed paths:
M pod/perldelta.pod
Log Message:
-----------
add perldelta entry for new "uninitialized value" warnings
Commit: 3baf103ace61b11c5d5c72a7bbd3ff909d8a96c0
https://github.com/Perl/perl5/commit/3baf103ace61b11c5d5c72a7bbd3ff909d8a96c0
Author: Lukas Mai <[email protected]>
Date: 2024-02-08 (Thu, 08 Feb 2024)
Changed paths:
M sv.c
M t/lib/warnings/9uninit
Log Message:
-----------
fix "uninitialized value" warnings for readline()
Like getc or (sys)read, readline can return undef even if its argument
is fully defined.
Compare: https://github.com/Perl/perl5/compare/ccd5fe1fb534...3baf103ace61