(W exiting) You are exiting a substitution by unconventional means, such
as a return, a goto, or a loop control statement.
+=item Experimental "%s" subs not enabled
+
+(F) To use lexical subs, you must first enable them:
+
+ no warnings 'experimental:lexical_subs';
+ use feature 'lexical_subs';
+ my sub foo { ... }
+
=item Explicit blessing to '' (assuming package main)
(W misc) You are blessing a reference to a zero length string. This has
*bar::like = *like;
}
no warnings 'deprecated';
-plan 124;
+plan 127;
+
+# -------------------- Errors with feature disabled -------------------- #
+
+eval "#line 8 foo\nmy sub foo";
+is $@, qq 'Experimental "my" subs not enabled at foo line 8.\n',
+ 'my sub unexperimental error';
+eval "#line 8 foo\nCORE::state sub foo";
+is $@, qq 'Experimental "state" subs not enabled at foo line 8.\n',
+ 'state sub unexperimental error';
+eval "#line 8 foo\nour sub foo";
+is $@, qq 'Experimental "our" subs not enabled at foo line 8.\n',
+ 'our sub unexperimental error';
# -------------------- our -------------------- #
+no warnings "experimental:lexical_subs";
+use feature 'lexical_subs';
{
our sub foo { 42 }
is foo, 42, 'calling our sub from same package';
# -------------------- state -------------------- #
-use 5.01; # state
+use feature 'state'; # state
{
state sub foo { 44 }
isnt \&::foo, \&foo, 'state sub is not stored in the package';
Can't find string terminator "foo" anywhere before EOF at (eval 1) line 1.
########
# NAME Missing name in "my sub"
-my sub;
+use feature 'lexical_subs'; my sub;
EXPECT
+The lexical_subs feature is experimental at - line 1.
Missing name in "my sub" at - line 1.
########
# NAME Missing name in "our sub"
-our sub;
+use feature 'lexical_subs'; our sub;
EXPECT
+The lexical_subs feature is experimental at - line 1.
Missing name in "our sub" at - line 1.
########
# NAME Missing name in "state sub"
-use 5.01;
+use 5.01; use feature 'lexical_subs';
state sub;
EXPECT
+The lexical_subs feature is experimental at - line 1.
Missing name in "state sub" at - line 2.
########
# NAME Unterminated delimiter for here document
Use of :locked is deprecated at - line 6.
########
# toke.c
-use warnings "syntax";
+use warnings "syntax"; use feature 'lexical_subs';
sub proto_after_array(@$);
sub proto_after_arref(\@$);
sub proto_after_arref2(\[@$]);
sub underscore_after_at(@_);
our sub hour (@$);
my sub migh (@$);
-use 5.01;
+use feature 'state';
state sub estate (@$);
package other;
sub hour (@$);
sub proto_after_hash(%$);
sub underscore_fail($_$);
EXPECT
+The lexical_subs feature is experimental at - line 2.
Prototype after '@' for main::proto_after_array : @$ at - line 3.
Prototype after '%' for main::proto_after_hash : %$ at - line 7.
Illegal character after '_' in prototype for main::underscore_fail : $_$ at - line 12.
#endif
s = scan_word(s, PL_tokenbuf, sizeof PL_tokenbuf, TRUE, &len);
if (len == 3 && strnEQ(PL_tokenbuf, "sub", 3))
+ {
+ if (!FEATURE_LEXSUBS_IS_ENABLED)
+ Perl_croak(aTHX_
+ "Experimental \"%s\" subs not enabled",
+ tmp == KEY_my ? "my" :
+ tmp == KEY_state ? "state" : "our");
goto really_sub;
+ }
PL_in_my_stash = find_in_my_stash(PL_tokenbuf, len);
if (!PL_in_my_stash) {
char tmpbuf[1024];