- (push `(unless ,(if restp
- ;; (If RESTP, then the argument list might be
- ;; dotted, in which case ordinary LENGTH won't
- ;; work.)
- `(list-of-length-at-least-p ,path-0 ,minimum)
- `(proper-list-of-length-p ,path-0 ,minimum ,maximum))
- ,(if (eq error-fun 'error)
- `(arg-count-error ',error-kind ',name ,path-0
- ',lambda-list ,minimum
- ,explicit-maximum)
- `(,error-fun 'arg-count-error
- :kind ',error-kind
- ,@(when name `(:name ',name))
- :args ,path-0
- :lambda-list ',lambda-list
- :minimum ,minimum
- :maximum ,explicit-maximum)))
+ (push (let ((args-form (if (eq 'define-compiler-macro context)
+ `(if (eq 'funcall (car ,whole-var))
+ (cdr ,path-0)
+ ,path-0)
+ path-0)))
+ (with-unique-names (args)
+ `(let ((,args ,args-form))
+ (unless ,(if restp
+ ;; (If RESTP, then the argument list
+ ;; might be dotted, in which case
+ ;; ordinary LENGTH won't work.)
+ `(list-of-length-at-least-p ,args ,minimum)
+ `(proper-list-of-length-p ,args
+ ,minimum
+ ,maximum))
+ ,(if (eq error-fun 'error)
+ `(arg-count-error ',context ',name ,args
+ ',lambda-list ,minimum
+ ,explicit-maximum)
+ `(,error-fun 'arg-count-error
+ :kind ',context
+ ,@(when name `(:name ',name))
+ :args ,args
+ :lambda-list ',lambda-list
+ :minimum ,minimum
+ :maximum ,explicit-maximum))))))