Ignore:
Timestamp:
May 13, 2009, 5:52:49 PM (10 years ago)
Author:
gz
Message:

Extend the mechanism used to warn about undefined and duplicate functions in a
compilation unit to do the same for types, use it for types defined by
deftype/defstruct/defclass.

Also make proclaim-type err on invalid types and warn about undefined ones.

Tighten up assorted type/ftype declaration checking. This in turn unleashed
a bunch of test suite tests requiring errors on conflicts between DECLARATION
declarations and types, so I put in checks for those as well.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/level-1/l1-utils.lisp

    r11373 r12045  
    537537    ;(function (proclaim-ftype (cons 'function (cddr spec)) (cadr spec)))
    538538    (t (unless (memq (%car spec) *nx-known-declarations*) ;not really right...
    539          ;; Any type name is now (ANSI CL) a valid declaration.
    540          (if (and (symbolp (%car spec))
    541                   (type-specifier-p (%car spec)))
     539         ;; Any type name is now (ANSI CL) a valid declaration.  Any symbol could become a type.
     540         (if (symbolp (%car spec))
    542541           (apply #'proclaim-type spec)
    543542           (warn "Unknown declaration specifier(s) in ~S" spec))))))
     
    548547    (if (symbolp var)
    549548      (let ((spec (assq var *nx-proclaimed-types*)))
     549        ;; Check the type.  This will signal program-error's in case of invalid types, let it.
     550        (when *type-system-initialized*
     551          (handler-case (specifier-type type)
     552            (parse-unknown-type (c)
     553              (warn "Undefined type ~s declaration for ~S" (parse-unknown-type-specifier c) var))))
    550554        (if spec
    551555          (rplacd spec type)
     
    594598  (declare (dynamic-extent syms))
    595599  (dolist (sym syms)
     600    (when (type-specifier-p sym)
     601      (error "Cannot define declaration ~s because it is the name of a type" sym))
    596602    (setq *nx-known-declarations*
    597603          (adjoin sym *nx-known-declarations* :test 'eq))))
     604
     605(defun check-declaration-redefinition (name why)
     606  (when (memq name *nx-known-declarations*)
     607    (cerror "Undeclare the declaration ~*~s"
     608            "Cannot ~a ~s because ~:*~s has been declared as a declaration name" why name)
     609    (setq *nx-known-declarations* (remove name *nx-known-declarations*))))
    598610
    599611(defun proclaim-ignore (t-or-nil &rest syms)
Note: See TracChangeset for help on using the changeset viewer.