From 2afbde902742b1aa64daa31a635ba564f14b35ae Mon Sep 17 00:00:00 2001 From: Wilfred Hughes Date: Fri, 10 Dec 2021 23:03:15 -0800 Subject: Use lexical-binding in tests and fix crash exposed argdesc in byte-code function objects may be an integer rather than a list, so handle that case gracefully. --- helpful.el | 9 ++++++++- test/helpful-unit-test.el | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/helpful.el b/helpful.el index 3ec6ed9..c4cdd28 100644 --- a/helpful.el +++ b/helpful.el @@ -2470,7 +2470,14 @@ For example, \"(some-func FOO &optional BAR)\"." ((symbolp sym) (help-function-arglist sym)) ((byte-code-function-p sym) - (aref sym 0)) + ;; argdesc can be a list of arguments or an integer + ;; encoding the min/max number of arguments. See + ;; Byte-Code Function Objects in the elisp manual. + (let ((argdesc (aref sym 0))) + (if (consp argdesc) + argdesc + ;; TODO: properly handle argdesc values. + nil))) (t ;; Interpreted function (lambda ...) (cadr sym)))) diff --git a/test/helpful-unit-test.el b/test/helpful-unit-test.el index 4e87efe..a07aa8e 100644 --- a/test/helpful-unit-test.el +++ b/test/helpful-unit-test.el @@ -1,3 +1,5 @@ +;;; helpful-unit-test.el -*- lexical-binding: t; -*- + (require 'ert) (require 'edebug) (require 'helpful) -- cgit v1.0