Jameson,

If I understand your response correctly, the type warning on the first 
snippet can be safely ignored.  

Meanwhile, I misreported the type errors on the second snippet.  In fact, I 
made a mistake with my modules, and the second snippet was not loading the 
correct version of keytype and datatype.  After I fixed my error, both 
snippets reported exactly the same type error (on sitofp).  Sorry about 
that.  So the issue is resolved.

Thanks,
Steve Vavasis



On Saturday, July 18, 2015 at 8:46:46 PM UTC-4, Jameson wrote:
>
> Intrinsics.sitofp doesn't have a return type. It needs to be wrapped by a 
> call to Intrinsics.box to actually get a return type assigned. There are a 
> few places (such as sitofp) where the expr type doesn't matter, so type 
> inference doesn't bother marking them. Unfortunately, code_warntype doesn't 
> know that, so it highlights those places anyways.
>
>
> On Sat, Jul 18, 2015 at 8:39 PM <[email protected] <javascript:>> wrote:
>
>> I have developed a parameterized type called SortedDict, and a version of 
>> the code recently developed is generating type warnings; I can't figure out 
>> why.  The type SortedDict is parameterized by K (key type), D (data type) 
>> and Ord (ordering). Let s be of type SortedDict(ASCIIString, Float64, 
>> Forward).  
>>
>> The following snippet is generating a type warning when checked with 
>> @code_warntype setindex1(s, 5, "c")
>>
>> function setindex1{K, D, Ord <: Ordering}(m::SortedDict{K,D,Ord}, d_, k_)
>>     insert!(m.bt, convert(K,k_), convert(D,d_), false)
>> end
>>
>> on a call to Base.sitopf.  As far as I know, this is a new problem (i.e., 
>> did not exist in previous versions of 0.4)  Shouldn't the compiler know 
>> that the result of Base.sitopf is of type Float64?
>>
>>
>> Meanwhile, the following snippet, which I thought would be equivalent, is 
>> generating four type warning (according to @code_warntype setindex2(s, 5, 
>> "c"): one on each 'convert' invocation and one on the invocations of 
>> keytype and datatype each:
>>
>> @inline keytype{K,D,Ord <: Ordering}(m::SortedDict{K,D,Ord}) = K
>> @inline datatype{K,D,Ord <: Ordering}(m::SortedDict{K,D,Ord}) = D
>>
>> function setindex2(m::SortedDict, d_, k_)
>>     insert!(m.bt, convert(keytype(m),k_), convert(datatype(m),d_), false)
>> end
>>
>> This is in Julia 0.4, 6-day-old master.  Why is the type inferencing not 
>> working as I would have expected?
>>
>> Thanks,
>> Steve Vavasis
>>
>>

Reply via email to