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).
require './test.pl';
}
-plan( tests => 16 );
+plan( tests => 17 );
sub empty_sub {}
undef *bar;
print "ok\n";
end
+
+# The outer call sets the scalar returned by ${\""}.${\""} to the current
+# package name.
+# The inner call sets it to "road".
+# Each call records the value twice, the outer call surrounding the inner
+# call. In 5.10-5.18 under ithreads, what gets pushed is
+# qw(main road road road) because the inner call is clobbering the same
+# scalar. If __PACKAGE__ is changed to "main", it works, the last element
+# becoming "main".
+my @scratch;
+sub a {
+ for (${\""}.${\""}) {
+ $_ = $_[0];
+ push @scratch, $_;
+ a("road",1) unless $_[1];
+ push @scratch, $_;
+ }
+}
+a(__PACKAGE__);
+require Config;
+$::TODO = "not fixed yet" if $Config::Config{useithreads};
+is "@scratch", "main road road main",
+ 'recursive calls do not share shared-hash-key TARGs';