From 0ffcbc25f88c6111d4cf57b2cebcb4e3eab761aa Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Sun, 8 Sep 2013 14:09:23 -0700 Subject: [PATCH] Hard-code op name in ck_exists|delete errors MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The reason is manifold: • ck_exists and ck_delete are each only ever called with one op type, so we can hard-code the op, which takes less code. • The messages in perldiag are more helpful if they include the op name. • Changing them in op.c too avoids the need for diag_listed_as clutter. (I know, two of these are not listed in perldiag yet. I’m get- ting to that.) --- op.c | 20 ++++++++++---------- pod/perldiag.pod | 56 ++++++++++++++++++++++++++++---------------------------- 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/op.c b/op.c index aa6c50d..771c105 100644 --- a/op.c +++ b/op.c @@ -8309,14 +8309,14 @@ Perl_ck_delete(pTHX_ OP *o) case OP_HELEM: break; case OP_KVASLICE: - Perl_croak(aTHX_ "%s argument is index/value array slice, use array slice", - OP_DESC(o)); + Perl_croak(aTHX_ "delete argument is index/value array slice," + " use array slice"); case OP_KVHSLICE: - Perl_croak(aTHX_ "%s argument is key/value hash slice, use hash slice", - OP_DESC(o)); + Perl_croak(aTHX_ "delete argument is key/value hash slice, use" + " hash slice"); default: - Perl_croak(aTHX_ "%s argument is not a HASH or ARRAY element or slice", - OP_DESC(o)); + Perl_croak(aTHX_ "delete argument is not a HASH or ARRAY " + "element or slice"); } if (kid->op_private & OPpLVAL_INTRO) o->op_private |= OPpLVAL_INTRO; @@ -8480,15 +8480,15 @@ Perl_ck_exists(pTHX_ OP *o) (void) ref(kid, o->op_type); if (kid->op_type != OP_RV2CV && !(PL_parser && PL_parser->error_count)) - Perl_croak(aTHX_ "%s argument is not a subroutine name", - OP_DESC(o)); + Perl_croak(aTHX_ + "exists argument is not a subroutine name"); o->op_private |= OPpEXISTS_SUB; } else if (kid->op_type == OP_AELEM) o->op_flags |= OPf_SPECIAL; else if (kid->op_type != OP_HELEM) - Perl_croak(aTHX_ "%s argument is not a HASH or ARRAY element or a subroutine", - OP_DESC(o)); + Perl_croak(aTHX_ "exists argument is not a HASH or ARRAY " + "element or a subroutine"); op_null(kid); } return o; diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 5838a79..d560d98 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -170,34 +170,6 @@ alternatives. (F) msgsnd() requires a string at least as long as sizeof(long). -=item %s argument is not a HASH or ARRAY element or a subroutine - -(F) The argument to exists() must be a hash or array element or a -subroutine with an ampersand, such as: - - $foo{$bar} - $ref->{"susie"}[12] - &do_something - -=item %s argument is not a HASH or ARRAY element or slice - -(F) The argument to delete() must be either a hash or array element, -such as: - - $foo{$bar} - $ref->{"susie"}[12] - -or a hash or array slice, such as: - - @foo[$bar, $baz, $xyzzy] - @{$ref->[12]}{"susie", "queue"} - -=item %s argument is not a subroutine name - -(F) The argument to exists() for C must be a subroutine -name, and not a subroutine call. C will generate this -error. - =item Argument "%s" isn't numeric%s (W numeric) The indicated string was fed as an argument to an operator @@ -1690,6 +1662,19 @@ discovered. (F) You said something like "use Module 42" but in the Module file there are neither package declarations nor a C<$VERSION>. +=item delete argument is not a HASH or ARRAY element or slice + +(F) The argument to delete() must be either a hash or array element, +such as: + + $foo{$bar} + $ref->{"susie"}[12] + +or a hash or array slice, such as: + + @foo[$bar, $baz, $xyzzy] + @{$ref->[12]}{"susie", "queue"} + =item Delimiter for here document is too long (F) In a here document construct like C<<, the label C is too @@ -1904,6 +1889,21 @@ OS. See L. (F) The final summary message when a Perl compilation fails. +=item exists argument is not a HASH or ARRAY element or a subroutine + +(F) The argument to exists() must be a hash or array element or a +subroutine with an ampersand, such as: + + $foo{$bar} + $ref->{"susie"}[12] + &do_something + +=item exists argument is not a subroutine name + +(F) The argument to exists() for C must be a subroutine +name, and not a subroutine call. C will generate this +error. + =item Exiting eval via %s (W exiting) You are exiting an eval by unconventional means, such as a -- 2.7.4