Subject: | The switch to PPR is a tad unfortunate wrt error message quality |
Date: | Thu, 22 Jun 2017 20:10:47 +0000 |
To: | bugs-Keyword-Declare [...] rt.cpan.org |
From: | Matt S Trout <mst [...] shadowcat.co.uk> |
So, having already noted that the way Method::Signatures::PP uses PPR makes
it great for working code but produce terrible errors if not, I realised that
for things like block keywords the problem might be more general than just
my LT hack. After a bit of playing ... yes, yes it is.
I took t/attributes_basic_unified.t from Dios (picked basically at random)
and then changed
@nums = @NEWNUMS;
to
@nums = @NEWNUMS:
since this is a moderately common mistake for me and also one that often
annoys me to debug.
With Dios 0.001001 and Keyword::Declare 0.000005 that results in:
Matt@demeisen$ perl -I$HOME/tmp/oldkwdeclare/lib/perl5 t/attributes_basic_unified.t
syntax error at t/attributes_basic_unified.t line 39, near "@NEWNUMS:"
Execution of t/attributes_basic_unified.t aborted due to compilation errors.
With Dios 0.002000 and Keyword::Declare 0.001000 that results in:
Matt@demeisen$ perl -Ilib t/attributes_basic_unified.t
Invalid class at t/attributes_basic_unified.t line 22.
Expected:
class <class name> <bases> <block>
but found:
class Demo is Base1 is Base2 {
Compilation failed at t/attributes_basic_unified.t line 22.
which is, well, accurate, but *vastly* less helpful.
This suggests three options that I can immediately think of:
(1) Use PPI for my stuff and rely on .pmc-ification ameliorating the speed
(2) Use PPR, then fall back to PPI if PPR doesn't parse it, since if you're
about to crash anyway taking an extra .5s to crash more usefully is fine
(3) Find some way to make PPR report partial parses, which probably ends up
heading towards PPR having to duplicating perl5's compilation errors as
well as parsing behaviour
My initial thoughts are that (1) would be fine for *me*, (2) is possibly the
least worst option for Keyword::Declare, and (3) is a great idea in theory
but a vast amount of work for not much payoff in practice.
Thoughts?
--
Matt S Trout - Shadowcat Systems - Perl consulting with a commit bit and a clue
http://shadowcat.co.uk/blog/matt-s-trout/ http://twitter.com/shadowcat_mst/
Email me now on mst (at) shadowcat.co.uk and let's chat about how our CPAN
commercial support, training and consultancy packages could help your team.