From: Gurusamy Sarathy Date: Sun, 19 Mar 2000 07:09:32 +0000 (+0000) Subject: produce better error message when \N{...} is used without X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f0af216fc1cc450de0014850eae1a2893448510c;p=p5sagit%2Fp5-mst-13.2.git produce better error message when \N{...} is used without "use charnames ..." p4raw-id: //depot/perl@5819 --- diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 0481f9a..e7eab2b 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -2205,15 +2205,12 @@ message indicates the type of reference that was expected. This usually indicates a syntax error in dereferencing the constant value. See L and L. -=item constant(%s): %%^H is not localized - -(F) When setting compile-time-lexicalized hash %^H one should set the -corresponding bit of $^H as well. - =item constant(%s): %s -(F) Compile-time-substitutions (such as overloaded constants and -character names) were not correctly set up. +(F) The parser found inconsistencies either while attempting to define an +overloaded constant, or when trying to find the character name specified +in the C<\N{...}> escape. Perhaps you forgot to load the corresponding +C or C pragma? See L and L. =item CORE::%s is not a keyword diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 6f96ec2..93b967b 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -1255,15 +1255,12 @@ workarounds. inlining. See L for commentary and workarounds. -=item constant(%s): %%^H is not localized - -(F) When setting compile-time-lexicalized hash %^H one should set the -corresponding bit of $^H as well. - =item constant(%s): %s -(F) Compile-time-substitutions (such as overloaded constants and -character names) were not correctly set up. +(F) The parser found inconsistencies either while attempting to define an +overloaded constant, or when trying to find the character name specified +in the C<\N{...}> escape. Perhaps you forgot to load the corresponding +C or C pragma? See L and L. =item Copy method did not return a reference diff --git a/toke.c b/toke.c index 3745071..0ec3cf6 100644 --- a/toke.c +++ b/toke.c @@ -5648,30 +5648,28 @@ S_new_constant(pTHX_ char *s, STRLEN len, const char *key, SV *sv, SV *pv, SV *res; SV **cvp; SV *cv, *typesv; - const char *why, *why1, *why2; + const char *why1, *why2, *why3; - if (!(PL_hints & HINT_LOCALIZE_HH)) { + if (!table || !(PL_hints & HINT_LOCALIZE_HH)) { SV *msg; - why = "%^H is not localized"; - report_short: - why1 = why2 = ""; + why1 = "%^H is not consistent"; + why2 = strEQ(key,"charnames") + ? " (missing \"use charnames ...\"?)" + : ""; + why3 = ""; report: msg = Perl_newSVpvf(aTHX_ "constant(%s): %s%s%s", - (type ? type: "undef"), why1, why2, why); + (type ? type: "undef"), why1, why2, why3); yyerror(SvPVX(msg)); SvREFCNT_dec(msg); return sv; } - if (!table) { - why = "%^H is not defined"; - goto report_short; - } cvp = hv_fetch(table, key, strlen(key), FALSE); if (!cvp || !SvOK(*cvp)) { - why = "} is not defined"; why1 = "$^H{"; why2 = key; + why3 = "} is not defined"; goto report; } sv_2mortal(sv); /* Parent created it permanently */ @@ -5719,9 +5717,9 @@ S_new_constant(pTHX_ char *s, STRLEN len, const char *key, SV *sv, SV *pv, POPSTACK; if (!SvOK(res)) { - why = "}} did not return a defined value"; why1 = "Call to &{$^H{"; why2 = key; + why3 = "}} did not return a defined value"; sv = res; goto report; }