emit require module name err hint only when valid

Programming / Compilers / PERL - David Mitchell [iabyn.com] - 18 April 2017 07:58 EDT

RT #131098

The helpful "you may need to install" hint which 'require' sometimes includes in its error message these days (split across multiple lines for clarity):

$ perl -e'require Foo::Bar' Can't locate Foo/Bar.pm in @INC (you may need to install the Foo::Bar module) (@INC contains: ... ) at ...

is a bit over-enthusiastic when the pathname hasn't actually been derived from a module name:

$ perl -e'require "Foo.+/%#Bar.pm"' Can't locate Foo.+%#Bar.pm in @INC (you may need to install the Foo.+::%#Bar module) (@INC contains: ... ) at ...

This commit changes things so that the hint message is only emitted if the reverse-mapped module name is legal as a bareword:

$ perl -e'require "Foo.+/%#Bar.pm"' Can't locate Foo.+%#Bar.pm in @INC (@INC contains: ... ) at ...

d31614f emit require module name err hint only when valid
pp_ctl.c | 54 ++++++++++++++++++++------
t/op/require_errors.t | 102 ++++++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 140 insertions(+), 16 deletions(-)

Upstream: perl5.git.perl.org


  • Share