Perl-Critic / PPI

53 stars 44 forks source link

Misparse of qw with comment before first delimiter #126

Open moregan opened 9 years ago

moregan commented 9 years ago

perldoc -f qw explains that if qw is followed by whitespace plus '#', the rest of the line is a comment, and the qw's opening delimiter will be taken from the following line:

    There can be whitespace between the operator and the quoting characters,
    except when "#" is being used as the quoting character. "q#foo#" is parsed
    as the string "foo", while "q #foo#" is the operator "q" followed by a
    comment. Its argument will be taken from the next line. This allows you to
    write:

        s {foo}  # Replace foo
          {bar}  # with bar.

With test file:

$ cat test.pl
print join ",", qw # comment
( a )

perl acts as documented:

perl -W test.pl
a

whereas PPI does not:

$ perl -MPPI::Document -WE 'say join( ",", PPI::Document->new("test.pl")->schild(0)->schild(4)->literal )'
(,a,)
adamkennedy commented 9 years ago

I really thought I had caught all of the qw special cases... darn.