* bug#8712: 24.0.50; getting the "Forgot to expand macro XXXX" error - problem? solution?
@ 2011-05-21 21:00 Drew Adams
2011-05-21 21:06 ` Drew Adams
2011-05-22 18:14 ` Stefan Monnier
0 siblings, 2 replies; 6+ messages in thread
From: Drew Adams @ 2011-05-21 21:00 UTC (permalink / raw)
To: 8712
When byte-compiling I'm getting the famous "Forgot to expand macro XXXX"
error.
AFAICT, the email threads about that error just said, in effect:
1. Stefan thinks he found a bug that caused this, and fixed it, but he
isn't sure.
2. Concerning Emacs sources, just do a make -k clean and then try again.
But I'm seeing this for my own code. I guess I need to understand the
solution (what to do) and, preferably, the cause of the problem.
I put the source files in a new directory, load the file with the
defmacros, and try to byte-compile a file that uses them. I get the
above error, with XXXX = `push'.
These are the files: icicles-mac.el has the macros; icicles-cmd1.el is
the file whose byte-compiling raises the error.
With the source files (only) in new directory foo, cd to foo,
(add-to-list 'load-path "."), then M-x load-library icicles.
Then try to byte-compile icicles-cmd1.el.
The files you will need are here:
http://www.emacswiki.org/cgi-bin/wiki?action=index;match=%5C.(el%7Ctar)(%5C.gz)%
3F%24
You will need these files, in order to load library `icicles':
hexrgb.el
icicles-cmd1.el
icicles-cmd2.el
icicles-face.el
icicles-fn.el
icicles-mac.el
icicles-mcmd.el
icicles-mode.el
icicles-opt.el
icicles-var.el
icicles.el
To reproduce, after loading those source files try to byte-compile
icicles-cmd1.el. You'll get this error:
icicles-cmd1.el:3066:91:Error: Wrong type argument: listp, "Forgot to
expand macro push"
I really don't understand. Please advise. Is this an Emacs bug that
has been fixed or will be fixed? Is there something that I need to do
to make the code compatible with lexbind? What's the story? Thx.
In GNU Emacs 24.0.50.1 (i386-mingw-nt5.1.2600)
of 2011-05-16 on 3249CTO
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (4.5) --no-opt --cflags
-Ic:/build/include'
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#8712: 24.0.50; getting the "Forgot to expand macro XXXX" error - problem? solution?
2011-05-21 21:00 bug#8712: 24.0.50; getting the "Forgot to expand macro XXXX" error - problem? solution? Drew Adams
@ 2011-05-21 21:06 ` Drew Adams
2011-05-22 18:14 ` Stefan Monnier
1 sibling, 0 replies; 6+ messages in thread
From: Drew Adams @ 2011-05-21 21:06 UTC (permalink / raw)
To: 8712
Forgot to mention that the same problem occurs when trying to byte-compile
icicles-cmd2.el. In that case the error message is:
icicles-cmd2.el:3033:11:Error: Wrong type argument: listp, "Forgot to expand
macro push"
So the same problem appears in icicles-cmd1.el and icicles-cmd2.el.
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#8712: 24.0.50; getting the "Forgot to expand macro XXXX" error - problem? solution?
2011-05-21 21:00 bug#8712: 24.0.50; getting the "Forgot to expand macro XXXX" error - problem? solution? Drew Adams
2011-05-21 21:06 ` Drew Adams
@ 2011-05-22 18:14 ` Stefan Monnier
2011-05-22 20:00 ` Drew Adams
1 sibling, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2011-05-22 18:14 UTC (permalink / raw)
To: Drew Adams; +Cc: 8712
> icicles-cmd1.el:3066:91:Error: Wrong type argument: listp, "Forgot to
> expand macro push"
I think the patch below fixes your problem, thanks. Please confirm.
Stefan
=== modified file 'lisp/emacs-lisp/bytecomp.el'
--- lisp/emacs-lisp/bytecomp.el 2011-05-12 02:36:05 +0000
+++ lisp/emacs-lisp/bytecomp.el 2011-05-22 17:36:39 +0000
@@ -2892,8 +2892,8 @@
That command is designed for interactive use only" fn))
(if (and (fboundp (car form))
(eq (car-safe (symbol-function (car form))) 'macro))
- (byte-compile-report-error
- (format "Forgot to expand macro %s" (car form))))
+ (byte-compile-log-warning
+ (format "Forgot to expand macro %s" (car form)) nil :error))
(if (and handler
;; Make sure that function exists. This is important
;; for CL compiler macros since the symbol may be
@@ -2991,7 +2991,7 @@
(cond
((<= (+ alen alen) fmax2)
;; Add missing &optional (or &rest) arguments.
- (dotimes (i (- (/ (1+ fmax2) 2) alen))
+ (dotimes (_ (- (/ (1+ fmax2) 2) alen))
(byte-compile-push-constant nil)))
((zerop (logand fmax2 1))
(byte-compile-log-warning "Too many arguments for inlined function"
=== modified file 'lisp/emacs-lisp/macroexp.el'
--- lisp/emacs-lisp/macroexp.el 2011-03-12 03:32:43 +0000
+++ lisp/emacs-lisp/macroexp.el 2011-05-22 18:11:30 +0000
@@ -169,14 +169,22 @@
;; here, so that any code that cares about the difference will
;; see the same transformation.
;; First arg is a function:
- (`(,(and fun (or `apply `mapcar `mapatoms `mapconcat `mapc))
+ (`(,(and fun (or `funcall `apply `mapcar `mapatoms `mapconcat `mapc))
',(and f `(lambda . ,_)) . ,args)
+ (byte-compile-log-warning
+ (format "%s quoted with ' rather than with #'"
+ (list 'lambda (nth 1 f) '...))
+ t)
;; We don't use `maybe-cons' since there's clearly a change.
(cons fun
(cons (macroexpand-all-1 (list 'function f))
(macroexpand-all-forms args))))
;; Second arg is a function:
(`(,(and fun (or `sort)) ,arg1 ',(and f `(lambda . ,_)) . ,args)
+ (byte-compile-log-warning
+ (format "%s quoted with ' rather than with #'"
+ (list 'lambda (nth 1 f) '...))
+ t)
;; We don't use `maybe-cons' since there's clearly a change.
(cons fun
(cons (macroexpand-all-1 arg1)
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#8712: 24.0.50; getting the "Forgot to expand macro XXXX" error - problem? solution?
2011-05-22 18:14 ` Stefan Monnier
@ 2011-05-22 20:00 ` Drew Adams
2011-05-23 1:36 ` Stefan Monnier
0 siblings, 1 reply; 6+ messages in thread
From: Drew Adams @ 2011-05-22 20:00 UTC (permalink / raw)
To: 'Stefan Monnier'; +Cc: 8712
> I think the patch below fixes your problem, thanks. Please confirm.
I patched the corresponding functions by hand, loaded their original source
files, then loaded the patched functions. I then byte-compiled
icicles-cmd[12].el. No byte-compilation errors, so it seems, at least on the
surface, that this is fixed. The compilation was _very_ slow, but that's no
doubt because I used the source code rather than byte-compiled code.
Thanks for the fix.
I do have a question about the follownig warning, however (which I have not
seen/noticed before):
(lambda (opt) ...) quoted with ' rather than with #'
That presumably comes from a defmacro that has, in effect, this:
` ... (let* (... (something (lambda (opt)...))))
That is, an unquoted lambda inside a backquote. The backquote expands to (quote
(lambda...)) no doubt.
I have a few such macros, and I use them heavily. I get this same warning
zillions of times (460 times just for icicles-cmd1.el, 30 times for
icicles-cmd2.el). This is quite annoying.
What is the suggested/recommended way to write such code, to avoid this warning?
Do I now need to add #' in front of a lambda inside a backquote?
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#8712: 24.0.50; getting the "Forgot to expand macro XXXX" error - problem? solution?
2011-05-22 20:00 ` Drew Adams
@ 2011-05-23 1:36 ` Stefan Monnier
2011-05-23 3:55 ` Drew Adams
0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2011-05-23 1:36 UTC (permalink / raw)
To: Drew Adams; +Cc: 8712
> I do have a question about the follownig warning, however (which I have not
> seen/noticed before):
> (lambda (opt) ...) quoted with ' rather than with #'
> That presumably comes from a defmacro that has, in effect, this:
> ` ... (let* (... (something (lambda (opt)...))))
This is because you pass (lambda (opt) ...) as `function' argument
to a macro that then splices it with
`(.... ',function ....)
so the expanded code contains '(lambda (opt) ...).
Splice it with #', instead.
> That is, an unquoted lambda inside a backquote. The backquote expands
> to (quote (lambda...)) no doubt.
No, backquote does not know you're building code, so it can't freely
decide to add `quote' symbols as it sees fit.
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#8712: 24.0.50; getting the "Forgot to expand macro XXXX" error - problem? solution?
2011-05-23 1:36 ` Stefan Monnier
@ 2011-05-23 3:55 ` Drew Adams
0 siblings, 0 replies; 6+ messages in thread
From: Drew Adams @ 2011-05-23 3:55 UTC (permalink / raw)
To: 'Stefan Monnier'; +Cc: 8712
> > That presumably comes from a defmacro that has, in effect, this:
> > ` ... (let* (... (something (lambda (opt)...))))
>
> This is because you pass (lambda (opt) ...) as `function' argument
> to a macro that then splices it with `(.... ',function ....)
> so the expanded code contains '(lambda (opt) ...).
Oh, right; I was looking in the wrong place. Thx.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-05-23 3:55 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-21 21:00 bug#8712: 24.0.50; getting the "Forgot to expand macro XXXX" error - problem? solution? Drew Adams
2011-05-21 21:06 ` Drew Adams
2011-05-22 18:14 ` Stefan Monnier
2011-05-22 20:00 ` Drew Adams
2011-05-23 1:36 ` Stefan Monnier
2011-05-23 3:55 ` Drew Adams
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.