Opened 7 years ago
Closed 7 years ago
#1533 closed defect (fixed)
Scrutinizer seems to get confused about list length
| Reported by: | sjamaan | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | 5.0 |
| Component: | scrutinizer | Version: | 5.0.0rc2 |
| Keywords: | flow analysis | Cc: | |
| Estimated difficulty: | hard |
Description
Seen when compiling awful-salmonella-tar:
(/usr/home/chicken/src/awful-salmonella-tar/ast-cache-manager.scm:86) in procedure call to `scheme#car', expected argument #1 of type `pair' but was given an argument of type `null'
Here's a stripped-down example that triggers it:
(module ast-cache-manager ()
(import scheme (chicken base) (chicken process-context))
(define (usage #!optional exit-code)
(when exit-code
(exit exit-code)))
(let ((args (command-line-arguments)))
(when (or (member "-h" args)
(member "-help" args)
(member "--help" args))
(usage 0))
(when (< (length args) 3)
(usage 1))
(let ((cache-dir (car args))
(awful-pid (string->number (cadr args)))
(max-items (and (not (null? (cddr args)))
(string->number (caddr args)))))
(assert awful-pid)))
) ;; end module
It seems that when you remove the when, the warning goes away.
Change History (2)
comment:1 Changed 7 years ago by
comment:2 Changed 7 years ago by
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Fixed with b7e293696efe4f1bfdfdcd8239c0b76de0dd615f
Note: See
TracTickets for help on using
tickets.

There's at least two things going on here.
First is type smashing. The calls to
usage, which has unknown typesmashes the type of
argsto(or pair null). This can be avoided bymoving the
usagecalls to tail call positions.In theory, defining
usagelike this should help:(define usage (the (#!optional fixnum -> noreturn) (lambda (#!optional exit-code) (when exit-code (exit exit-code)))))But doesn't, for some reason.
Secondly, there's an issue with refinement:
The type should stay
(or pair null), but is refined tonull.