Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProhibitInterpolationOfLiterals false positive with map and regexp match #466

Open
thaljef opened this issue Nov 1, 2013 · 5 comments
Open
Labels

Comments

@thaljef
Copy link
Member

thaljef commented Nov 1, 2013

RT Ticket: http://rt.cpan.org/Ticket/Display.html?id=75920
Requested On: Tue Mar 20 11:24:14 2012
Requested By: EDAVIS@cpan.org


map { 0 } /"/

gives a false positive

Useless interpolation of literal string at line 1, column 12. See page
51 of PBP. (Severity: 1)

@thaljef
Copy link
Member Author

thaljef commented Nov 1, 2013

RT Ticket: http://rt.cpan.org/Ticket/Display.html?id=75920
Comment On: 2012-03-20 18:36:17
Comment By: edavis@cpan.org


This also gives a false positive from
ValuesAndExpressions::ProhibitMismatchedOperators:

Mismatched operator at line 1, column 11. Numeric/string operators and
operands should match. (Severity: 3)

@thaljef
Copy link
Member Author

thaljef commented Nov 1, 2013

RT Ticket: http://rt.cpan.org/Ticket/Display.html?id=75920
Comment On: 2012-03-20 18:38:46
Comment By: edavis@cpan.org


Looks like a PPI bug:
% cat test
map { 0 } /"/
% perl -MPPI -MPPI::Dumper -E 'my $p = new PPI::Document "test"; my $d =
new PPI::Dumper $p; $d->print'
PPI::Document
PPI::Statement
PPI::Token::Word 'map'
PPI::Token::Whitespace ' '
PPI::Structure::Block { ... }
PPI::Token::Whitespace ' '
PPI::Statement
PPI::Token::Number '0'
PPI::Token::Whitespace ' '
PPI::Token::Whitespace ' '
PPI::Token::Operator '/'
PPI::Token::Quote::Double '"/\n'

@thaljef
Copy link
Member Author

thaljef commented Nov 1, 2013

RT Ticket: http://rt.cpan.org/Ticket/Display.html?id=75920
Comment On: 2012-03-20 18:41:26
Comment By: edavis@cpan.org


Just to show that PPI is wrong, and it really is a regexp match not a
division:

% cat test
use 5.010;
$_ = '"""';
@A = map { 0 } /"/g;
say "@A";
% perl test
0 0 0
% perl -MPPI -MPPI::Dumper -E 'my $p = new PPI::Document "test"; my $d =
new PPI::Dumper $p; $d->print'
PPI::Document
PPI::Statement::Include
PPI::Token::Word 'use'
PPI::Token::Whitespace ' '
PPI::Token::Number::Float '5.010'
PPI::Token::Structure ';'
PPI::Token::Whitespace '\n'
PPI::Statement
PPI::Token::Magic '$_'
PPI::Token::Whitespace ' '
PPI::Token::Operator '='
PPI::Token::Whitespace ' '
PPI::Token::Quote::Single ''"""''
PPI::Token::Structure ';'
PPI::Token::Whitespace '\n'
PPI::Statement
PPI::Token::Symbol '@A'
PPI::Token::Whitespace ' '
PPI::Token::Operator '='
PPI::Token::Whitespace ' '
PPI::Token::Word 'map'
PPI::Token::Whitespace ' '
PPI::Structure::Block { ... }
PPI::Token::Whitespace ' '
PPI::Statement
PPI::Token::Number '0'
PPI::Token::Whitespace ' '
PPI::Token::Whitespace ' '
PPI::Token::Operator '/'
PPI::Token::Quote::Double '"/g;\nsay "'
PPI::Token::Symbol '@A'
PPI::Token::Quote::Double '";\n'

@thaljef
Copy link
Member Author

thaljef commented Nov 1, 2013

RT Ticket: http://rt.cpan.org/Ticket/Display.html?id=75920
Comment On: 2012-03-20 18:45:41
Comment By: edavis@cpan.org


Filed against PPI as #75921.

@epa
Copy link

epa commented Nov 3, 2014

The PPI bug now lives here: Perl-Critic/PPI#67

@petdance petdance added the Bug label Jan 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants