Subject: | new can not fail silently |
use Parse::RecDescent;
undef $::RD_ERRORS;
undef $::RD_WARN;
undef $::RD_HINT;
new Parse::RecDescent("asdffa" );
Even whith globals set for not reporting problems, errors and hints, a bad grammar still print this hint:
(Hint: Set $::RD_HINT (or -RD_HINT if you're using "perl -s")
for hints on fixing these problems.)
This patch only print the hint about RD_HINT when RD_ERRORS is not set. The default comportement will not change because RD_ERRORS is set by default.
--- lib/Parse/RecDescent.pm (revision 2)
+++ lib/Parse/RecDescent.pm (working copy)
@@ -2621,11 +2621,11 @@
$@ =~ s/at grammar/in grammar at/;
_hint($@);
}
}
- if ($ERRORS and !_verbosity("HINT"))
+ if ($ERRORS and !_verbosity("HINT") and _verbosity("ERRORS"))
{
local $::RD_HINT = 1;
_hint('Set $::RD_HINT (or -RD_HINT if you\'re using "perl -s")
for hints on fixing these problems.');
}
--- lib/Parse/RecDescent.pm (revision 2)
+++ lib/Parse/RecDescent.pm (working copy)
@@ -2621,11 +2621,11 @@
$@ =~ s/at grammar/in grammar at/;
_hint($@);
}
}
- if ($ERRORS and !_verbosity("HINT"))
+ if ($ERRORS and !_verbosity("HINT") and _verbosity("ERRORS"))
{
local $::RD_HINT = 1;
_hint('Set $::RD_HINT (or -RD_HINT if you\'re using "perl -s")
for hints on fixing these problems.');
}