[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sbcl-commits
Subject:    [Sbcl-commits] master: bind *compiler-error-context* to nil for eval/compile
From:       Christophe Rhodes via Sbcl-commits <sbcl-commits () lists ! sourceforge ! net>
Date:       2020-05-31 9:54:26
Message-ID: 1590918867.74102.14213 () sfp-scm-2 ! v30 ! lw ! sourceforge ! com
[Download RAW message or body]

The branch "master" has been updated in SBCL:
       via  c3ae90f3a9dead985b0220f3c9ec9ac285ca7381 (commit)
      from  501a23a20b8eec53b08314ad6e9c4abe03d5324f (commit)

- Log -----------------------------------------------------------------
commit c3ae90f3a9dead985b0220f3c9ec9ac285ca7381
Author: Christophe Rhodes <csr21@cantab.net>
Date:   Sun May 31 10:52:26 2020 +0100

    bind *compiler-error-context* to nil for eval/compile
    
    If arbitrary code is somehow triggered while within the compiler, we
    do not want re-entrant evaluations to use the outer compiler error
    context for reporting proiblems with an inner compilation.
---
 src/compiler/target-main.lisp |  7 +++++++
 tests/compiler.test.sh        | 22 ++++++++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/src/compiler/target-main.lisp b/src/compiler/target-main.lisp
index 3d0736274..5c14b15ba 100644
--- a/src/compiler/target-main.lisp
+++ b/src/compiler/target-main.lisp
@@ -74,6 +74,13 @@
                   ;; controlled by function arguments and lexical variables.
                   (*compile-verbose* nil)
                   (*compile-print* nil)
+                  ;; in some circumstances, we can trigger execution
+                  ;; of user code during optimization, which can
+                  ;; re-enter the compiler through explicit calls to
+                  ;; EVAL or COMPILE.  Those inner evaluations
+                  ;; shouldn't attempt to report any compiler problems
+                  ;; using the outer compiler error context.
+                  (*compiler-error-context* nil)
                   (oops nil))
              (handler-bind (((satisfies handle-condition-p) #'handle-condition-handler))
                (unless source-paths
diff --git a/tests/compiler.test.sh b/tests/compiler.test.sh
index 5ecc027d1..90e688efa 100644
--- a/tests/compiler.test.sh
+++ b/tests/compiler.test.sh
@@ -513,5 +513,27 @@ cat > $tmpfilename <<EOF
 EOF
 fail_on_condition_during_compile sb-ext:compiler-note $tmpfilename
 
+cat > $tmpfilename <<EOF
+(in-package :cl-user)
+
+(eval-when (:compile-toplevel :load-toplevel :execute)
+  (defclass subclass (superclass) ((zslot2 :initarg :zslot2 :accessor zslot2))))
+
+(eval-when (:compile-toplevel :load-toplevel :execute)
+  (defclass superclass () ((c :initarg c :accessor c))))
+
+(eval-when (:compile-toplevel :load-toplevel :execute)
+  (sb-kernel::%invalidate-layout (sb-pcl::class-wrapper (find-class 'subclass))))
+
+(eval-when (:compile-toplevel :load-toplevel :execute)
+  (defmethod sb-mop:finalize-inheritance :after (class)
+    (eval '(defmethod z (x) (abcde)))
+    (funcall (compile nil '(lambda () (defun zz (x) (defgh)))))))
+
+(defun subclass-p (x)
+  (typep x 'subclass))
+EOF
+expect_warned_compile $tmpfilename
+
 # success
 exit $EXIT_TEST_WIN

-----------------------------------------------------------------------


hooks/post-receive
-- 
SBCL


_______________________________________________
Sbcl-commits mailing list
Sbcl-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sbcl-commits
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic