master: lambda-var-ref-lvar: correctly omit the arg-count var

stassats via Sbcl-commits <[email protected]> Wed, 06 May 2026 14:24:32 +0000
Newsgroups gmane.lisp.steel-bank.cvs
Message-ID <[email protected]>
The branch "master" has been updated in SBCL:
       via  0056dfb1490375048fe4e62f2e5af4c94a325a83 (commit)
      from  f22a5de2afb2075b9245aef49235c52a0ca75d1b (commit)

- Log -----------------------------------------------------------------
commit 0056dfb1490375048fe4e62f2e5af4c94a325a83
Author: Stas Boukarev <[email protected]>
Date:   Wed May 6 17:19:31 2026 +0300

    lambda-var-ref-lvar: correctly omit the arg-count var
---
 src/compiler/ir1util.lisp  |  2 +-
 tests/bad-code.pure.lisp   | 11 +++++++++++
 tests/compiler-2.pure.lisp |  2 +-
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/compiler/ir1util.lisp b/src/compiler/ir1util.lisp
index 0c43c2c9c..022f874c0 100644
--- a/src/compiler/ir1util.lisp
+++ b/src/compiler/ir1util.lisp
@@ -1549,7 +1549,7 @@
                    (eq (combination-fun combination) lvar))
           (let ((args (combination-args combination)))
             (when (functional-kind-eq fun external toplevel-xep)
-              (pop args)) ;; arg-count
+              (pop vars)) ;; arg-count
             (loop for v in vars
                   for arg in args
                   when (eq v var)
diff --git a/tests/bad-code.pure.lisp b/tests/bad-code.pure.lisp
index c08839e6b..e822da9fa 100644
--- a/tests/bad-code.pure.lisp
+++ b/tests/bad-code.pure.lisp
@@ -1090,3 +1090,14 @@
                                                (lambda (a) (+ a 1)))
                                            1 2))
                                :allow-warnings t))))
+
+(with-test (:name :see-through-xep-call)
+  (assert (nth-value 3
+                     (checked-compile
+                      `(lambda (n l)
+                         (funcall (if n
+                                      (lambda (x key)
+                                        (member x l :key key))
+                                      #'list)
+                                  1 #'eq))
+                      :allow-style-warnings t))))
diff --git a/tests/compiler-2.pure.lisp b/tests/compiler-2.pure.lisp
index 1271399be..086e59d0d 100644
--- a/tests/compiler-2.pure.lisp
+++ b/tests/compiler-2.pure.lisp
@@ -5151,4 +5151,4 @@
                   (lambda (a) (+ a 2))
                   (lambda (a) (+ a 1)))
               1))
-   number))
+   (integer 2 3)))

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


hooks/post-receive
-- 
SBCL