1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

Propagate function calls also when hiddend under funcall

* lisp/emacs-lisp/comp.el (comp-fwprop-call): Propagate functions
	also when called under `funcall'.
	* test/src/comp-tests.el (comp-tests-type-spec-tests): Add a test.
This commit is contained in:
Andrea Corallo 2020-12-28 11:54:34 +01:00
parent e532ec9552
commit eafcc8eda0
2 changed files with 10 additions and 1 deletions

View file

@ -2642,6 +2642,10 @@ Return non-nil if the function is folded successfully."
F is the function being called with arguments ARGS.
Fold the call in case."
(unless (comp-function-call-maybe-fold insn f args)
(when (and (eq 'funcall f)
(comp-mvar-value-vld-p (car args)))
(setf f (comp-mvar-value (car args))
args (cdr args)))
(when-let ((cstr-f (gethash f comp-known-func-cstr-h)))
(let ((cstr (comp-cstr-f-ret cstr-f)))
(setf (comp-mvar-range lval) (comp-cstr-range cstr)

View file

@ -1137,7 +1137,12 @@ Return a list of results."
((defun comp-tests-ret-type-spec-f (x)
(when (<= 1 x 5)
(1- x)))
(or null float (integer 0 4)))))
(or null float (integer 0 4)))
;; 47
((defun comp-tests-ret-type-spec-f ()
(error "foo"))
nil)))
(defun comp-tests-define-type-spec-test (number x)
`(comp-deftest ,(intern (format "ret-type-spec-%d" number)) ()