Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
YarinHeffes committed Nov 19, 2024
1 parent e6784b8 commit 8619ceb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/typechecker/define-type.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -324,16 +324,16 @@
(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)
(tc-error (format nil "Alias type variable~P defined but never used" number-of-unused-variables)
(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)
Expand Down Expand Up @@ -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)))
Expand Down
15 changes: 13 additions & 2 deletions src/typechecker/types.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -233,8 +245,7 @@
(tgen-id type2)))

(:method (type1 type2)
(declare (ignore type1)
(ignore type2))
(declare (ignore type1 type2))
nil))

;;;
Expand Down

0 comments on commit 8619ceb

Please sign in to comment.