This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
sub.t: To-do test for recursive shared-hash-keys TARGs
authorFather Chrysostomos <sprout@cpan.org>
Sat, 15 Jun 2013 18:41:57 +0000 (11:41 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Fri, 26 Jul 2013 06:47:58 +0000 (23:47 -0700)
commit7f6ba6d234ccc0e3e085c7f74151d287c91be0b9
tree0929e68873dbb63726dfca59f3e357088cad9388
parent6f7e3040169a31244d7459c4fa0492602bc514df
sub.t: To-do test for recursive shared-hash-keys TARGs

This is only buggy under ithreads.

sub a {
  for (${\""}.${\""}) {
    $_ = $_[0] || __PACKAGE__;
    print "$_\n";
    a("road") unless $_[0];
    print "$_\n";
  }
}
a();

The outer call sets the scalar returned by ${\""}.${\""} to the cur-
rent package name.

The inner call sets it to "road".

Each call prints it twice, the outer call surrounding the inner call.
The output in 5.10-5.18 is:

main
road
road
road

because the inner call is clobbering the same scalar.  If __PACKAGE__
is changed to "main", it works, and prints

main
road
road
main

(as the script above also prints in 5.8.8).
t/op/sub.t