all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Paul Pogonyshev <pogonyshev@gmail.com>
To: 26073@debbugs.gnu.org
Subject: bug#26073: workaround
Date: Sun, 19 Mar 2017 20:31:58 +0100	[thread overview]
Message-ID: <CAG7Bpao7GuWUiRwb5Yoi5tt3ie6QengUx_pK91-=tCudQ8Y5gQ@mail.gmail.com> (raw)
In-Reply-To: <CAG7Bpao-E1pn1H-wgfCoJHqO4wHF1NFzw8W13--pVhVY_Sr1Sg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 395 bytes --]

Attached patch is a workaround for the bug. It adds special handling
of lambdas to `cl--sm-macroexpand', similar to the way it handles
`let'. However, there is an unhandled case of "binding" symbols to
forms. I'm also not sure what would be correct behavior in old
non-lexical-scope code (do we still care?).

So, this patch cannot really go in as-is, but it can serve as a base
for a real fix.

[-- Attachment #2: 0001-Fix-for-rebinding-in-lambdas-in-generator-functions.patch --]
[-- Type: text/x-patch, Size: 1308 bytes --]

diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index 58bcdd52ac..52d946a0c0 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -2092,6 +2092,21 @@ except that it additionally expands symbol macros."
                                 (car exp))
                              ,(nreverse nbs)
                              ,@body)))))
+            (`(function (lambda . ,(or `(,params . ,body) _dontcare)))
+             (let (found nbs)
+               (dolist (param params)
+                 (let* ((sm (assq param env)))
+                   (push (if (not (cdr sm))
+                             param
+                           (let ((nexp (cadr sm)))
+                             (setq found t)
+                             (unless (symbolp nexp) (error "FIXME"))
+                             nexp))
+                         nbs)))
+               (when found
+                 (setq exp `(function (lambda
+                                        ,(nreverse nbs)
+                                        ,@body))))))
             ;; FIXME: The behavior of CL made sense in a dynamically scoped
             ;; language, but for lexical scoping, Common-Lisp's behavior might
             ;; make more sense (and indeed, CL behaves like Common-Lisp w.r.t

  parent reply	other threads:[~2017-03-19 19:31 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-12 13:25 bug#26073: bug in generator function with nested dash anaphoric macros Paul Pogonyshev
2017-03-12 14:05 ` bug#26073: Simplified testcase Paul Pogonyshev
2017-03-19 19:31 ` Paul Pogonyshev [this message]
2017-03-20  0:49   ` bug#26073: workaround Stefan Monnier
2017-03-20  9:04     ` Paul Pogonyshev
2017-03-20  9:22       ` Paul Pogonyshev
2017-09-26 14:38         ` Stefan Monnier
2017-09-28 17:18           ` Paul Pogonyshev
2017-09-28 20:07             ` Stefan Monnier
2017-09-28 19:39           ` Philipp Stephani
2017-09-28 20:09             ` Stefan Monnier
2017-11-27 20:34             ` Stefan Monnier
2018-02-09  0:34               ` Noam Postavsky
2018-02-09  2:43                 ` Stefan Monnier
2018-02-15  2:37                   ` Noam Postavsky
2017-03-20 13:25       ` Stefan Monnier
2017-03-20 14:20         ` Paul Pogonyshev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAG7Bpao7GuWUiRwb5Yoi5tt3ie6QengUx_pK91-=tCudQ8Y5gQ@mail.gmail.com' \
    --to=pogonyshev@gmail.com \
    --cc=26073@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.