mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-01-14 13:21:54 -08:00
The optional type checks generated by the compiler were invalid when the type contained a complex function type
This commit is contained in:
parent
ad05b12dd6
commit
7574590108
2 changed files with 19 additions and 2 deletions
|
|
@ -189,6 +189,11 @@ ECL 8.9.0:
|
|||
|
||||
- DIRECTORY would fail to handle symbolic links under certain conditions.
|
||||
|
||||
- The optional type checks generated by the compiler are based on TYPEP and
|
||||
thus they fail when the declaration type contains a function type (FUNCTION
|
||||
(...) ...) This is now solved by replacing parts of these types with the
|
||||
simple type FUNCTION.
|
||||
|
||||
;;; Local Variables: ***
|
||||
;;; mode:text ***
|
||||
;;; fill-column:79 ***
|
||||
|
|
|
|||
|
|
@ -439,11 +439,23 @@
|
|||
;; TYPE CHECKING
|
||||
;;
|
||||
|
||||
(defun remove-function-types (type)
|
||||
(if (atom type)
|
||||
type
|
||||
(case (first type)
|
||||
((OR AND NOT)
|
||||
(cons (first type) (loop for i in (rest type) collect (remove-function-types i))))
|
||||
(FUNCTION 'FUNCTION)
|
||||
(otherwise type))))
|
||||
|
||||
(defmacro optional-check-type (&whole whole var-name type &environment env)
|
||||
"Generates a type check that is only activated for the appropriate
|
||||
safety settings and when the type is not trivial."
|
||||
(unless (policy-automatic-check-type-p env)
|
||||
(cmpnote "Unable to emit check for variable ~A" whole))
|
||||
(when (policy-automatic-check-type-p env)
|
||||
(unless (subtypep 't type)
|
||||
`(check-type ,var-name ,type))))
|
||||
(setf type (remove-function-types type))
|
||||
(multiple-value-bind (ok valid)
|
||||
(subtypep 't type)
|
||||
(unless (or ok (not valid))
|
||||
`(check-type ,var-name ,type)))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue