GNU bug report logs - #27910
24.5; local-scope; construct list

Previous Next

Package: emacs;

Reported by: hw <huwei9527 <at> gmail.com>

Date: Tue, 1 Aug 2017 15:25:01 UTC

Severity: normal

Found in version 24.5

Done: Andreas Schwab <schwab <at> suse.de>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 27910 in the body.
You can then email your comments to 27910 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#27910; Package emacs. (Tue, 01 Aug 2017 15:25:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to hw <huwei9527 <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 01 Aug 2017 15:25:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: hw <huwei9527 <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.5; local-scope; construct list
Date: Tue, 01 Aug 2017 20:02:17 +0800
Look at this code:

(defun test ()
  "Test"
  (setq a '(A))
  (push 'B a)
  (nreverse a))

(message "%s" (test))
(message "%s" (test))

The result of the code run on my emacs is:

(A B)
(B A B)

Since 'a' is a local variable, it is expected to be lke this:

(A B)
(A B)

If I substitute '(setq a '(A))' with '(setq a (list 'A))', I get
the result I expect. I think there is no difference between
the two ways of constructing list(quote expression or list function),
but the result is different.If my understanding is right,
I doubt that the local binding or optimization of elisp cause this
problem.

Can anyone tell me the reason or tell me this is really a bug so
I will be careful with constructing list.

Thank you!









In GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, GTK+ Version 3.18.9)
 of 2016-04-17 on lgw01-04, modified by Debian
System Description:	Ubuntu 16.04.2 LTS

Configured using:
 `configure --build x86_64-linux-gnu --prefix=/usr
 --sharedstatedir=/var/lib --libexecdir=/usr/lib
 --localstatedir=/var/lib --infodir=/usr/share/info
 --mandir=/usr/share/man --with-pop=yes
 --enable-locallisppath=/etc/emacs24:/etc/emacs:/usr/local/share/emacs/24.5/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.5/site-lisp:/usr/share/emacs/site-lisp
 --build x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib
 --libexecdir=/usr/lib --localstatedir=/var/lib
 --infodir=/usr/share/info --mandir=/usr/share/man --with-pop=yes
 --enable-locallisppath=/etc/emacs24:/etc/emacs:/usr/local/share/emacs/24.5/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.5/site-lisp:/usr/share/emacs/site-lisp
 --with-x=yes --with-x-toolkit=gtk3 --with-toolkit-scroll-bars
 'CFLAGS=-g -O2 -fstack-protector-strong -Wformat
 -Werror=format-security -Wall' 'CPPFLAGS=-Wdate-time
 -D_FORTIFY_SOURCE=2' 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro''

Important settings:
  value of $LC_MONETARY: zh_CN.UTF-8
  value of $LC_NUMERIC: zh_CN.UTF-8
  value of $LC_TIME: zh_CN.UTF-8
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Messages

Minor modes in effect:
  global-linum-mode: t
  linum-mode: t
  tooltip-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  line-number-mode: t
  transient-mark-mode: t

Recent messages:
(Y X A)
tt: (Y X A)
(A X Y)

(A B)
(4 3 2 1)

SBSBSB end
0.187039
Making completion list...

Load-path shadows:
/usr/share/emacs/24.5/site-lisp/debian-startup hides /usr/share/emacs/site-lisp/debian-startup
/usr/share/emacs24/site-lisp/latex-cjk-thai/thai-word hides /usr/share/emacs/24.5/lisp/language/thai-word

Features:
(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml
mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util
help-fns mail-prsvr mail-utils help-mode init config-auto-save
smart-auto-save pp auto-save-code auto-save-custom config-ui
config-theme solarized-theme solarized-definitions color-theme-custom
linum ui-custom config-miscellany file-lib file-custom miscellany-custom
config-elpa info easymenu package epg-config elpa-custom global-custom
path-lib file-code xterm time-date tooltip electric uniquify ediff-hook
vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image
regexp-opt fringe tabulated-list newcomment lisp-mode prog-mode register
page menu-bar rfn-eshadow timer select scroll-bar 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 minibuffer nadvice
loaddefs button faces cus-face macroexp files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process dbusbind
gfilenotify dynamic-setting system-font-setting font-render-setting
move-toolbar gtk x-toolkit x multi-tty emacs)

Memory information:
((conses 16 183902 6810)
 (symbols 48 22987 0)
 (miscs 40 133 143)
 (strings 32 35066 12364)
 (string-bytes 1 870136)
 (vectors 16 12013)
 (vector-slots 8 397093 3882)
 (floats 8 70 746)
 (intervals 56 294 23)
 (buffers 960 12)
 (heap 1024 32681 704))




Reply sent to Andreas Schwab <schwab <at> suse.de>:
You have taken responsibility. (Tue, 01 Aug 2017 15:47:01 GMT) Full text and rfc822 format available.

Notification sent to hw <huwei9527 <at> gmail.com>:
bug acknowledged by developer. (Tue, 01 Aug 2017 15:47:01 GMT) Full text and rfc822 format available.

Message #10 received at 27910-done <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> suse.de>
To: hw <huwei9527 <at> gmail.com>
Cc: 27910-done <at> debbugs.gnu.org
Subject: Re: bug#27910: 24.5; local-scope; construct list
Date: Tue, 01 Aug 2017 17:46:42 +0200
On Aug 01 2017, hw <huwei9527 <at> gmail.com> wrote:

> Look at this code:
>
> (defun test ()
>   "Test"
>   (setq a '(A))
>   (push 'B a)
>   (nreverse a))
>
> (message "%s" (test))
> (message "%s" (test))
>
> The result of the code run on my emacs is:
>
> (A B)
> (B A B)
>
> Since 'a' is a local variable, it is expected to be lke this:

This is irrelevant, nreverse is destructively modifying the literal in
the function:

ELISP> (symbol-function 'test)
(lambda nil "Test"
  (setq a
	'(A B))
  (push 'B a)
  (nreverse a))


Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab <at> suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#27910; Package emacs. (Tue, 01 Aug 2017 16:03:01 GMT) Full text and rfc822 format available.

Message #13 received at 27910 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> users.sourceforge.net>
To: 27910 <at> debbugs.gnu.org, Andreas Schwab <schwab <at> suse.de>, huwei9527 <at> gmail.com
Subject: Re: bug#27910: 24.5; local-scope; construct list
Date: Tue, 1 Aug 2017 12:02:01 -0400
On Tue, Aug 1, 2017 at 11:46 AM, Andreas Schwab <schwab <at> suse.de> wrote:
>
> This is irrelevant, nreverse is destructively modifying the literal in
> the function:

See also `(elisp) Rearrangement'[1], and Bug#23417.

[1]: https://www.gnu.org/software/emacs/manual/html_node/elisp/Rearrangement.html




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 30 Aug 2017 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 7 years and 298 days ago.

Previous Next


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