From ee4b57516a9b39c9cd0fb8b66f8816e7c8e4a6cf Mon Sep 17 00:00:00 2001
From: rtoy <rtoy>
Date: Mon, 15 Feb 2010 16:34:42 +0000
Subject: [PATCH] Fix from Helmut Eller for a bug mentioned by Madhu on
 cmucl-imp, 2010/02/14:

$ echo '(compile nil (lambda (x) x))' > foo.lisp
$ lisp -noinit
* (compile-file "foo.lisp")
* (load *)

causes an error.
---
 compiler/main.lisp | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/compiler/main.lisp b/compiler/main.lisp
index 2e9ba0a9e..d5c20e507 100644
--- a/compiler/main.lisp
+++ b/compiler/main.lisp
@@ -5,7 +5,7 @@
 ;;; Carnegie Mellon University, and has been placed in the public domain.
 ;;;
 (ext:file-comment
-  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/main.lisp,v 1.148 2010/01/22 06:17:13 rtoy Exp $")
+  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/main.lisp,v 1.149 2010/02/15 16:34:42 rtoy Exp $")
 ;;;
 ;;; **********************************************************************
 ;;;
@@ -1945,7 +1945,17 @@ in the user USER-INFO slot of STREAM-SOURCE-LOCATIONs.")
 	     (start-warnings *compiler-warning-count*)
 	     (start-notes *compiler-note-count*)
 	     (*lexical-environment* (make-null-environment))
-	     (form `#',(get-lambda-to-compile definition))
+	     ;; From Helmut Eller: ... we don't need the
+	     ;; lambda-expression. To quote the CLHS entry for
+	     ;; compile:
+	     ;;
+	     ;;   If the definition is already a compiled function,
+	     ;;   compile either produces that function itself (i.e.,
+	     ;;   is an identity operation) or an equivalent function.
+	     (form (etypecase definition
+		     ((or cons eval:interpreted-function)
+		      `#',(get-lambda-to-compile definition))
+		     (function `',definition)))
 	     (*source-info* (make-lisp-source-info form))
 	     (*top-level-lambdas* ())
 	     (*converting-for-interpreter* nil)
-- 
GitLab