[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-hackers] [PATCH] Disjoint return types with undefined (or *?) m
From: |
Peter Bex |
Subject: |
[Chicken-hackers] [PATCH] Disjoint return types with undefined (or *?) mess up "not" typechecks |
Date: |
Sun, 22 Apr 2012 19:22:19 +0200 |
User-agent: |
Mutt/1.4.2.3i |
Hi all,
While debugging the other scrutinizer issue with empty lists, I found
this one:
(define (some-proc x y) (if (string->number y) (set-cdr! x x) x))
(assert (null? (some-proc (list) "invalid number syntax")))
This fails, because there's an early return in simplify in simplify-type
in scrutinizer.scm which gets triggered whenever it encounters a
"undefined" type. This means that a type of '(or * undefined) gets
simplified to 'undefined, which means it matches the '(not null)
specialisation for null (this is implicit, since it's defined as
a predicate for the null type). Of course that's invalid as the
string->number check is false for Y = "invalid number syntax",
so SOME-PROC will simply return the X value it is passed, which
is null.
The attached patch is a big one, but it simply removes the early
returns; the rest is just due to the indentation change.
I wasn't 100% sure whether the early return on * is bad too, but
it seems safer to omit any early returns.
Cheers,
Peter
--
http://sjamaan.ath.cx
--
"The process of preparing programs for a digital computer
is especially attractive, not only because it can be economically
and scientifically rewarding, but also because it can be an aesthetic
experience much like composing poetry or music."
-- Donald Knuth
0001-Do-not-return-early-when-encountering-undefined-or-t.patch
Description: Text document
- [Chicken-hackers] [PATCH] Disjoint return types with undefined (or *?) mess up "not" typechecks,
Peter Bex <=