From 30c93105a8bce7b701a5043fb11254f6f1bdd6da Mon Sep 17 00:00:00 2001 From: Nikodemus Siivola Date: Fri, 17 Oct 2008 11:57:32 +0000 Subject: [PATCH] 1.0.21.22: COMPILE-FILE and toplevel symbols * The fopcompiler elided unused symbol references completely: warn and dump the appropriate SYMBOL-VALUE form even if the value is unused is the variable is undefined. * This reveals a missing start of a block comment in src/pcl/dfun.lisp -- fix it. Did you realize that ||# reads as a symbol? I didn't. One strike against using the "emacs friendly" #||...||# instead of #|...|#. * Also fix on #-sb-unicode issue in the test-suite. --- NEWS | 3 +++ src/compiler/fopcompile.lisp | 30 +++++++++++++++--------------- src/pcl/dfun.lisp | 1 + tests/compiler.pure.lisp | 3 ++- tests/compiler.test.sh | 7 +++++++ version.lisp-expr | 2 +- 6 files changed, 29 insertions(+), 17 deletions(-) diff --git a/NEWS b/NEWS index 5befbfa..deaea56 100644 --- a/NEWS +++ b/NEWS @@ -26,6 +26,9 @@ changes in sbcl-1.0.22 relative to 1.0.21: was broken. (reporteed by Willem Broekema) * bug fix: SB-EXT:NATIVE-NAMESTRING on Windows did not work on pathnames without a directory. + * bug fix: COMPILE-FILE did not warn about undefined variable + references at toplevel, and LOAD of the resulting fasl did + not signal an error. changes in sbcl-1.0.21 relative to 1.0.20: * new feature: the compiler is able to track the effective type of a diff --git a/src/compiler/fopcompile.lisp b/src/compiler/fopcompile.lisp index 16f9daf..6adfbf2 100644 --- a/src/compiler/fopcompile.lisp +++ b/src/compiler/fopcompile.lisp @@ -258,21 +258,21 @@ ;; Special variable (fopcompile `(symbol-value ',form) path for-value-p) ;; Lexical - (when for-value-p - (let* ((lambda-var (cdr (assoc form (lexenv-vars *lexenv*)))) - (handle (when lambda-var - (lambda-var-fop-value lambda-var)))) - (if handle - (sb!fasl::dump-push handle - *compile-object*) - (progn - ;; Undefined variable. Signal a warning, and - ;; treat it as a special variable reference, - ;; like the real compiler does. - (note-undefined-reference form :variable) - (fopcompile `(symbol-value ',form) - path - for-value-p)))))))))) + (let* ((lambda-var (cdr (assoc form (lexenv-vars *lexenv*)))) + (handle (when lambda-var + (lambda-var-fop-value lambda-var)))) + (if handle + (when for-value-p + (sb!fasl::dump-push handle *compile-object*)) + (progn + ;; Undefined variable. Signal a warning, and + ;; treat it as a special variable reference, like + ;; the real compiler does -- do not elide even if + ;; the value is unused. + (note-undefined-reference form :variable) + (fopcompile `(symbol-value ',form) + path + for-value-p))))))))) ((listp form) (multiple-value-bind (macroexpansion macroexpanded-p) (sb!xc:macroexpand form *lexenv*) diff --git a/src/pcl/dfun.lisp b/src/pcl/dfun.lisp index 3d5f353..96a0ffc 100644 --- a/src/pcl/dfun.lisp +++ b/src/pcl/dfun.lisp @@ -1790,6 +1790,7 @@ Except see also BREAK-VICIOUS-METACIRCLE. -- CSR, 2003-05-28 ;;; I'm aware of, but they look like they might be useful for ;;; debugging or performance tweaking or something, so I've just ;;; commented them out instead of deleting them. -- WHN 2001-03-28 +#|| (defun list-dfun (gf) (let* ((sym (type-of (gf-dfun-info gf))) (a (assq sym *dfun-list*))) diff --git a/tests/compiler.pure.lisp b/tests/compiler.pure.lisp index 6fcfb21..0623c1f 100644 --- a/tests/compiler.pure.lisp +++ b/tests/compiler.pure.lisp @@ -2589,7 +2589,8 @@ "foo")))) (with-test (:name :base-string-aref-type) - (assert (eq 'base-char + (assert (eq #+sb-unicode 'base-char + #-sb-unicode 'character (funcall (compile nil '(lambda (s) (sb-c::compiler-derived-type (aref (the base-string s) 0)))) diff --git a/tests/compiler.test.sh b/tests/compiler.test.sh index 5679935..0a479eb 100644 --- a/tests/compiler.test.sh +++ b/tests/compiler.test.sh @@ -348,6 +348,13 @@ EOF expect_failed_compile $tmpfilename cat > $tmpfilename < $tmpfilename <