From: Noam Postavsky <npostavs@gmail.com>
To: Gemini Lasswell <gazally@runbox.com>
Cc: 31688@debbugs.gnu.org
Subject: bug#31688: 26.1.50; Byte compiler confuses two string variables
Date: Sat, 02 Jun 2018 14:02:51 -0400 [thread overview]
Message-ID: <87po199id0.fsf@gmail.com> (raw)
In-Reply-To: <87a7sdkrft.fsf@runbox.com> (Gemini Lasswell's message of "Sat, 02 Jun 2018 10:51:18 -0700")
Gemini Lasswell <gazally@runbox.com> writes:
> Here is a test which succeeds when interpreted and fails when
> byte-compiled. The byte compiler is apparently confusing two string
> variables, or optimizing away one of them. I've tried it both
> with and without lexical-binding with the same results.
>
> To reproduce, save this to bug.el:
>
> (require 'ert)
> (ert-deftest test-strings-props ()
> (let* ((str1 "abcdefghij")
> (obj '(a b))
> (str2 "abcdefghij"))
> (put-text-property 0 5 'test obj str2)
> (should (equal "\"abcdefghij\"" (prin1-to-string str1)))))
I don't think this is a bug, the compiler coalesces equal string
literals. `put-text-property' modifies the string destructively, so you
shouldn't use it on literals, for the same reason you shouldn't use
destructive operations on quoted list literals. Another example, not
dependent on compilation:
(defun foo (prop val)
(let ((s "xyz"))
(put-text-property 0 3 prop val s)
s))
(foo 'x 1) ;=> #("xyz" 0 3 (x 1))
(foo 'y 2) ;=> #("xyz" 0 3 (x 1 y 2))
next prev parent reply other threads:[~2018-06-02 18:02 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-02 17:51 bug#31688: 26.1.50; Byte compiler confuses two string variables Gemini Lasswell
2018-06-02 18:02 ` Noam Postavsky [this message]
2018-06-02 22:52 ` Gemini Lasswell
2018-06-02 23:25 ` Noam Postavsky
2018-06-03 0:40 ` Drew Adams
2018-06-02 23:03 ` Drew Adams
2018-06-02 23:38 ` Phil Sainty
2018-06-02 23:54 ` Noam Postavsky
2018-06-03 12:32 ` Phil Sainty
2018-06-03 13:05 ` Andreas Schwab
2018-06-04 10:02 ` Phil Sainty
2018-06-04 15:58 ` Eli Zaretskii
2018-06-04 17:01 ` Andreas Schwab
2018-06-08 15:09 ` Eli Zaretskii
2018-06-03 0:02 ` Michael Heerdegen
2018-06-03 0:46 ` Drew Adams
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87po199id0.fsf@gmail.com \
--to=npostavs@gmail.com \
--cc=31688@debbugs.gnu.org \
--cc=gazally@runbox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.