summaryrefslogtreecommitdiff
path: root/t/op/hash.t
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2013-08-07 08:46:52 -0700
committerFather Chrysostomos <sprout@cpan.org>2013-08-09 19:28:33 -0700
commit649c173f8c6054f378a811701c168f02aba60e46 (patch)
tree0b7e1046de8ab40d0f536ecbe0c6d8a18d88043a /t/op/hash.t
parent03b0de9ff2f87112a5d4c2e0f433e84f0bbec56f (diff)
downloadperl-649c173f8c6054f378a811701c168f02aba60e46.tar.gz
Don’t stringify undef hash keys at compile time
$ ./perl -wIlib -Mconstant' u=>undef' -e '()=$a{+u} if $a' Use of uninitialized value at -e line 1. Well, I didn’t even execute that hash lookup, so why is it warning me about an uninitialized value? This is a compile-time optimisation to turn hash keys into shared hash key scalars (containing precomputed hashes) to speed up key lookup. It stringifies the hash key at compile time as part of the process. The value should not be stringified if that would cause observable difference with tied hashes. Commit 04698ff67 fixed this for refs, globs and regexps, but missed undef scalars. This could be considered part of bug #79178.
Diffstat (limited to 't/op/hash.t')
-rw-r--r--t/op/hash.t7
1 files changed, 6 insertions, 1 deletions
diff --git a/t/op/hash.t b/t/op/hash.t
index e0e8021e73..5f4c143fcd 100644
--- a/t/op/hash.t
+++ b/t/op/hash.t
@@ -42,7 +42,12 @@ is($destroyed, 1, 'Timely hash destruction with lvalue keys');
tie my %h, "bar";
() = $h{\'foo'};
is ref $key, SCALAR =>
- 'hash keys are not stringified during compilation';
+ 'ref hash keys are not stringified during compilation';
+ use constant u => undef;
+ no warnings 'uninitialized'; # work around unfixed bug #105918
+ () = $h{+u};
+ is $key, undef,
+ 'undef hash keys are not stringified during compilation, either';
}
# Part of RT #85026: Deleting the current iterator in void context does not