GNU bug report logs -
#66178
30.0.50; cperl-mode inconsistent hash key fontification
Previous Next
Reported by: Mauro Aranda <maurooaranda <at> gmail.com>
Date: Sun, 24 Sep 2023 11:03:01 UTC
Severity: normal
Tags: notabug, wontfix
Found in version 30.0.50
Done: Mauro Aranda <maurooaranda <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
Message #8 received at 66178 <at> debbugs.gnu.org (full text, mbox):
tags 66178 + wontfix
thanks
Mauro Aranda <maurooaranda <at> gmail.com> writes:
> emacs -Q
> C-x C-f bug.pl
> M-x cperl-mode
> my %factorial = (
> 0 => 1,
> zero => 1
> );
>
> zero is recognized as a string, 0 is not.
This might look surprising, but it is intentional.
zero is a bareword which undergoes hash-key stringification.
The digit 0, on the other hand, is converted to a string according to
Perl's type conversion rules. That is a different thing: Perl's type
conversion converts all of 0, 000, 0.0, 0E0 to the hash key "0".
Let me expand your example to demonstrate some more cases where the hash
key is (correctly) not fontified as a string:
my %hash = (
"0" => 'The string "0"',
"00" => 'The string "00"',
0 => 'A number which is converted to the string "0"',
00 => 'A number which is converted to the string "0"',
0.0 => 'A number which is converted to the string "0"',
0E0 => 'A number which is converted to the string "0"',
zero => "A bareword which is stringified",
zero() => "The function's return value is the key",
+zero => "The function's return value is the key",
);
--
Cheers,
haj
This bug report was last modified 1 year and 299 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.