(neg dst) nil)
(cl-return-from comp-cstr-union-1-no-mem dst))
+ ;; Verify disjoint condition between positive types and
+ ;; negative types coming from values, in case give-up.
+ (let ((neg-value-types (nconc (mapcar #'type-of (valset neg))
+ (when (range neg)
+ '(integer)))))
+ (when (cl-some (lambda (x)
+ (cl-some (lambda (y)
+ (and (not (eq y x))
+ (comp-subtype-p y x)))
+ neg-value-types))
+ (typeset pos))
+ (setf (typeset dst) '(t)
+ (valset dst) ()
+ (range dst) ()
+ (neg dst) nil)
+ (cl-return-from comp-cstr-union-1-no-mem dst)))
+
;; Value propagation.
(cond
((and (valset pos) (valset neg)
;; Range propagation
(if (and range
(or (range pos)
- (range neg))
- (cl-notany (lambda (x)
- (comp-subtype-p 'integer x))
- (typeset pos)))
- (if (or (valset neg)
- (typeset neg))
+ (range neg)))
+ (if (or (valset neg) (typeset neg))
(setf (range neg)
(if (memq 'integer (typeset neg))
(comp-range-negation (range pos))
;; When possibile do not return a negated cstr.
(setf (typeset dst) (typeset pos)
(valset dst) (valset pos)
- (range dst) (comp-range-union
- (comp-range-negation (range neg))
- (range pos))
+ (range dst) (unless (memq 'integer (typeset dst))
+ (comp-range-union
+ (comp-range-negation (range neg))
+ (range pos)))
(neg dst) nil)
(cl-return-from comp-cstr-union-1-no-mem dst))
(setf (range neg) ()))
((not symbol) . (not symbol))
((or (member foo) (not (member foo bar))) . (not (member bar)))
((or (member foo bar) (not (member foo))) . t)
- ;; Intentionally conservative, see `comp-cstr-union'.
+ ;; Intentionally conservative, see `comp-cstr-union-1-no-mem'.
((or symbol (not sequence)) . t)
((or symbol (not symbol)) . t)
;; Conservative.
((or (member foo) (not string)) . (not string))
((or (not (integer 1 2)) integer) . integer)
((or (not (integer 1 2)) (not integer)) . (not integer))
- ((or (integer 1 2) (not integer)) . (not (or integer (integer * 0) (integer 3 *)))))
+ ((or (integer 1 2) (not integer)) . (not (or integer (integer * 0) (integer 3 *))))
+ ((or number (not (integer 1 2))) . t)
+ ((or atom (not (integer 1 2))) . t)
+ ((or atom (not (member foo))) . t))
"Alist type specifier -> expected type specifier.")
(defmacro comp-cstr-synthesize-tests ()