diff options
author | Father Chrysostomos <sprout@cpan.org> | 2013-06-01 18:39:33 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2013-06-02 11:54:55 -0700 |
commit | 83a72a15a3e8908c9fea8334e083e9329d425feb (patch) | |
tree | d655f4fe058c725f8fdc9c811263dbfee22d2abb /t/op/lexsub.t | |
parent | fe54d63b71ffdc66546e8a06b4ea561f58af2fc2 (diff) | |
download | perl-83a72a15a3e8908c9fea8334e083e9329d425feb.tar.gz |
Name lexical constants
$ ./perl -Ilib -Mfeature=:all -e 'my sub a(){44} a()'
The lexical_subs feature is experimental at -e line 1.
Assertion failed: (hek), function Perl_ck_subr, file op.c, line 10558.
Abort trap: 6
The experimental warning is expected. The assertion failure is not.
When a call checker is invoked, the name of the subroutine is passed
to it. op.c:ck_subr gets the name from the CV’s cv (CvGV) or, in the
case of lexical subs, from its name hek (CvNAME_HEK). If neither
exists, ck_subr cannot cope.
Lexical subs never have a GV pointer. Lexical constants were acci-
dentally having neither a GV pointer nor a hek. They should have a
hek, like other lexical subs.
Diffstat (limited to 't/op/lexsub.t')
-rw-r--r-- | t/op/lexsub.t | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/t/op/lexsub.t b/t/op/lexsub.t index 8d768cc833..b6960e03ed 100644 --- a/t/op/lexsub.t +++ b/t/op/lexsub.t @@ -8,7 +8,7 @@ BEGIN { *bar::like = *like; } no warnings 'deprecated'; -plan 130; +plan 132; # -------------------- Errors with feature disabled -------------------- # @@ -299,6 +299,8 @@ sub make_anon_with_state_sub{ is ref $_[0], 'ARRAY', 'state sub with proto'; } p(my @a); + state sub q () { 45 } + is q(), 45, 'state constant called with parens'; } { state sub x; @@ -596,6 +598,8 @@ not_lexical11(); is ref $_[0], 'ARRAY', 'my sub with proto'; } p(my @a); + my sub q () { 46 } + is q(), 46, 'my constant called with parens'; } { my sub x; |