Don’t stringify undef hash keys at compile time
authorFather Chrysostomos <sprout@cpan.org>
Wed, 7 Aug 2013 15:46:52 +0000 (08:46 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 10 Aug 2013 02:28:33 +0000 (19:28 -0700)
commit649c173f8c6054f378a811701c168f02aba60e46
tree0b7e1046de8ab40d0f536ecbe0c6d8a18d88043a
parent03b0de9ff2f87112a5d4c2e0f433e84f0bbec56f
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.
op.c
t/op/hash.t