chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] scrutiny


From: felix winkelmann
Subject: [Chicken-users] scrutiny
Date: Fri, 29 May 2009 16:18:55 +0200

Hello!


I have merged the recent work on the "scrutiny" branch into trunk (r14828).
"Scrutiny" is a lightweight local conservative (read: simple) flow analysis
pass over the internal representation of the code and performs a check on
argument-count/-types and results of calls to core library procedures.
Additionally, the number of result values is checked in various places.
Local variable bindings are taken into account and an attempt has been
made to provide useful error messages (which has only partially
succeeded).

When I write something from scratch, I usually go through a phase
of fixing typos and trivial errors (forgetting an pass an argument, etc.),
and to help out with this tedious work, the scrutiny feature was implemented.
Note that this is not an optimization, it is just for checking code correctness.

Running the scrutinizer on the core libraries and compiler has already
found two bugs:

Index: eval.scm
===================================================================
--- eval.scm    (revision 14524)
+++ eval.scm    (revision 14525)
@@ -1311,7 +1311,7 @@
           ((symbol? x) (##sys#slot x 1))
           ((number? x) (##sys#number->string x))
           (else (error "invalid extension version" x)) ) )
-   (if (and (list spec) (fx= 3 (length spec)))
+   (if (and (list? spec) (fx= 3 (length spec)))
        (let* ((info (extension-information (cadr spec)))
              (vv (and info (assq 'version info))) )
         (unless (and vv (string>=? (->string (car vv)) (->string (caddr 
spec))))

% Index: optimizer.scm
===================================================================
--- optimizer.scm       (revision 14527)
+++ optimizer.scm       (revision 14528)
@@ -299,7 +299,7 @@
                                        ((eq? '##core#variable (node-class k)))
                                        (kvar (first (node-parameters k)))
                                        (lval (and (not (test kvar 'unknown)) 
(test kvar 'value)))
-                                       (eq? '##core#lambda (node-class lval))
+                                       ((eq? '##core#lambda (node-class lval)))
                                        (llist (third (node-parameters lval)))
                                        ((or (test (car llist) 'unused)
                                             (and (not (test (car llist) 
'references))

It is likely that the type-database still contains some bugs, so if you
try it out and get strange warnings, please mail them to me.

Usage is simple: just pass "-scrutinize" (or "-S" in csc).


cheers,
felix




reply via email to

[Prev in Thread] Current Thread [Next in Thread]