PPI icon indicating copy to clipboard operation
PPI copied to clipboard

RT 41170: When token before ":" in a ternary expression is a bareword, it's misparsed as a label

Open moregan opened this issue 11 years ago • 1 comments

Still an issue in 1.215:

ppidump  '$foo = $condition ? undef : 1;'
                    PPI::Document
                      PPI::Statement
[    1,   1,   1 ]     PPI::Token::Symbol       '$foo'
[    1,   6,   6 ]     PPI::Token::Operator     '='
[    1,   8,   8 ]     PPI::Token::Symbol       '$condition'
[    1,  19,  19 ]     PPI::Token::Operator     '?'
[    1,  21,  21 ]     PPI::Token::Label        'undef :'
[    1,  29,  29 ]     PPI::Token::Number       '1'
[    1,  30,  30 ]     PPI::Token::Structure    ';'

moregan avatar Mar 14 '14 05:03 moregan

ditto in 1.236

Similar bugs happens when it is a method call:

> ppi-dump -e '$foo = $condition ? Class->method : 1;'
PPI::Document
  PPI::Statement
    PPI::Token::Symbol  	'$foo'
    PPI::Token::Operator  	'='
    PPI::Token::Symbol  	'$condition'
    PPI::Token::Operator  	'?'
    PPI::Token::Word  	'Class'
    PPI::Token::Operator  	'->'
    PPI::Token::Label  	'method :'
    PPI::Token::Number  	'1'
    PPI::Token::Structure  	';'
> ppi-dump -e '$foo = $condition ? $obj->method : 1;'
PPI::Document
  PPI::Statement
    PPI::Token::Symbol  	'$foo'
    PPI::Token::Operator  	'='
    PPI::Token::Symbol  	'$condition'
    PPI::Token::Operator  	'?'
    PPI::Token::Symbol  	'$obj'
    PPI::Token::Operator  	'->'
    PPI::Token::Label  	'method :'
    PPI::Token::Number  	'1'
    PPI::Token::Structure  	';'

gugod avatar Jun 20 '18 08:06 gugod