Skip to content

Commit 367a7dc

Browse files
author
Mark Evenson
committed
DISASSEMBLE type-error on bad argument
CLHS specifies `disassemble`'s argument as an *extended function designator* — i.e. `(or function symbol (cons (eql setf) (cons symbol null)))` — and mandates a `TYPE-ERROR` otherwise. `DISASSEMBLE.ERROR.3` iterates the mini-universe expecting `TYPE-ERROR` for everything outside that set, but ABCL accepted arbitrary junk, often crashing inside `disassemble-function`. Added an explicit `typep` guard that signals `TYPE-ERROR` with `:datum` and `:expected-type` populated. The accepted type is widened with `(cons (eql lambda) t)` so that `DISASSEMBLE.3` (`(disassemble '(lambda (x y) (cons y x)))`, which expects success) keeps passing.
1 parent dead547 commit 367a7dc

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/org/armedbear/lisp/disassemble.lisp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,14 @@ CL:DISASSEMBLE."
210210
;; (get-java-field (elt (#"get" (elt (#"getFields" (#"getClass" #'foo)) 0) #'foo) 0) "value")
211211

212212
(defun disassemble (arg)
213+
(unless (typep arg '(or function symbol
214+
(cons (eql setf) (cons symbol null))
215+
(cons (eql lambda) t)))
216+
(error 'type-error
217+
:datum arg
218+
:expected-type '(or function symbol
219+
(cons (eql setf) (cons symbol null))
220+
(cons (eql lambda) t))))
213221
(print-lines-with-prefix (disassemble-function arg)))
214222

215223
(defun print-lines-with-prefix (string)

0 commit comments

Comments
 (0)