diff options
| author | Eshel Yaron | 2025-10-07 23:28:07 +0200 |
|---|---|---|
| committer | Eshel Yaron | 2025-10-08 00:13:34 +0200 |
| commit | 61caa91875ceb61181c2d88b5e69daabdcb9b721 (patch) | |
| tree | 2aab58a9853f55421cc7f42e197a60fcb23ebab6 | |
| parent | d1d06099d65c298c7260c26c131d4e5779b0f944 (diff) | |
| download | emacs-61caa91875ceb61181c2d88b5e69daabdcb9b721.tar.gz emacs-61caa91875ceb61181c2d88b5e69daabdcb9b721.zip | |
; elisp-scope.el: Fix 'wrong-type-argument' in local function analyzers
* lisp/emacs-lisp/elisp-scope.el
(elisp-scope--local-function-analyzer): New function.
(elisp-scope-flet, elisp-scope-labels)
(elisp-scope-named-let): Use it.
(elisp-scope-cl-macrolet): Check that argument is
'symbol-with-pos-p' before calling 'symbol-with-pos-pos'.
| -rw-r--r-- | lisp/emacs-lisp/elisp-scope.el | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/lisp/emacs-lisp/elisp-scope.el b/lisp/emacs-lisp/elisp-scope.el index 3b757e646c5..f689f4bb34f 100644 --- a/lisp/emacs-lisp/elisp-scope.el +++ b/lisp/emacs-lisp/elisp-scope.el | |||
| @@ -747,12 +747,19 @@ Optional argument LOCAL is a local context to extend." | |||
| 747 | (elisp-scope-1 (car exps))) | 747 | (elisp-scope-1 (car exps))) |
| 748 | (let ((pos (or beg (cons 'gen (incf elisp-scope-counter))))) | 748 | (let ((pos (or beg (cons 'gen (incf elisp-scope-counter))))) |
| 749 | (elisp-scope-with-local-definition bare | 749 | (elisp-scope-with-local-definition bare |
| 750 | (lambda (f &rest args) | 750 | (elisp-scope--local-function-analyzer pos) |
| 751 | (elisp-scope-report 'function (symbol-with-pos-pos f) len pos) | ||
| 752 | (elisp-scope-n args)) | ||
| 753 | (elisp-scope-flet (cdr defs) body outspec)))) | 751 | (elisp-scope-flet (cdr defs) body outspec)))) |
| 754 | (elisp-scope-n body outspec))) | 752 | (elisp-scope-n body outspec))) |
| 755 | 753 | ||
| 754 | (defun elisp-scope--local-function-analyzer (pos) | ||
| 755 | (lambda (f &rest args) | ||
| 756 | (when (symbol-with-pos-p f) | ||
| 757 | (elisp-scope-report 'function | ||
| 758 | (symbol-with-pos-pos f) | ||
| 759 | (length (symbol-name (bare-symbol f))) | ||
| 760 | pos)) | ||
| 761 | (elisp-scope-n args))) | ||
| 762 | |||
| 756 | (defun elisp-scope-labels (defs forms outspec) | 763 | (defun elisp-scope-labels (defs forms outspec) |
| 757 | (if defs | 764 | (if defs |
| 758 | (let* ((def (car defs)) | 765 | (let* ((def (car defs)) |
| @@ -766,9 +773,7 @@ Optional argument LOCAL is a local context to extend." | |||
| 766 | (elisp-scope-report 'function beg len beg)) | 773 | (elisp-scope-report 'function beg len beg)) |
| 767 | (let ((pos (or beg (cons 'gen (incf elisp-scope-counter))))) | 774 | (let ((pos (or beg (cons 'gen (incf elisp-scope-counter))))) |
| 768 | (elisp-scope-with-local-definition bare | 775 | (elisp-scope-with-local-definition bare |
| 769 | (lambda (f &rest args) | 776 | (elisp-scope--local-function-analyzer pos) |
| 770 | (elisp-scope-report 'function (symbol-with-pos-pos f) len pos) | ||
| 771 | (elisp-scope-n args)) | ||
| 772 | (elisp-scope-lambda args body) | 777 | (elisp-scope-lambda args body) |
| 773 | (elisp-scope-flet (cdr defs) forms outspec)))) | 778 | (elisp-scope-flet (cdr defs) forms outspec)))) |
| 774 | (elisp-scope-n forms outspec))) | 779 | (elisp-scope-n forms outspec))) |
| @@ -1047,12 +1052,9 @@ Optional argument LOCAL is a local context to extend." | |||
| 1047 | (when-let* ((sym (car (ensure-list binding))) | 1052 | (when-let* ((sym (car (ensure-list binding))) |
| 1048 | (bare (elisp-scope-sym-bare sym))) | 1053 | (bare (elisp-scope-sym-bare sym))) |
| 1049 | (setq l (elisp-scope-local-new bare (elisp-scope-sym-pos sym) l)))) | 1054 | (setq l (elisp-scope-local-new bare (elisp-scope-sym-pos sym) l)))) |
| 1050 | (let ((pos (or beg (cons 'gen (incf elisp-scope-counter)))) | 1055 | (let ((pos (or beg (cons 'gen (incf elisp-scope-counter))))) |
| 1051 | (len (length (symbol-name bare)))) | ||
| 1052 | (elisp-scope-with-local-definition bare | 1056 | (elisp-scope-with-local-definition bare |
| 1053 | (lambda (f &rest args) | 1057 | (elisp-scope--local-function-analyzer pos) |
| 1054 | (elisp-scope-report 'function (symbol-with-pos-pos f) len pos) | ||
| 1055 | (elisp-scope-n args)) | ||
| 1056 | (let ((elisp-scope-local-bindings l)) (elisp-scope-n body outspec))))))) | 1058 | (let ((elisp-scope-local-bindings l)) (elisp-scope-n body outspec))))))) |
| 1057 | 1059 | ||
| 1058 | (defun elisp-scope-rx (regexps) | 1060 | (defun elisp-scope-rx (regexps) |
| @@ -1550,7 +1552,8 @@ Optional argument LOCAL is a local context to extend." | |||
| 1550 | (let ((pos (or beg (cons 'gen (incf elisp-scope-counter))))) | 1552 | (let ((pos (or beg (cons 'gen (incf elisp-scope-counter))))) |
| 1551 | (elisp-scope-with-local-definition bare | 1553 | (elisp-scope-with-local-definition bare |
| 1552 | (lambda (f &rest _) | 1554 | (lambda (f &rest _) |
| 1553 | (elisp-scope-report 'macro (symbol-with-pos-pos f) len pos)) | 1555 | (when (symbol-with-pos-p f) |
| 1556 | (elisp-scope-report 'macro (symbol-with-pos-pos f) len pos))) | ||
| 1554 | (elisp-scope-cl-macrolet (cdr bindings) body outspec)))))) | 1557 | (elisp-scope-cl-macrolet (cdr bindings) body outspec)))))) |
| 1555 | (elisp-scope-n body outspec))) | 1558 | (elisp-scope-n body outspec))) |
| 1556 | 1559 | ||