mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
cl-defsubst: Use static scoping for args
* lisp/emacs-lisp/cl-macs.el (cl--slet): New function, partly extracted from `cl--slet*`. (cl--slet*): Use it. (cl--defsubst-expand): Use it to fix bug#47552. * test/lisp/emacs-lisp/cl-macs-tests.el (cl-defstruct-dynbound-label): New test.
This commit is contained in:
parent
37a09a4c00
commit
e2ee646b16
2 changed files with 31 additions and 14 deletions
|
|
@ -803,18 +803,28 @@ See Bug#57915."
|
|||
(macroexpand form)
|
||||
(should (string-empty-p messages))))))))
|
||||
|
||||
(defvar cl--test-a)
|
||||
|
||||
(ert-deftest cl-&key-arguments ()
|
||||
(cl-flet ((fn (&key x) x))
|
||||
(should-error (fn :x))
|
||||
(should (eq (fn :x :a) :a)))
|
||||
;; In ELisp function arguments are always statically scoped (bug#47552).
|
||||
(defvar cl--test-a)
|
||||
(let ((cl--test-a 'dyn)
|
||||
;; FIXME: How do we silence the "Lexical argument shadows" warning?
|
||||
(f (cl-function (lambda (&key cl--test-a b)
|
||||
(list cl--test-a (symbol-value 'cl--test-a) b)))))
|
||||
(should (equal (funcall f :cl--test-a 'lex :b 2) '(lex dyn 2)))))
|
||||
|
||||
(cl-defstruct cl--test-s
|
||||
cl--test-a b)
|
||||
|
||||
(ert-deftest cl-defstruct-dynbound-label-47552 ()
|
||||
"Check that labels can have the same name as dynbound vars."
|
||||
(let ((cl--test-a 'dyn))
|
||||
(let ((x (make-cl--test-s :cl--test-a 4 :b cl--test-a)))
|
||||
(should (cl--test-s-p x))
|
||||
(should (equal (cl--test-s-cl--test-a x) 4))
|
||||
(should (equal (cl--test-s-b x) 'dyn)))))
|
||||
|
||||
;;; cl-macs-tests.el ends here
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue