Assert types for NCONC.
Some checks are pending
CL-host / ecl (push) Waiting to run
CL-host / clisp (push) Waiting to run
CL-host / ccl (push) Waiting to run
CL-host / cmucl (push) Waiting to run
CL-host / sbcl (push) Waiting to run
CL-host / self (push) Waiting to run
CL-host / compare-xc-host-fasls (ccl, false) (push) Blocked by required conditions
CL-host / compare-xc-host-fasls (clisp, false) (push) Blocked by required conditions
CL-host / compare-xc-host-fasls (cmucl, false) (push) Blocked by required conditions
CL-host / compare-xc-host-fasls (self, false) (push) Blocked by required conditions
Linux / build (x86, --with-sb-thread, ) (push) Waiting to run
Linux / build (x86, --without-sb-thread, ) (push) Waiting to run
Linux / build (x86, --without-sb-unicode, ) (push) Waiting to run
Linux / build (x86-64, --with-mark-region-gc) (push) Waiting to run
Linux / build (x86-64, --with-sb-fasteval --without-sb-eval, fasteval) (push) Waiting to run
Linux / build (x86-64, --with-sb-thread, ) (push) Waiting to run
Linux / build (x86-64, --with-sb-thread, sse4) (push) Waiting to run
Linux / build (x86-64, --without-sb-thread, ) (push) Waiting to run
Linux / build (x86-64, --without-sb-unicode, ) (push) Waiting to run
Mac / build (--without-sb-thread, x86-64) (push) Waiting to run
Mac / build (arm64, --with-mark-region-gc) (push) Waiting to run
Mac / build (arm64, --with-sb-thread) (push) Waiting to run
Mac / build (x86-64, --with-mark-region-gc) (push) Waiting to run
Mac / build (x86-64, --with-sb-thread) (push) Waiting to run
Windows / build (push) Waiting to run

This commit is contained in:
Stas Boukarev 2024-06-28 15:44:31 +03:00
parent 977d5ef8af
commit 9917571207
3 changed files with 26 additions and 4 deletions

View file

@ -1020,9 +1020,8 @@
;;; express that in this syntax, append-call-type-deriver does that.
(defknown append (&rest t) t (flushable)
:call-type-deriver #'append-call-type-deriver)
(defknown sb-impl::append2 (list t) t
(flushable no-verify-arg-count)
:call-type-deriver #'append-call-type-deriver)
(defknown sb-impl::append2 (proper-list t) t
(flushable no-verify-arg-count))
(defknown copy-list (proper-or-dotted-list) list (flushable)
:derive-type (sequence-result-nth-arg 0 :preserve-dimensions t))
@ -1032,7 +1031,8 @@
(defknown copy-tree (t) t (flushable recursive))
(defknown revappend (proper-list t) t (flushable))
(defknown nconc (&rest (modifying t :butlast t)) t ())
(defknown nconc (&rest (modifying t :butlast t)) t ()
:call-type-deriver #'nconc-call-type-deriver)
(defknown nreconc ((modifying list) t) t (important-result))
(defknown butlast (proper-or-dotted-list &optional unsigned-byte) list (flushable))

View file

@ -571,6 +571,25 @@
(not trusted))
(reoptimize-lvar arg)))))
(defun nconc-call-type-deriver (call trusted)
(let* ((policy (lexenv-policy (node-lexenv call)))
(args (combination-args call))
(list-type (specifier-type 'list)))
;; All but the last argument should be proper lists
(loop for (arg next) on args
while next
do
(add-annotation
arg
(make-lvar-proper-sequence-annotation
:kind 'proper-or-dotted-list))
(when (policy policy (> check-constant-modification 0))
(add-annotation arg
(make-lvar-modified-annotation :caller 'nconc)))
(when (and (assert-lvar-type arg list-type policy)
(not trusted))
(reoptimize-lvar arg)))))
;;; It's either (number) or (real real)
(defun atan-call-type-deriver (call trusted)
(let* ((policy (lexenv-policy (node-lexenv call)))

View file

@ -270,6 +270,9 @@
(specifier-type t)
(specifier-type 'list)))
(setf (fun-info-externally-checkable-type (fun-info-or-lose 'nconc))
#'append-externally-checkable-type-optimizer)
(flet ((remove-nil (fun args)
(let ((remove
(loop for (arg . rest) on args