This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
"cannot convert literal" warning
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
--- /dev/null Tue Oct 7 04:48:06 2003
+++ pair.scm Mon Jan 31 15:03:14 2005
@@ -0,0 +1,14 @@
+(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)))