unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Harald Jörg" <haj@posteo.de>
To: 66178@debbugs.gnu.org
Subject: bug#66178: 30.0.50; cperl-mode inconsistent hash key fontification
Date: Sun, 24 Sep 2023 13:44:02 +0000	[thread overview]
Message-ID: <8734z3y9cp.fsf@oook.m.uunet.de> (raw)
In-Reply-To: <1817567d-4fce-cd09-a34f-89e30186c0b3@gmail.com> (Mauro Aranda's message of "Sun, 24 Sep 2023 08:02:04 -0300")

tags 66178 + wontfix
thanks

Mauro Aranda <maurooaranda@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





  reply	other threads:[~2023-09-24 13:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-24 11:02 bug#66178: 30.0.50; cperl-mode inconsistent hash key fontification Mauro Aranda
2023-09-24 13:44 ` Harald Jörg [this message]
2023-09-24 22:21   ` Mauro Aranda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8734z3y9cp.fsf@oook.m.uunet.de \
    --to=haj@posteo.de \
    --cc=66178@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).