[racket] TR error message

From: Vincent St-Amour (stamourv at ccs.neu.edu)
Date: Thu Sep 23 13:48:01 EDT 2010

At Thu, 23 Sep 2010 13:32:42 -0400,
Matthias Felleisen wrote:
> You do want to see more than the general 
> case when you are trying to eliminate 
> casts from your numeric programs. I am 
> not sure showing just the general case 
> suffices. 

In the case of comparisons, since, if we ignore filters, all the
domains (Fixnum PositiveFixnum, Integer Natural, etc.) can be
generalized to Real Real *. Since the return type is the same
(Boolean) in all cases, only showing the general case does not cause
any loss of information.

In the case of + and others, since the return types of all the cases
are different (Integer Integer -> Integer, Float Float -> Float,
etc.), no case is more general (in a subtyping sense) than the others,
so they are not eliminated.

However, we do restrict the domains shown for errors related to +, but
in another way: we only show the domains for which the return type is
consistent with the expected type (the return type has to be a subtype
of the expected type). That means that you see the domains that would
give you a value of the required type: these are cases where you don't
need casts.

So right now, if you have the following code:
(+ 'a 'b)
with an expected type of Integer, the error only mentions the domains
for which the return type would be Integer, but it mentions all of
them, and it ignores the cases that would result in a Float, or a


Posted on the users mailing list.