Subject: bug#7145: elisp-code behaves differently after byte-compilation

From: Johan Bockgård <[email-masked]>
Date: Sat, 02 Oct 2010 12:41:18 +0200

Andreas Schwab <[email-masked]> writes:

> "Markus Sauermann" <[email-masked]> writes:
>
>> The following code however shows a case where this is not the case.
>>
>> --- BEGIN CODE ---
>> (let ((fun (lambda () (let ((bar "foo")
>>                             (baz "foo"))
>>                         (eq bar baz)))))
>>   (list (funcall (byte-compile fun))
>>         (funcall fun)))
>> --- END CODE---
>>
>> Evaluation this code (don't try to byte-compile it, because it is buggy ;-) ) results in:
>>
>> --- BEGIN OUTPUT ---
>> (t nil)
>> --- END OUTPUT ---
>
> This is not a bug.

But this is, IMO:

(progn
  (defsubst spooky-action-at-a-distance ()
    (let ((a (concat "a" "bc")))
      (store-substring a 0 "123")))

  (defun foo ()
    (spooky-action-at-a-distance)
    (concat "ab" "c"))

  (byte-compile 'foo)
  (foo))

=>  "123"