This commit not only mentions default (as opposed to when)
in the error message about it being outside a topicalizer, but
also normalises those error messages, making them consistent with
continue and other loop controls. It also makes the perldiag
entry for when actually match the error message.
t/lib/compmod.pl Helper for 1_compile.t
t/lib/croak/mg Test croak calls from mg.c
t/lib/croak/op Test croak calls from op.c
t/lib/compmod.pl Helper for 1_compile.t
t/lib/croak/mg Test croak calls from mg.c
t/lib/croak/op Test croak calls from op.c
+t/lib/croak/pp_ctl Test croak calls from pp_ctl.c
t/lib/croak.t Test calls to Perl_croak() in the C source.
t/lib/cygwin.t Builtin cygwin function tests
t/lib/dbmt_common.pl Common functionality for ?DBM_File tests
t/lib/croak.t Test calls to Perl_croak() in the C source.
t/lib/cygwin.t Builtin cygwin function tests
t/lib/dbmt_common.pl Common functionality for ?DBM_File tests
/* This is a default {} block */
enterop->op_first = block;
enterop->op_flags |= OPf_SPECIAL;
/* This is a default {} block */
enterop->op_first = block;
enterop->op_flags |= OPf_SPECIAL;
+ o ->op_flags |= OPf_SPECIAL;
o->op_next = (OP *) enterop;
}
o->op_next = (OP *) enterop;
}
/* On OP_DBSTATE, indicates breakpoint
* (runtime property) */
/* On OP_REQUIRE, was seen as CORE::require */
/* On OP_DBSTATE, indicates breakpoint
* (runtime property) */
/* On OP_REQUIRE, was seen as CORE::require */
- /* On OP_ENTERWHEN, there's no condition */
+ /* On OP_(ENTER|LEAVE)WHEN, there's
+ no condition */
/* On OP_SMARTMATCH, an implicit smartmatch */
/* On OP_ANONHASH and OP_ANONLIST, create a
reference to the new anon hash or array */
/* On OP_SMARTMATCH, an implicit smartmatch */
/* On OP_ANONHASH and OP_ANONLIST, create a
reference to the new anon hash or array */
(F) Only scalar, array, and hash variables may be declared as "my", "our" or
"state" variables. They must have ordinary identifiers as names.
(F) Only scalar, array, and hash variables may be declared as "my", "our" or
"state" variables. They must have ordinary identifiers as names.
+=item Can't "default" outside a topicalizer
+
+(F) You have used a C<default> block that is neither inside a
+C<foreach> loop nor a C<given> block. (Note that this error is
+issued on exit from the C<default> block, so you won't get the
+error if you use an explicit C<continue>.)
+
=item Can't do inplace edit: %s is not a regular file
(S inplace) You tried to use the B<-i> switch on a special file, such as
=item Can't do inplace edit: %s is not a regular file
(S inplace) You tried to use the B<-i> switch on a special file, such as
value that prints out looking like SCALAR(0xdecaf). Use the $1 form
instead.
value that prints out looking like SCALAR(0xdecaf). Use the $1 form
instead.
-=item Can't use "when" outside a topicalizer
-
-(F) You have used a when() block that is neither inside a C<foreach>
-loop nor a C<given> block. (Note that this error is issued on exit
-from the C<when> block, so you won't get the error if the match fails,
-or if you use an explicit C<continue>.)
-
=item Can't weaken a nonreference
(F) You attempted to weaken something that was not a reference. Only
references can be weakened.
=item Can't weaken a nonreference
(F) You attempted to weaken something that was not a reference. Only
references can be weakened.
+=item Can't "when" outside a topicalizer
+
+(F) You have used a when() block that is neither inside a C<foreach>
+loop nor a C<given> block. (Note that this error is issued on exit
+from the C<when> block, so you won't get the error if the match fails,
+or if you use an explicit C<continue>.)
+
=item Can't x= to read-only value
(F) You tried to repeat a constant value (often the undefined value)
=item Can't x= to read-only value
(F) You tried to repeat a constant value (often the undefined value)
cxix = dopoptogiven(cxstack_ix);
if (cxix < 0)
cxix = dopoptogiven(cxstack_ix);
if (cxix < 0)
- DIE(aTHX_ "Can't use when() outside a topicalizer");
+ /* diag_listed_as: Can't "when" outside a topicalizer */
+ DIE(aTHX_ "Can't \"%s\" outside a topicalizer",
+ PL_op->op_flags & OPf_SPECIAL ? "default" : "when");
POPBLOCK(cx,newpm);
assert(CxTYPE(cx) == CXt_WHEN);
POPBLOCK(cx,newpm);
assert(CxTYPE(cx) == CXt_WHEN);
--- /dev/null
+__END__
+# NAME when outside given
+use 5.01;
+when(undef){}
+EXPECT
+Can't "when" outside a topicalizer at - line 2.
+########
+# NAME default outside given
+use 5.01;
+default{}
+EXPECT
+Can't "default" outside a topicalizer at - line 2.