From: Daniel Dickison <danieldickison@cm...>  20051117 18:29:57

Hi  I'm new to this list  I hope this isn't redundant (it's not, as far as I can tell from searching the archive). > I was playing with the code from Luis G. Lopez's recent "Beautiful > Patterns" post on c.l.l, and I found what I think is a bug with type > inferencing. The following bit of code refuses to compile on version > 0.9.4 and 0.9.5.32 (according to a1k0n on #lisp): > > ( y (* (signum x) (sqrt (abs ( (* b x) c))))) > > The above throws the following: > > 0.0 can't be converted to type NIL. > [Condition of type SIMPLETYPEERROR] > > This version does compile: > > ( y (* (the real (signum x)) (sqrt (abs ( (* b x) c))))) > > Other types that seem to work are "fixnum" "singlefloat" but not > "number" Here are some more details on this bug. The error only seems to happen if you try to do an arithmetic operation the results of (abs ...) with a float, but ONLY if a) the argument to abs is an integer referenced by a dynamic variable or a function parameter, and b) the result of (abs ...) is stored in a lexical variable. The following work fine: (* 2.0 (abs 2)) (let ((x (abs 2))) (* 2.0 x)) (defvar y 2) (defvar x (abs y)) (* 2.0 x)) ... But the following do not work (gets the error referred to above): (defvar y 2) (let ((x (abs y))) (* 2.0 x)) (defun foo (y) (let ((x (abs y))) (* 2.0 x))) Hope this helps. Daniel 