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

Operator Classified As Cast #94

Closed
thaljef opened this issue Nov 6, 2014 · 5 comments
Closed

Operator Classified As Cast #94

thaljef opened this issue Nov 6, 2014 · 5 comments
Labels
Milestone

Comments

@thaljef
Copy link
Member

thaljef commented Nov 6, 2014

In the following expression, the * operator is misclassified as a cast:

my $v = $opts{r}*$g;

Parse tree (PPI version 1.219_001)

                    PPI::Document604
                      PPI::Statement::Variable
[    1,   1,   1 ]     PPI::Token::Word     'my'
[    1,   4,   4 ]     PPI::Token::Symbol   '$v'
[    1,   7,   7 ]     PPI::Token::Operator     '='
[    1,   9,   9 ]     PPI::Token::Symbol   '$opts'
                        PPI::Structure::Subscript   { ... }
                          PPI::Statement::Expression
[    1,  15,  15 ]         PPI::Token::Word     'r'
[    1,  17,  17 ]     PPI::Token::Cast     '*'     <------------------- WRONG !!!
[    1,  18,  18 ]     PPI::Token::Symbol   '$g'
[    1,  20,  20 ]     PPI::Token::Structure    ';'

NB: Adding whitespace after the * operator produces the correct result.

This was originally reported as Perl-Critic/Perl-Critic#604

@wchristian
Copy link
Member

Balls. Thanks, i'll try and figure out how to fix that.

@adamkennedy
Copy link
Collaborator

This is one of those cases where i wish I'd written a more generic operator
vs operand context thingy.
On Nov 5, 2014 6:49 PM, "Christian Walde" notifications@github.com wrote:

Balls. Thanks, i'll try and figure out how to fix that.


Reply to this email directly or view it on GitHub
#94 (comment).

wchristian added a commit that referenced this issue Nov 6, 2014
@wchristian
Copy link
Member

Ok, i think i fixed this.

@adamkennedy : Can you please look at the commit to verify that the change looks sane for this issue?

Further, can you please make another issue elaborating on what you mean with operator/operand context/method?

@thaljef : This issue has been present since roughly 2006. As such, i hope you don't mind if this fix will be released with 1.222, and 1.220 to be released unchanged from the dev release.

@wchristian wchristian added this to the 1.222 milestone Nov 6, 2014
@wchristian wchristian added the bug label Nov 6, 2014
@thaljef
Copy link
Member Author

thaljef commented Nov 11, 2014

i hope you don't mind if this fix will be released with 1.222

@wchristian: No problem.

@wchristian
Copy link
Member

wchristian added a commit that referenced this issue Jan 21, 2017
Amorymeltzer added a commit to Amorymeltzer/Perl-Critic that referenced this issue Nov 5, 2021
Initially reported at Perl-Critic#604, PPI was (prior to 1.222) treating as a cast certain operators, namely multiplication (`*`) (<Perl-Critic/PPI#94>) and modulus (`%`) and bitwise-and (`&`) (<Perl-Critic/PPI#119>).  Fixed upstream but added some tests to cover all bases.

Signed-off-by: Amory Meltzer <Amorymeltzer@gmail.com>
Amorymeltzer added a commit to Amorymeltzer/Perl-Critic that referenced this issue Nov 5, 2021
Initially reported at Perl-Critic#604, PPI was (prior to 1.222) treating as a cast certain operators, namely multiplication (`*`) (<Perl-Critic/PPI#94>) and modulus (`%`) and bitwise-and (`&`) (<Perl-Critic/PPI#119>).  Fixed upstream but added some tests to cover all bases.
petdance pushed a commit to Perl-Critic/Perl-Critic that referenced this issue Dec 4, 2022
Initially reported at #604, PPI was (prior to 1.222) treating as a cast certain operators, namely multiplication (`*`) (<Perl-Critic/PPI#94>) and modulus (`%`) and bitwise-and (`&`) (<Perl-Critic/PPI#119>).  Fixed upstream but added some tests to cover all bases.
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