"cannot convert literal" warning

Dean Ferreyra dferreyra@igc.org
Tue Feb 1 05:09:00 GMT 2005


Hello,

With the latest Kawa CVS sources I'm getting some new warnings when 
compiling our code that I wasn't getting before.  Now that I've narrowed 
it down to a small example, I'm not sure what to make of it.  Here's the 
example (the same is attached):

   (define-syntax gen-list
     (syntax-rules ()
       ((_ flag)
        (if flag '(1) '()))))

   (define (fn-warns flag)
     (car (gen-list flag)))

   (define (fn-okay flag)
     (let ((lst (gen-list flag)))
       (car lst)))

   (define (fn-okay2)
     (car (gen-list #t)))

Here's the warning from the line in FN-WARNS:

   % java kawa.repl --main -C pair.scm
   (compiling pair.scm)
   pair.scm:7:8: warning - cannot convert literal (of type 
gnu.lists.LList) to gnu.lists.Pair
   %

The warning, I think, is centered around the fact that the macro might 
return the empty list.  On the one hand, the warning could be saving us 
from taking the CAR of the empty list.  On the other hand, in the places 
in our source where we do something like this, the arguments to the 
macro are checked before hand so that the macro will never evaluate to 
the empty list and the warnings do not help us.

I'm thinking that maybe we should not be getting the warning.  For 
example, I don't expect to get a warning for this, even though FIND-TAIL 
might evaluate to #f:

   (define (fn lst)
     (car (find-tail even? lst)))

What's the right thing here?  Any thoughts?

Dean Ferreyra
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: example.diff
URL: <http://sourceware.org/pipermail/kawa/attachments/20050201/ee228767/attachment.ksh>


More information about the Kawa mailing list