emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [elpa] externals/org ee0961ba31: lisp/org-table.el: fix warning abou


From: Karl Fogel
Subject: Re: [elpa] externals/org ee0961ba31: lisp/org-table.el: fix warning about `eq' usage
Date: Wed, 01 Nov 2023 01:07:50 -0500
User-agent: Gnus/5.13 (Gnus v5.13)

Stefan Monnier wrote:
This change does not affect the behavior of
`org-table-make-reference' because `eq' treats all instances
of the empty string as the same object anyway, e.g., `(eq (string-trim "aaabbb" "a+" "b+") "")' ==> t.

Not quite so: (eq (string-to-multibyte "") "") => nil

Thank you for noticing this, Stefan.

I did many tests with `eq' and various kinds of generated empty strings before writing that commit message -- but, alas, I didn't think of testing with a multibyte string. (I also looked in the documentation, and the fact that there was no explicit mention of all empty strings being the same object should have tipped me off!)

So, I believe this means there is an error in that commit message. I've attached the commitinfo below for easy reference, with 'inline' disposition.

However, the code change itself remains correct... I think? That is: the previous code presumably had a latent bug, in that there *could* have been times when the `eq' test would fail when comparing against a multibyte empty string.

I don't know much about how Org Mode gets merged into Emacs, nor whether there are opportunities for rebasing anywhere along the way in that process. If there's a way to update that commit message, then I'd do so (I can post a new one here). But if there's no such opportunity, then so be it: I'll be on the permanent record with a technical mistake in a log message. I'm sure it wouldn't be the first time :-/.

Best regards,
-Karl

commit ee0961ba3170f7bc89c2f6fabda4b6ea2e7a2c88
Author:     Karl Fogel <kfogel@red-bean.com>
AuthorDate: Mon Oct 30 10:33:29 2023 -0500
Commit:     Bastien Guerry <bzg@gnu.org>
CommitDate: Tue Oct 31 21:38:23 2023 +0100

    lisp/org-table.el: fix warning about `eq' usage
    
    * lisp/org-table.el (org-table-make-reference): Use `equal' instead of
    `eq' to compare strings.
    
    This change makes the following warning go away:
    
      Warning (comp): org-table.el:2867:23: \
      Warning: `eq' called with literal string that may never match (arg 2)
    
    This change does not affect the behavior of `org-table-make-reference'
    because `eq' treats all instances of the empty string as the same
    object anyway, e.g., `(eq (string-trim "aaabbb" "a+" "b+") "")' ==> t.
    The only effect of this change is to eliminate the warning.

M       lisp/org-table.el


reply via email to

[Prev in Thread] Current Thread [Next in Thread]