Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[perl #114018] Let eval close over stale vars in active sub
See also commit cae5dbb. These two lines should never produce different values: print $x, "\n"; print eval '$x', "\n"; But they were producing different values if $x happened to have the tale flag set. Even if my in false conditional is not supported (this was the cause of the bug report), it should still work; and it is not the only way to get a stale lexical in an active sub (just the easiest way). As long as the sub containing the eval is active, the eval should be able to see the same variables, stale or not. However, this does get a bit tricky in cases like this, which legiti- mately warn (from t/lib/warnings/pad): { my $x = 1; $y = \$x; # force abandonment rather than clear-in-place at scope exit sub f2 { eval '$x' } } f2(); In this case the f2 sub does not explicitly close over the $x, so by the time the eval is reached the ‘right’ $x is gone. It is only in those cases where the sub containing the eval has the stale variable in its own pad that we can safely ignore the stale flag.
- Loading branch information
Father Chrysostomos
committed
Aug 8, 2012
1 parent
710ba57
commit 7ef3083
Showing
3 changed files
with
20 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters