Subject: bug#31688: closed (Re: bug#31688: 26.1.50; Byte compiler confuses two string variables)

From: [email-masked] (GNU bug Tracking System)
Date: Fri, 08 Jun 2018 15:10:02 +0000

Your bug report

#31688: 26.1.50; Byte compiler confuses two string variables

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
31688: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=31688
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#31688: 26.1.50; Byte compiler confuses two string variables
From: Eli Zaretskii <[email-masked]>
To: Andreas Schwab <[email-masked]>
Cc: [email-masked], [email-masked], [email-masked], [email-masked], bug-gnu-emacs-bounces+psainty=[email-masked]
Date: Fri, 08 Jun 2018 18:09:35 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> From: Andreas Schwab <[email-masked]>
> Date: Mon, 04 Jun 2018 19:01:16 +0200
> Cc: Gemini Lasswell <[email-masked]>, Noam Postavsky <[email-masked]>,
> 	bug-gnu-emacs <bug-gnu-emacs-bounces+psainty=[email-masked]>,
> 	[email-masked]
> 
> On Jun 04 2018, Phil Sainty <[email-masked]> wrote:
> 
> > Surely consistent behaviour between compiled and uncompiled code is
> > not only desirable, but a primary goal?
> 
> Not if you are using self-modifying code.

Thanks to everyone who participated in the discussion.  I have now
added some explanation of these issues to the ELisp manual, and I'm
closing the bug report.

Subject: 26.1.50; Byte compiler confuses two string variables
From: Gemini Lasswell <[email-masked]>
To: [email-masked]
Date: Sat, 02 Jun 2018 10:51:18 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

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

Then:
C-u M-x byte-compile-file RET bug.el RET
M-x ert RET t RET

Result:

    (ert-test-failed
     ((should
       (equal "\"abcdefghij\""
	      (prin1-to-string str1)))
      :form
      (equal "\"abcdefghij\"" "#(\"abcdefghij\" 0 5 (test (a b)))")
      :value nil :explanation
      (arrays-of-different-length 12 32 "\"abcdefghij\"" "#(\"abcdefghij\" 0 5 (test (a b)))" first-mismatch-at 0)))