unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#6080: Behaviour of `char-syntax' changes when byte-compiled
@ 2010-05-02 11:15 Toby Cubitt
  2010-05-03 17:05 ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Toby Cubitt @ 2010-05-02 11:15 UTC (permalink / raw)
  To: 6080

Define the following test function:

  (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

When the test function is byte-compiled, loaded, and run as before with
"M-: (test)", it throws an error and produces the following backtrace:

Debugger entered--Lisp error: (wrong-type-argument characterp 33554464)
  test()
  eval((test))
  eval-expression((test) nil)
  call-interactively(eval-expression nil nil)

This is with a recent VCS Emacs checkout. Emacs version and settings are
included below.

Toby



In GNU Emacs 23.1.96.1 (i686-pc-linux-gnu, GTK+ Version 2.18.6)
 of 2010-04-23 on c3po
Windowing system distributor `The X.Org Foundation', version 11.0.10706000
configured using `configure  '--prefix=/usr' '--host=i686-pc-linux-gnu' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--datadir=/usr/share' '--sysconfdir=/etc' '--localstatedir=/var/lib' '--program-suffix=-emacs-23-vcs' '--infodir=/usr/share/info/emacs-23-vcs' '--with-sound' '--with-x' '--without-gconf' '--with-toolkit-scroll-bars' '--without-gif' '--without-jpeg' '--with-png' '--with-rsvg' '--without-tiff' '--with-xpm' '--with-xft' '--without-libotf' '--without-m17n-flt' '--with-x-toolkit=gtk' '--without-hesiod' '--without-kerberos' '--without-kerberos5' '--with-gpm' '--with-dbus' '--build=i686-pc-linux-gnu' 'build_alias=i686-pc-linux-gnu' 'host_alias=i686-pc-linux-gnu' 'CFLAGS=-march=prescott -O2 -pipe' 'LDFLAGS=-Wl,-O1''

Important settings:
  value of $LC_ALL: en_GB.UTF-8
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_GB.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Features:
(conf-mode newcomment shadow sort mail-extr message sendmail ecomplete
rfc822 mml mml-sec password-cache mm-decode mm-bodies mm-encode mailcap
mail-parse rfc2231 rfc2047 rfc2045 qp ietf-drums mailabbrev nnheader
gnus-util netrc time-date mm-util mail-prsvr gmm-utils wid-edit
mailheader canlock sha1 hex-util hashcash mail-utils emacsbug iso-transl
info pp cl-specs edebug thingatpt cc-mode cc-fonts cc-menus cc-cmds
cc-styles cc-align cc-engine cc-vars cc-defs easy-mmode compile comint
ring multi-isearch vc-git find-func help-mode view debug server
which-func imenu paren advice advice-preload post help-fns derived cl
cl-19 css-mode-simple edmacro kmacro regexp-opt undo-tree
log-modification-mode show-point-mode predictive-html auto-overlay-flat
predictive-texinfo predictive-latex predictive-auto-overlay-auto-dict
auto-overlay-nested auto-overlay-self auto-overlay-line
auto-overlay-word predictive timerfunctions auto-overlays
auto-overlay-common dict-tree trie cedet-edebug tNFA queue heap avl-tree
semantic/util-modes easymenu semantic/util semantic semantic/tag
semantic/lex semantic/fw eieio byte-opt bytecomp byte-compile mode-local
cedet completion-ui-sources completion-ui-menu completion-ui-tooltip
completion-ui-echo completion-ui-hotkeys completion-ui-dynamic
completion-ui-popup-frame completion-ui flyspell ispell avoid
site-gentoo preview-latex tex-site auto-loads tooltip ediff-hook
vc-hooks lisp-float-type mwheel x-win x-dnd font-setting tool-bar dnd
fontset image fringe lisp-mode register page menu-bar rfn-eshadow timer
select scroll-bar mldrag mouse jit-lock font-lock syntax facemenu
font-core frame cham georgian utf-8-lang misc-lang vietnamese tibetan
thai tai-viet lao korean japanese hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese case-table epa-hook
jka-cmpr-hook help simple abbrev loaddefs button minibuffer faces
cus-face files text-properties overlay md5 base64 format env code-pages
mule custom widget hashtable-print-readable backquote
make-network-process dbusbind font-render-setting gtk x-toolkit x
multi-tty emacs)


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

email: tsc25@cantab.net
web: www.dr-qubit.org







^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#6080: Behaviour of `char-syntax' changes when byte-compiled
  2010-05-02 11:15 bug#6080: Behaviour of `char-syntax' changes when byte-compiled Toby Cubitt
@ 2010-05-03 17:05 ` Stefan Monnier
  2010-05-03 19:26   ` Toby Cubitt
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2010-05-03 17:05 UTC (permalink / raw)
  To: Toby Cubitt; +Cc: 6080

>   (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.

> 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.


        Stefan






^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#6080: Behaviour of `char-syntax' changes when byte-compiled
  2010-05-03 17:05 ` Stefan Monnier
@ 2010-05-03 19:26   ` Toby Cubitt
  2010-05-05 17:54     ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Toby Cubitt @ 2010-05-03 19:26 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 6080

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: tsc25@cantab.net
web: www.dr-qubit.org






^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#6080: Behaviour of `char-syntax' changes when byte-compiled
  2010-05-03 19:26   ` Toby Cubitt
@ 2010-05-05 17:54     ` Stefan Monnier
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2010-05-05 17:54 UTC (permalink / raw)
  To: Toby Cubitt; +Cc: 6080

> Will you fix the char-syntax function so that it signals an error in this
> case?

I've just installed such a change,


        Stefan


--- src/syntax.c	2010-03-10 14:45:21 +0000
+++ src/syntax.c	2010-05-05 17:20:27 +0000
@@ -858,7 +858,7 @@
      Lisp_Object character;
 {
   int char_int;
-  CHECK_NUMBER (character);
+  CHECK_CHARACTER (character);
   char_int = XINT (character);
   SETUP_BUFFER_SYNTAX_TABLE ();
   return make_number (syntax_code_spec[(int) SYNTAX (char_int)]);







^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-05-05 17:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-02 11:15 bug#6080: Behaviour of `char-syntax' changes when byte-compiled Toby Cubitt
2010-05-03 17:05 ` Stefan Monnier
2010-05-03 19:26   ` Toby Cubitt
2010-05-05 17:54     ` Stefan Monnier

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).