diff --git a/src/typechecker/define-type.lisp b/src/typechecker/define-type.lisp index 24219759a..64a2c51cc 100644 --- a/src/typechecker/define-type.lisp +++ b/src/typechecker/define-type.lisp @@ -324,8 +324,8 @@ (let* ((defined-variables (mapcar #'parser:keyword-src-name (parser:type-definition-vars parsed-type))) (used-variables (mapcar #'tc:tyvar-id (tc:type-variables aliased-type))) (unused-variables (loop :for tyvar :in defined-variables - :when (not (member (tc:tyvar-id (partial-type-env-lookup-var partial-env tyvar parsed-type)) - used-variables)) + :unless (member (tc:tyvar-id (partial-type-env-lookup-var partial-env tyvar parsed-type)) + used-variables) :collect tyvar)) (number-of-unused-variables (length unused-variables))) (unless (zerop number-of-unused-variables) @@ -333,7 +333,7 @@ (tc-note parsed-type "Type alias ~S defines unused type variable~P ~{:~A~^ ~}" (parser:identifier-src-name (parser:type-definition-name parsed-type)) number-of-unused-variables - (mapcar (lambda (str) (subseq str 0 (- (length str) (1+ (position #\- (reverse str)))))) + (mapcar (lambda (str) (subseq str 0 (position #\- str :from-end t))) (mapcar #'string unused-variables))))))) (defun infer-define-type-scc-kinds (types env) @@ -467,7 +467,7 @@ name)) :aliased-type (let ((parser-aliased-type (parser:type-definition-aliased-type type))) - (when parser-aliased-type + (if parser-aliased-type (let ((aliased-type (parse-type parser-aliased-type env))) (check-for-unused-type-alias-type-variables aliased-type type env) aliased-type))) diff --git a/src/typechecker/types.lisp b/src/typechecker/types.lisp index 64a28557e..a52379ae0 100644 --- a/src/typechecker/types.lisp +++ b/src/typechecker/types.lisp @@ -75,6 +75,18 @@ ;;; (defstruct (ty (:constructor nil)) + ;; When this field is not null, it comprises a head which is the + ;; explicit type-alias used, and a tail which consists of the + ;; type-aliases used to define the explicit alias. + ;; for example: + ;; (define-type-alias T1 T) + ;; (define-type-alias T2 T1) + ;; (declare x T2) + ;; (define x ...) + ;; the type of x will be T, with the alias field + ;; populated with (Cons T2 (Cons T1 Nil)). + ;; + ;; Could be replaced by a weak hash table. (alias nil :type (or null ty-list) :read-only nil)) (defmethod make-load-form ((self ty) &optional env) @@ -233,8 +245,7 @@ (tgen-id type2))) (:method (type1 type2) - (declare (ignore type1) - (ignore type2)) + (declare (ignore type1 type2)) nil)) ;;;