diff --git a/compiler/envanal.lisp b/compiler/envanal.lisp index 2a73c1e8f35d4839e6cef8190ed6b8565dc1264c..e21d840c629975d0fdfb478b23bd59638b30d086 100644 --- a/compiler/envanal.lisp +++ b/compiler/envanal.lisp @@ -38,18 +38,19 @@ (declare (type component component)) (assert (not (component-new-functions component))) (dolist (fun (component-lambdas component)) - (let* ((f (if (eq (functional-kind fun) :external) - (functional-entry-function fun) - fun)) - (dtype (definition-type f)) - (node (lambda-bind fun))) - (setf (leaf-type f) dtype) - (when (and (eq (function-type-returns dtype) *empty-type*) - (or (functional-entry-function f) - (null (functional-kind f))) - (policy node (>= safety brevity))) - (let ((*compiler-error-context* node)) - (compiler-note "Function does not return.")))) + (let* ((ef (functional-entry-function fun)) + (kind (functional-kind fun)) + (f (cond ((eq (functional-kind fun) :external) + (when (optional-dispatch-p ef) ef)) + ((null kind) fun)))) + (when f + (let* ((dtype (definition-type f)) + (node (lambda-bind fun))) + (setf (leaf-type f) dtype) + (when (and (eq (function-type-returns dtype) *empty-type*) + (policy node (>= safety brevity))) + (let ((*compiler-error-context* node)) + (compiler-note "Function does not return.")))))) (get-lambda-environment fun))