Mark H Weaver writes: > calcium writes: >> Here is the bug that I found : >> >> ;;; -START- code with the bug -START- ;;; >> >> (define (strange lst) >> (let loop ((lst lst) >> (is-empty '())) >> (cond ((nil? lst) >> (if (nil? is-empty) 'works >> (list 'should-not-occur is-empty))) >> (else >> (loop (cdr lst) >> is-empty))))) >> >> (strange '()) >> => (should-not-occur ()) >> >> (strange #nil) >> => (should-not-occur ()) > > Indeed, this certainly indicates a bug. > > I believe the bug is in 'local-type-fold' in (language cps type-fold). > It contains a local procedure 'scalar-value' which, if I understand > correctly, seems to incorrectly assume that (nil? x) returns #t if and > only if X is 'eq?' to #nil. The bug actually wasn't in 'local-type-fold', but it's true that the type inferencer assumed in a few places that if (nil? X) returned #t that X must be #nil, and similarly for 'null?' and (). I've attached a proposed fix. Andy, does this fix look right to you? Thanks, Mark