Subject: 24.3; Eager Macro Expansion

From: Achim Gratz <[email-masked]>
Date: Sun, 19 May 2013 16:26:10 +0200

In GNU Emacs 24.3.1 (i686-suse-linux-gnu, GTK+ Version 3.8.1) of 2013-04-27
Windowing system distributor `The X.Org Foundation', version 11.0.11302000
System Description:	openSUSE 12.3/Tumbleweed (i586)

The following test case demonstrates a problem that has been distilled
from Org's test suite.  Org has since switched to use defun instead of
defmacro to work around this issue, but it seems that this might be a
corner case that eager macro expansion produces or not yet warn about
(whatever the intended behaviour might be).

(require 'ert)

(defvar ll nil)

(defmacro one (p)
  `(progn (push ',p ll)))

(defmacro two (p)
  (let (pp)
    (setq pp (append ll p))
  `(progn (push ',pp ll))))
 
(ert-deftest surprise ()
    (should
     (equal '((one . two) one)
	    (progn
	      (one one)
	      (two two)
	      ll))))

(ert-run-tests-batch-and-exit 'surprise)

This passes on all Emacs versions until 24.2, but fails on trunk:

eme> emacs-24.2 -batch -Q -l eme.el
Running 1 tests (2013-05-19 16:16:06+0200)
   passed  1/1  surprise

Ran 1 tests, 1 results as expected (2013-05-19 16:16:06+0200)

eme> emacs-24.3.50 -batch -Q -l eme.el
Running 1 tests (2013-05-19 16:16:16+0200)
Test surprise backtrace:
  (if (unwind-protect (setq value-2 (apply fn-0 args-1)) (setq form-de
  (let (form-description-4) (if (unwind-protect (setq value-2 (apply f
  (let ((value-2 (quote ert-form-evaluation-aborted-3))) (let (form-de
  (let ((fn-0 (function equal)) (args-1 (list (quote ((one . two) one)
  (lambda nil (let ((fn-0 (function equal)) (args-1 (list (quote ((one
  #[0 "\306\307!r\211q\210\310\311\312\313\314\315!\316\"\317\320%DC
  funcall(#[0 "\306\307!r\211q\210\310\311\312\313\314\315!\316\"\31
  ert--run-test-internal([cl-struct-ert--test-execution-info [cl-struc
  #[0 "r\304\305!q\210\306 )\307\310\311\312\313\314!\315\"\316\317%
  funcall(#[0 "r\304\305!q\210\306 )\307\310\311\312\313\314!\315\"\
  ert-run-test([cl-struct-ert-test surprise nil (lambda nil (let ((fn-
  ert-run-or-rerun-test([cl-struct-ert--stats surprise [[cl-struct-ert
  ert-run-tests(surprise #[385 "\306\307\"\203D\211\211G\310U\203\
  ert-run-tests-batch(surprise)
  ert-run-tests-batch-and-exit(surprise)
  eval-buffer(#<buffer  *load*> nil "/eme/eme.el"
  load-with-code-conversion("/eme/eme.el" "/eme/
  load("/eme/eme.el" nil t)
  command-line-1(("-l" "eme.el"))
  command-line()
  normal-top-level()
Test surprise condition:
    (ert-test-failed
     ((should
       (equal '...
        (progn ... ... ll)))
      :form
      (equal
       ((one . two)
        one)
       (two one))
      :value nil :explanation
      (list-elt 0
                (different-types
                 (one . two)
                 two))))
   FAILED  1/1  surprise

Ran 1 tests, 0 results as expected, 1 unexpected (2013-05-19 16:16:16+0200)

1 unexpected results:
   FAILED  surprise

Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Wavetables for the Waldorf Blofeld:
http://Synth.Stromeko.net/Downloads.html#BlofeldUserWavetables