-
Notifications
You must be signed in to change notification settings - Fork 581
Use of uninitialized value within @_ in anonymous array ([]) #22884
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Unrelated to Data::Dumper:
|
@mauke, am I correct in thinking that this ticket is Not a Bug, hence closable? |
Why do you think it's not a bug? |
That was simply my interpretation of the fact that you started off your reply with "Unrelated to Data::Dumper." But, given that Data::Dumper itself has warnings enabled, wouldn't we expect that warning? |
The first warning, yes. But as the reporter says:
I suspect this is caused by the hash element being in "potential lvalue" context (because it is a subroutine argument). If the hash element doesn't exist yet, it will be created on demand, but only if the subroutine assigns to |
Oooookay ... so what should we do about this. Would documenting the anomaly be sufficient? |
There is no hash lookup in the visible Perl code, so preferably we wouldn't emit a warning for code that the user didn't write. Not sure how feasible this would be to implement. |
This looks like #22423 |
It does not seem a bug in
There are completly different construction. In 2'th example, example in 1'th is more interesting. let's separate key construction: In that construction, perl silently fill lost chain element 'data'. It will create second anonymous empty hash, addressed by 'data' key.
of course, value of returned key This is not a bug in Data::Dumper module, but in your script. You should look, key or element exists or not, by using exists . It is base for structured data manipulation. I tested it on This is perl 5, version 28, subversion 1 (v5.28.1) built for x86_64-linux-gnu-thread-multi , but this is not changed by years. I run this example code, and my result is:
Only one difference between my older perl and reported there, is information in printed warning. nothing else. |
The confusing warning seems like a bug to me. My WIP fix for #22423 also fixes this:
I hadn't realized is only started in 5.34:
which leads me to look at what specifically started the extra warning. |
The 5.32 vs 5.34 difference is due to |
Yay, thank you :) |
Uh oh!
There was an error while loading. Please reload this page.
Module: Data::Dumper
Description
Referencing a non-existent hash results in:
Steps to Reproduce
Original reproduction code:
Result:
This was shortened by Daniel Böhmer to:
$ perl -MData::Dumper -we 'my (%hash1,%hash2); Dumper($hash1{$hash2{key}})'
Result:
Expected behavior
The warning about "anonymous array" not to be there.
Perl configuration
The text was updated successfully, but these errors were encountered: