fix arity check for applicable structs
authorAndy Wingo <wingo@pobox.com>
Mon, 21 May 2012 16:06:34 +0000 (18:06 +0200)
committerAndy Wingo <wingo@pobox.com>
Mon, 21 May 2012 16:06:34 +0000 (18:06 +0200)
* module/language/tree-il/analyze.scm (validate-arity): Fix for
  applicable structs.  Applicable structs are procedures, but not every
  struct has a first slot, and not every struct with a procedure in its
  first slot is applicable.  Besides, the approach in this patch gives
  better errors.

module/language/tree-il/analyze.scm

index c3ff9e2..88f81f3 100644 (file)
@@ -1008,10 +1008,14 @@ accurate information is missing from a given `tree-il' element."
                                 (arity:allow-other-keys? a)))
                         (program-arities proc))))
           ((procedure? proc)
-           (let ((arity (procedure-minimum-arity proc)))
-             (values (procedure-name proc)
-                     (list (list (car arity) (cadr arity) (caddr arity)
-                                 #f #f)))))
+           (if (struct? proc)
+               ;; An applicable struct.
+               (arities (struct-ref proc 0))
+               ;; An applicable smob.
+               (let ((arity (procedure-minimum-arity proc)))
+                 (values (procedure-name proc)
+                         (list (list (car arity) (cadr arity) (caddr arity)
+                                     #f #f))))))
           (else
            (let loop ((name    #f)
                       (proc    proc)
@@ -1196,11 +1200,6 @@ accurate information is missing from a given `tree-il' element."
                       proc)))
             (cond ((lambda? proc*)
                    (validate-arity proc* application #t))
-                  ((struct? proc*)
-                   ;; An applicable struct.
-                   (let ((p (struct-ref proc* 0)))
-                     (and (procedure? p)
-                          (validate-arity p application #f))))
                   ((procedure? proc*)
                    (validate-arity proc* application #f)))))
         toplevel-calls)))