bug#47598: cperl-mode: Highlighting confused with ternary and -x

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

bug#47598: cperl-mode: Highlighting confused with ternary and -x

E. Choroba-2
When combining the ternary operator with file tests using the default
argument, cperl-mode gets confused.

For example:

my $f = -f ? 'file'
       : -l ? [readlink]
       : -d ? 'dir'
            : 'unknown';

It seems to think the ?'s are not part of a ternary operator, but rather a
match-once operator. Note that m?? without m results in a syntax error since
Perl 5.22.

Ch.



Reply | Threaded
Open this post in threaded view
|

bug#47598: cperl-mode: Highlighting confused with ternary and -x [PATCH]

Harald Jörg
E. Choroba writes:

> When combining the ternary operator with file tests using the default
> argument, cperl-mode gets confused.
>
> For example:
>
> my $f = -f ? 'file'
>       : -l ? [readlink]
>       : -d ? 'dir'
>            : 'unknown';
>
> It seems to think the ?'s are not part of a ternary operator, but
> rather a match-once operator. ...
Exactly, that is what is happening here.

> ... Note that m?? without m results in a
> syntax error since Perl 5.22.

Because of that it seems appropriate to stop dealing with bare ?foo?
altogether.  So, the patch eliminates the recognition of bare ?foo?, and
also deletes the corresponding lines from CPerl's builtin short
documentation.  The test in the patch uses the text from the bug report,
and also checks that m?foo? is still processed as a regular expression,
and a bare ?foo?  isn't.
--
Cheers,
haj

0001-cperl-mode-Eliminate-bad-interpretation-of-foo-bug-4.patch (4K) Download Attachment