Oct 9, 2009, 2:46:02 PM (10 years ago)

From working-0711 branch: more extensive compile-time checking involving methods/gfs: warn about incongruent lambda lists, duplicate gf defs, required keyword args (from defgeneric), and invalid keyword args in gf calls. Also fix to keep method source files in env function info so dup method warnings can cite the right file.

1 edited


  • trunk/source/compiler/nx-basic.lisp

    r12861 r12940  
    584584    (setq env (lexenv.parent-env env))))
    586 (defun report-compile-time-argument-mismatch (condition stream)
     586(defun report-compile-time-argument-mismatch (condition stream &aux (type (compiler-warning-warning-type condition)))
    587587  (destructuring-bind (callee reason args spread-p)
    588588      (compiler-warning-args condition)
    591591            callee
    592592            args)
    593     (case (car reason)
     593    (ecase (car reason)
    594594      (:toomany
    595595       (destructuring-bind (provided max)
    606606       (destructuring-bind (badguy goodguys)
    607607           (cdr reason)
    608          (format stream "the keyword argument~:[ ~s is~;s~{ ~s~^~#[~; and~:;,~]~} are~] not one of ~s, which are recognized~&  by "
    609                  (consp badguy) badguy goodguys))))
     608         (format stream "the keyword argument~:[ ~s is~;s~{ ~s~^~#[~; and~:;,~]~} are~] not one of ~:s, which are recognized by "
     609                 (consp badguy) badguy goodguys)))
     610      (:unknown-gf-keywords
     611         (let ((badguys (cadr reason)))
     612           (when (and (consp badguys) (null (%cdr badguys))) (setq badguys (car badguys)))
     613           (format stream "the keyword argument~:[ ~s is~;s~{ ~s~^~#[~; and~:;,~]~} are~] not recognized by "
     615                   (consp badguys) badguys))))
    610616    (format stream
    611             (ecase (compiler-warning-warning-type condition)       
     617            (ecase type
    612618              (:ftype-mismatch "the FTYPE declaration of ~s")
    613619              (:global-mismatch "the current global definition of ~s")
    614620              (:environment-mismatch "the definition of ~s visible in the current compilation unit.")
    615               (:lexical-mismatch "the lexically visible definition of ~s"))
     621              (:lexical-mismatch "the lexically visible definition of ~s")
     622              ;; This can happen when compiling without compilation unit:
     623              (:deferred-mismatch "~s"))
    616624            callee)))
    620628    (:unused . "Unused lexical variable ~S")
    621629    (:ignore . "Variable ~S not ignored.")
    622     (:undefined-function . "Undefined function ~S") ;; (not reported if defined later)
    623     (:undefined-type . "Undefined type ~S")         ;; (not reported if defined later)
     630    (:undefined-function . "Undefined function ~S") ;; (deferred)
     631    (:undefined-type . "Undefined type ~S")         ;; (deferred)
    624632    (:unknown-type-in-declaration . "Unknown or invalid type ~S, declaration ignored")
    625633    (:bad-declaration . "Unknown or invalid declaration ~S")
    633641    (:lexical-mismatch . report-compile-time-argument-mismatch)   
    634642    (:ftype-mismatch . report-compile-time-argument-mismatch)
     643    (:deferred-mismatch . report-compile-time-argument-mismatch)
    635644    (:type . "Type declarations violated in ~S")
    636645    (:type-conflict . "Conflicting type declarations for ~S")
    637646    (:special-fbinding . "Attempt to bind compiler special name: ~s. Result undefined.")
    638647    (:lambda . "Suspicious lambda-list: ~s")
     648    (:incongruent-gf-lambda-list . "Lambda list of generic function ~s is incongruent with previously defined methods")
     649    (:incongruent-method-lambda-list . "Lambda list of ~s is incongruent with previous definition of ~s")
     650    (:gf-keys-not-accepted . "~s does not accept keywords ~s required by the generic functions")
    639651    (:result-ignored . "Function result ignored in call to ~s")
    640652    (:duplicate-definition . report-compile-time-duplicate-definition)
Note: See TracChangeset for help on using the changeset viewer.