This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: case-expression in function position causes error


Jim White wrote:

Per Bothner wrote:

Sven Hartrumpf wrote:

A case-expression in a function position causes errors like this:

kawa ; current CVS version


#|kawa:1|# (load "kawabug3.scm")
kawabug3.scm:2:4: warning - cannot convert literal (of type gnu.mapping.Values) to gnu.mapping.Procedure
#|kawa:2|#


The warning is correct, if confusing, because
you have no else clause.

I changed the error message in this case to the following.
Would that make it easier to understand the message?

kawabig3.scm:2:10: warning - cannot convert void to gnu.mapping.Procedure


For those still wondering what this means:

1) Since a case without an else-clause has an undefined value, Kawa compiles it as void.

2) Kawa sees the void as incompatible with Procedure because the case's value is the procedure in the expression, and so gives a warning.

3) As long as the case does match and so doesn't return void, the code works as expected.

4) If you want to get rid of the warning, supply an else-clause whose value is a Procedure, just like the other clauses.

All correct.


It is possible that Kawa is getting confused by this case,
and generating bad code.  However, that has not been confirmed.

It probably would not be difficult to improve the error
message, but locally what Kawa has available just that
void is being converted to a context that expects a
Procedure, which can happen in other rare cases.

We could also completely suppress the warning, and just
silently generate code to throw an exception.  However,
I think keeping the warning in there is best.
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]