jrockway / cperl-mode

cperl-mode with 5.10 fixes, mx-declare support, perl6 support, etc.
102 stars 33 forks source link

Spurious unbalanced error #48

Closed CeleritasCelery closed 6 years ago

CeleritasCelery commented 6 years ago

Using the test file below with the cursor located at | try to type the m character.

#!/usr/bin/perl
|
my $foo;

You will see the error End of ‘mp ... p’ string/RE not found: (scan-error Unbalanced parentheses n n)

choroba commented 6 years ago

That's the expected behaviour, as cperl-mode can't find the closing | for a m|...| match.

CeleritasCelery commented 6 years ago

I realize now that using | to indicate the cursor position was a mistake. The file looks like this

#!/usr/bin/perl

my $foo;

there is no | in the file. typing m (as in starting to type the keyword my) before my $foo leads to the error. However typing the letter m after my $foo does not lead to the error. In either case, there are no unbalanced parenthesis.

choroba commented 6 years ago

There are. Try it with a variable name that contains m:

#!/usr/bin/perl
m
my $foo_m;

As running perl -MO=Deparse on the source tells us, it's equivalent to

/y $foo_/;

because perlop:

When using a character valid in an identifier, whitespace is required after the "m".

CeleritasCelery commented 6 years ago

Wow. You are right. Since this issue doesn't throw an error (just prints), its manageable. It would be nice however, if the major mode either suppressed this error or found a better way to handle it, as it's quite confusing if you do not know what is going on.