Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the PPI CPAN distribution.

Report information
The Basics
Id: 16834
Status: resolved
Priority: 0/
Queue: PPI

People
Owner: Nobody in particular
Requestors: nospam-abuse [...] bloodgate.com
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 1.109
Fixed in: (no value)



Subject: "$a = 1 if ($a == 2)" vs "$a = 1 if $a == 2"
PPI misses the PPI::Structure::Condition ( ... ) when you leave of the parantheses on "$a = 1 if ($a == 2)" vs "$a = 1 if $a == 2": "$a = 1 if $a == 2": PPI::Document PPI::Statement PPI::Token::Symbol '$s' PPI::Token::Whitespace ' ' PPI::Token::Operator '=' PPI::Token::Whitespace ' ' PPI::Token::Number '1' PPI::Token::Whitespace ' ' PPI::Token::Word 'if' PPI::Token::Whitespace ' ' PPI::Token::Symbol '$a' PPI::Token::Whitespace ' ' PPI::Token::Operator '==' PPI::Token::Whitespace ' ' PPI::Token::Number '9' "$a = 1 if ($a == 2)": PPI::Document PPI::Statement PPI::Token::Symbol '$s' PPI::Token::Whitespace ' ' PPI::Token::Operator '=' PPI::Token::Whitespace ' ' PPI::Token::Number '1' PPI::Token::Whitespace ' ' PPI::Token::Word 'if' PPI::Token::Whitespace ' ' PPI::Structure::Condition ( ... ) PPI::Statement::Expression PPI::Token::Symbol '$a' PPI::Token::Whitespace ' ' PPI::Token::Operator '==' PPI::Token::Whitespace ' ' PPI::Token::Number '9' This makes it very hard to recognize the statement from third-party code, even though Perl treats both constructs the same. Just including a "::Condition" would inject "()" if you do a $element->content(), though, so I am unsure what the best solution is. A "silent" or "invisible" flag on PPI::Statement::Condition? Best wishes, Tels
NOTABUG A structure just refers to a ( ) syntacic structure, and ::Condition only refers to it's syntactic type. Since there is no syntactic structure there, and the fact it is a logically is only logically infered, and since PPI only handles syntax, and is very limited in regard to meaning, this current behaviour is the expected behaviour. Any logic to detect the lexical meaning of the post-if in that case MUST be added to the analysis code above the level of the parser itself.