diff options
author | Peter Martini <PeterCMartini@GMail.com> | 2013-08-06 03:16:35 -0400 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2013-08-06 05:53:07 -0700 |
commit | eb40d2ca32bab47c140b354a1907b0ba5b74f9bc (patch) | |
tree | 926a5446502b2b60e6390b9e1b3c86a9c270150c /t | |
parent | 51da40ed5ad9513dc5f2213b76a414e9eb4c239d (diff) | |
download | perl-eb40d2ca32bab47c140b354a1907b0ba5b74f9bc.tar.gz |
[perl #2726] Prototype is not applied until BLOCK is defined
In the case of a sub definition with a prototype, the prototype
is not attached to the sub until after the body is completely
defined. This means that any sub which calls itself will
not honor its prototype unless the prototype was declared prior to
the sub's definition. Whether or not this behavior is desirable is
debatable, but its far too late to do anything about it other than
document it and test to make sure it doesn't change.
Diffstat (limited to 't')
-rw-r--r-- | t/comp/proto.t | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/t/comp/proto.t b/t/comp/proto.t index 947a2327a0..47ebf74749 100644 --- a/t/comp/proto.t +++ b/t/comp/proto.t @@ -18,7 +18,7 @@ BEGIN { # strict use strict; -print "1..199\n"; +print "1..201\n"; my $i = 1; @@ -559,6 +559,13 @@ print "ok ", $i++, " star3 STDERR\n"; print "not " unless eval 'star4 STDERR; 1'; print "ok ", $i++, " star4 STDERR\n"; +# [perl #2726] +# Test that prototype binding is late +print "not " unless eval 'sub l564($){ l564(); } 1'; +print "ok ", $i++, " prototype checking not done within initial definition\n"; +print "not " if eval 'sub l566($); sub l566($){ l566(); } 1'; +print "ok ", $i++, " prototype checking done if sub pre-declared\n"; + # test scalarref prototype sub sreftest (\$$) { print "not " unless ref $_[0]; |