Background:
In Perl, if a hash called %h has an element whose key is 'foo', you can address it in two equivalent ways:
$h{'foo'}
$h{foo}
In the second case, 'foo' is said to be autoquoted.
The bug:
Create and save this file:
#!/usr/bin/perl -l
my %hash = (height => 2, width => 3);
my $rh = \%hash;
print $hash{height};
print $$rh{height};
print $rh->{height};
my @a = map {quotemeta} keys %hash;
for (@a) {print};
In each of the three print statements, jEdit correctly spots that `height' is autoquoted, and highlights it as a literal string. However, in the last two lines, it also highlights `quotemeta' and `print' as literal strings; this is a bug.
A heuristic that's probably good enough is to autoquote the contents of the braces only if the open-brace is immediately preceded by a non-blank character. That would fix the behaviour in this example.
We probably need a fix for bug 1946895 (look-behind not working) before we can fix this autoquoting bug. If we had that, a possible fix would be to change this paragraph of perl.xml --
<!-- non-quoted literals in hashes -->
<SPAN_REGEXP TYPE="OPERATOR" HASH_CHAR="{" NO_LINE_BREAK="TRUE" DELEGATE="LITERAL">
<BEGIN>\{(?=\s*[\p{Alpha}_\-][\p{Alnum}_]*\s*\})</BEGIN>
<END>}</END>
</SPAN_REGEXP>
-- to look like this:
<!-- non-quoted literals in hashes -->
<SPAN_REGEXP TYPE="OPERATOR" HASH_CHAR="{" NO_LINE_BREAK="TRUE" DELEGATE="LITERAL">
<BEGIN>(?<=\S)\{(?=\s*[\p{Alpha}_\-][\p{Alnum}_]*\s*\})</BEGIN>
<END>}</END>
</SPAN_REGEXP>
(The change consists of a few characters added immediately after <BEGIN> tag.)
Logged In: YES
user_id=935841
Originator: NO
moving to patches tracker
Logged In: YES
user_id=75113
Originator: NO
There's not really a patch here, 'tis a bug. :-)