Skip to content

Conversation

@mauke
Copy link
Contributor

@mauke mauke commented Aug 17, 2025

When the "Use of uninitialized value" warning tries to find the source of the problem, it skips over builtin::reftype/builtin::refaddr operations and blames their arguments:

$ perl -wE 'my $x = 42; $_ = reftype($x) eq ""'
Use of uninitialized value $x in string eq at -e line 1.
$ perl -wE 'my $x = 42; $_ = refaddr($x) eq ""'
Use of uninitialized value $x in string eq at -e line 1.

This is wrong because $x is clearly defined.

This patch teaches S_find_uninit_var that reftype/refaddr can return undef even if their arguments are perfectly defined.

Fixes #19273.


  • This set of changes does not require a perldelta entry.

When the "Use of uninitialized value" warning tries to find the source
of the problem, it skips over builtin::reftype/builtin::refaddr
operations and blames their arguments:

    $ perl -wE 'my $x = 42; $_ = reftype($x) eq ""'
    Use of uninitialized value $x in string eq at -e line 1.
    $ perl -wE 'my $x = 42; $_ = refaddr($x) eq ""'
    Use of uninitialized value $x in string eq at -e line 1.

This is wrong because $x is clearly defined.

This patch teaches S_find_uninit_var that reftype/refaddr can return
undef even if their arguments are perfectly defined.

Fixes Perl#19273.
@mauke mauke merged commit dd99ef8 into Perl:blead Aug 18, 2025
34 checks passed
@mauke mauke deleted the fix-19273-uninit-refops branch August 18, 2025 04:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

builtin::reftype string comparison provides incorrect warning

2 participants