GNU bug report logs - #65017
29.1; Byte compiler interaction with cl-lib function objects, removes symbol-function

Previous Next

Package: emacs;

Reported by: Eric Marsden <eric.marsden <at> risk-engineering.org>

Date: Wed, 2 Aug 2023 13:34:02 UTC

Severity: normal

Found in version 29.1

Done: Alan Mackenzie <acm <at> muc.de>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Alan Mackenzie <acm <at> muc.de>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Mattias EngdegÄrd <mattias.engdegard <at> gmail.com>, 65017 <at> debbugs.gnu.org, Eric Marsden <eric.marsden <at> risk-engineering.org>
Subject: bug#65017: 29.1; Byte compiler interaction with cl-lib function objects, removes symbol-function
Date: Thu, 10 Aug 2023 14:50:03 +0000
Hello, Stefan.

On Wed, Aug 09, 2023 at 23:41:56 -0400, Stefan Monnier wrote:
> >> > Are you sure?
> >> Yes.
> > What about two SWPs with the same symbol but different positions?  If
> > they aren't considered EQ here, there will never be a match for the
> > first arm of the cond form in cl--labels-convert; then
> > cl--labels-convert-cache will get written, but never used.

> Nope: when it gets written, the `function` macro returns:

>     (function <THESYMWITHPOS>)

> so the macro is immediately called again with the *exact* same
> <THESYMWITHPOS>, so the second time the `function` macro is called, the
> cache does hit (and it's the only case where it should hit), making the
> second call to the macro return the *exact* `eq`-same

>     (function <THESYMWITHPOS>)

> list which is the trick that stops the infinite macroexpansion loop.

OK, thanks, I think I've got that now.

> Next time the `function` macro is invoked with a "similar" sympos the
> cache should *not* match because we don't want to accidentally replace

>     (function <SOMESYMWITHPOS>)
> with
>     (function <THESYMWITHPOS>)

> > And if, somehow, it does get used (the current code, I think), then (as
> > you write below) the argument F will get replaced by an F with the wrong
> > position.  Am I right, here?

> That's right.

OK.  So perhaps binding symbols-with-pos-enabled to nil around that eq
call could be the way to go.

> > Why must the F get replaced by a different F?  There must surely be a
> > way, a simpler way than the current cl--labels-convert, to retain the
> > current F (hence, not corrupting its position)?

> There might.  The current hack is the best I could come up with.

I'm not criticising the hack, not at all!  But it could be better
commented, and the doc string for cl--labels-convert could be more
informative.  The "why" is missing - why is necessary to handle
`function' as a macro?  I think it's to inhibit the processing of
`function' as function somewhere else, but where and why?  I think you
explained it, at least partly, in an earlier post on this thread.

> >> > If cl--labels-convert-cache is being used
> >> > inside the byte compiler, it surely needs to consider #<symbol foo at
> >> > 42> and #<symbol foo at 60> as eq?
> >> No, it should not treat them equal (when it does, it introduces an
> >> incorrect sympos and can thus lead to error messages pointing at the
> >> wrong place).
> > Then isn't what is wrong here the introduction of the incorrect SWP
> > rather than treating the two SWPs as EQ?

> I can't see how to separate one from the other here: the introduction of
> the incorrect SWP is due to treating the two SWP as `eq`.

> > This is obscure, difficult code.  :-(

> Agreed.

> > We should think about committing a fix to the original bug,
> > sometime, too.

> I'm not completely sure we agree yet on what is "the original bug", but
> obviously I agree with  your sentence :-)

I meant bug #65017.  I committed a fix for it yesterday using the patch
I posted here on Sunday, and closed the bug.

>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).




This bug report was last modified 1 year and 337 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.