Don't rely on dynamic scoping to fix bug#59213

Rather than look up a dynamically scoped var to decide whether to trim
closures, use an ad-hoc marker on those closures which should not be trimmed.

* lisp/emacs-lisp/cconv.el (cconv-dont-trim-unused-variables): Delete var.
(cconv-make-interpreted-closure): Use a `:closure-dont-trim-context`
markers instead.

* lisp/emacs-lisp/edebug.el (edebug-make-enter-wrapper): Use
`:closure-dont-trim-context` rather than `cconv-dont-trim-unused-variables`.

* lisp/emacs-lisp/testcover.el (testcover-analyze-coverage): Remove
workaround for `cconv-dont-trim-unused-variables`.

* test/lisp/emacs-lisp/cconv-tests.el (cconv-safe-for-space): New test.
This commit is contained in:
Stefan Monnier 2023-02-18 12:56:24 -05:00
parent 2ac8d7e64a
commit 750bc57cbb
4 changed files with 34 additions and 21 deletions

View file

@ -1217,16 +1217,18 @@ purpose by adding an entry to this alist, and setting
(setq edebug-old-def-name nil))
(setq edebug-def-name
(or edebug-def-name edebug-old-def-name (gensym "edebug-anon")))
`(let ((cconv-dont-trim-unused-variables t))
(edebug-enter
(quote ,edebug-def-name)
,(if edebug-inside-func
`(list
;; Doesn't work with more than one def-body!!
;; But the list will just be reversed.
,@(nreverse edebug-def-args))
'nil)
(function (lambda () ,@forms)))))
`(edebug-enter
(quote ,edebug-def-name)
,(if edebug-inside-func
`(list
;; Doesn't work with more than one def-body!!
;; But the list will just be reversed.
,@(nreverse edebug-def-args))
'nil)
;; Make sure `forms' is not nil so we don't accidentally return
;; the magic keyword. Mark the closure so we don't throw away
;; unused vars (bug#59213).
#'(lambda () :closure-dont-trim-context ,@(or forms '(nil)))))
(defvar edebug-form-begin-marker) ; the mark for def being instrumented