From: Jarkko Hietaniemi Date: Sun, 5 Nov 2000 17:22:01 +0000 (+0000) Subject: A fix of sorts for 20000329.026, a better error message X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=41ab332feccc7634fd538d8b8d2d84e2f2935ca3;p=p5sagit%2Fp5-mst-13.2.git A fix of sorts for 20000329.026, a better error message for a missing "use charnames" when using the \N{...}. p4raw-id: //depot/perl@7557 --- diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 452938c..20a4a76 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -1086,7 +1086,7 @@ on I.) to check the return value of your socket() call? See L. -=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 274e506..64b6925 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;