Subject: bug#6080: Behaviour of `char-syntax' changes when byte-compiled

From: Toby Cubitt <[email-masked]>
Date: Mon, 3 May 2010 20:26:14 +0100

On Mon, May 03, 2010 at 01:05:40PM -0400, Stefan Monnier wrote:
> >   (defun test ()
> >     (let ((char 33554464))
> >       (message "char: %s" char)
> >       (message "syntax: %s" (char-syntax char)))
> >     nil)
> 
> > (Note that 33554464 is the value of `last-input-event' when a command is
> > invoked by the key sequence "S-<SPC>".)
> 
> > When the test function is evalled and then run with "M-: (test)", it
> > outputs the following in the *Messages* buffer:
> 
> > char: 33554464
> > syntax: 32
> > nil
> 
> That's an error: S-SPC is not a char, so the function should signal
> an error.

Good to know which is considered the correct behaviour.

> > When the test function is byte-compiled, loaded, and run as before with
> > "M-: (test)", it throws an error and produces the following backtrace:
> 
> Yes, oddly enough (it probably made sense at some point, of course, but
> that point was passed a very long time ago), char-syntax has its own
> byte code, so what happens above is that the byte-code version of
> char-syntax is not implemented in the exact same way as
> char-syntax function.

Interesting! So the byte-compiler replaces a char-syntax call with
hand-crafted byte-code, and bypasses the version in syntax.c entirely?

Will you fix the char-syntax function so that it signals an error in this
case? If so, then I won't bother working around this Emacs bug, as it was
a minor issue and I can just tell people to byte-compile to fix it.

Toby
-- 
Dr T. S. Cubitt
Quantum Information Theory group
Department of Mathematics
University of Bristol
United Kingdom

email: [email-masked]
web: www.dr-qubit.org