From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#31688: 26.1.50; Byte compiler confuses two string variables Date: Sat, 02 Jun 2018 14:02:51 -0400 Message-ID: <87po199id0.fsf@gmail.com> References: <87a7sdkrft.fsf@runbox.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1527962481 7868 195.159.176.226 (2 Jun 2018 18:01:21 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 2 Jun 2018 18:01:21 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Cc: 31688@debbugs.gnu.org To: Gemini Lasswell Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jun 02 20:01:17 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fPAq5-0001v4-3V for geb-bug-gnu-emacs@m.gmane.org; Sat, 02 Jun 2018 20:01:17 +0200 Original-Received: from localhost ([::1]:60668 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fPAsC-0001e3-2U for geb-bug-gnu-emacs@m.gmane.org; Sat, 02 Jun 2018 14:03:28 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45377) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fPArp-0001SY-Nt for bug-gnu-emacs@gnu.org; Sat, 02 Jun 2018 14:03:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fPArm-0001in-LW for bug-gnu-emacs@gnu.org; Sat, 02 Jun 2018 14:03:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:51647) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fPArm-0001ie-GY for bug-gnu-emacs@gnu.org; Sat, 02 Jun 2018 14:03:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fPArm-0008T9-8V for bug-gnu-emacs@gnu.org; Sat, 02 Jun 2018 14:03:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 02 Jun 2018 18:03:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 31688 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 31688-submit@debbugs.gnu.org id=B31688.152796258032547 (code B ref 31688); Sat, 02 Jun 2018 18:03:02 +0000 Original-Received: (at 31688) by debbugs.gnu.org; 2 Jun 2018 18:03:00 +0000 Original-Received: from localhost ([127.0.0.1]:59544 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fPArk-0008Ss-0i for submit@debbugs.gnu.org; Sat, 02 Jun 2018 14:03:00 -0400 Original-Received: from mail-it0-f48.google.com ([209.85.214.48]:50247) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fPAri-0008Se-G4 for 31688@debbugs.gnu.org; Sat, 02 Jun 2018 14:02:58 -0400 Original-Received: by mail-it0-f48.google.com with SMTP id u4-v6so5454800itg.0 for <31688@debbugs.gnu.org>; Sat, 02 Jun 2018 11:02:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=D+lcpDwJpWIWrNd47M6l7hgv3pOh0+IwmcMbIlSgES4=; b=Tfyv8T4YJN6kmBWOMqGHreRGtGfPbhT8geaLoojtknoIaDmzqZ7/qrrFSVWJoMsNzc P2MGBaCH2nCo12aswxtdXUcqWKdWr/X/WK2opKR441HEd+JMRtvlnAfeUTTEHkt6sM16 9HhZF4I+uYrxkahJdCUjSK8+PuL7UtqdYlT82Ke38UhJmmJqxAkLmfHlvTnpyvD1o/My bSpotXdj+x8MFoMdKuR8x0thAEUN732yJxFoyZXAjA9pLHMomAFtTkEL+DYGdcATTLPr ib00uu1lDbAMzWeVmKv/eyStssYe1vU3Gnv2rFwjK9jfy7sBF/d7DB5JQ6TaNSscmQwZ oN7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=D+lcpDwJpWIWrNd47M6l7hgv3pOh0+IwmcMbIlSgES4=; b=NJbvfImRfOI9MtwYjP244mS5/KipcnX6xHEU2EZsvTN1UWXLLesVl7szUvXHc4z4TJ 5ExqJOZbw2nZ7/q2Dd+vQWOpc9tYK2LMLyiG0C3tnawTmUT8+P7bq6Br50uK6N2ZRW3d Xa6U/VDBMLqFf3KChjfT7Nb5rEkKjaKFdhJ5t4isMUxjSDobqBceVqZli2XKkhJx3+5H w1PZb1dpOsDX2JVtNtdcqvOXyrr08J+LjowNMIhgS6hi2NkX2RceNmvyUh9hIJM52AMl 8HtrUBVOJ4nt6B08E8JPDL+YmBBiEJYdiGSerUqXa0YNehWJs/3qA9LIQBUduT8VOfQf uR+Q== X-Gm-Message-State: APt69E113nSUbf4Ggq04s9dM6y70dxadnjkL5WlCtblAK1MEJRUvS7a1 YKqv4pcj4EHpGpMMqP80jJkHWg== X-Google-Smtp-Source: ADUXVKIWrzSzBsZFNdN9HoJKFGZEHFJgwDCWAxurOYojHjAjNX01Q6Tlt574K1o7tcXxLrL2FH6Suw== X-Received: by 2002:a24:fa07:: with SMTP id v7-v6mr8855992ith.18.1527962572912; Sat, 02 Jun 2018 11:02:52 -0700 (PDT) Original-Received: from zebian (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.googlemail.com with ESMTPSA id g127-v6sm2523989ioa.79.2018.06.02.11.02.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 02 Jun 2018 11:02:52 -0700 (PDT) In-Reply-To: <87a7sdkrft.fsf@runbox.com> (Gemini Lasswell's message of "Sat, 02 Jun 2018 10:51:18 -0700") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:146874 Archived-At: Gemini Lasswell 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))