diff options
author | Father Chrysostomos <sprout@cpan.org> | 2012-07-04 23:18:32 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-09-15 22:44:56 -0700 |
commit | 18f703895eca8c44a852a7e191cb3fdbb65d6891 (patch) | |
tree | fc46d76d53026b0159046055d50dce9039d04682 /t/cmd | |
parent | 24b6ef70a86a5d0e357194d0de0d4698aa6f7197 (diff) | |
download | perl-18f703895eca8c44a852a7e191cb3fdbb65d6891.tar.gz |
Let barewords look up our subs
These take precedence over built-in keywords (just as my $AUTOLOAD
shadows the package var), but not the keyword plugin, as the latter
takes precedence over labels, and these don’t.
Diffstat (limited to 't/cmd')
-rw-r--r-- | t/cmd/lexsub.t | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/t/cmd/lexsub.t b/t/cmd/lexsub.t index cef8070abc..ef2581e871 100644 --- a/t/cmd/lexsub.t +++ b/t/cmd/lexsub.t @@ -7,7 +7,7 @@ BEGIN { *bar::is = *is; } no warnings 'deprecated'; -plan 20; +plan 21; { our sub foo { 42 } @@ -16,9 +16,7 @@ plan 20; is do foo(), 42, 'calling our sub from same package (do)'; package bar; sub bar::foo { 43 } - { local $::TODO = ' '; - is foo, 42, 'calling our sub from another package'; - } + is foo, 42, 'calling our sub from another package'; is &foo, 42, 'calling our sub from another package (amper)'; is do foo(), 42, 'calling our sub from another package (do)'; } @@ -44,9 +42,7 @@ package main; our sub b { if (shift) { package bar; - { local $::TODO = ' '; - is b, 42, 'our sub visible inside itself after decl'; - } + is b, 42, 'our sub visible inside itself after decl'; is &b, 42, 'our sub visible inside itself after decl (amper)'; is do b(), 42, 'our sub visible inside itself after decl (do)'; } @@ -59,9 +55,7 @@ sub bar::c { 43 } { our sub c; package bar; - { local $::TODO = ' '; - is c, 42, 'our sub foo; makes lex alias for existing sub'; - } + is c, 42, 'our sub foo; makes lex alias for existing sub'; is &c, 42, 'our sub foo; makes lex alias for existing sub (amper)'; is do c(), 42, 'our sub foo; makes lex alias for existing sub (do)'; } @@ -76,3 +70,9 @@ sub bar::c { 43 } our sub e ($); is prototype "::e", '$', 'our sub with proto'; } +{ + # lexical subs (even our) override all keywords + our sub if() { 42 } + my $x = if if if; + is $x, 42; +} |