summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pod/perldiag.pod2
-rw-r--r--toke.c17
2 files changed, 14 insertions, 5 deletions
diff --git a/pod/perldiag.pod b/pod/perldiag.pod
index 452938cb7c..20a4a76db3 100644
--- a/pod/perldiag.pod
+++ b/pod/perldiag.pod
@@ -1086,7 +1086,7 @@ on I<Mastering Regular Expressions>.)
to check the return value of your socket() call? See
L<perlfunc/connect>.
-=item constant(%s): %s
+=item Constant(%s)%s: %s
(F) The parser found inconsistencies either while attempting to define
an overloaded constant, or when trying to find the character name
diff --git a/toke.c b/toke.c
index 274e506b3b..64b69256c7 100644
--- a/toke.c
+++ b/toke.c
@@ -5749,14 +5749,23 @@ S_new_constant(pTHX_ char *s, STRLEN len, const char *key, SV *sv, SV *pv,
if (!table || !(PL_hints & HINT_LOCALIZE_HH)) {
SV *msg;
- why1 = "%^H is not consistent";
why2 = strEQ(key,"charnames")
- ? " (missing \"use charnames ...\"?)"
+ ? "(possibly a missing \"use charnames ...\")"
: "";
- why3 = "";
+ msg = Perl_newSVpvf(aTHX_ "Constant(%s) unknown: %s",
+ (type ? type: "undef"), why2);
+
+ /* This is convoluted and evil ("goto considered harmful")
+ * but I do not understand the intricacies of all the different
+ * failure modes of %^H in here. The goal here is to make
+ * the most probable error message user-friendly. --jhi */
+
+ goto msgdone;
+
report:
- msg = Perl_newSVpvf(aTHX_ "constant(%s): %s%s%s",
+ msg = Perl_newSVpvf(aTHX_ "Constant(%s): %s%s%s",
(type ? type: "undef"), why1, why2, why3);
+ msgdone:
yyerror(SvPVX(msg));
SvREFCNT_dec(msg);
return sv;