On the other hand, it works ok for the mean function:

r = rand(10)
test(r) = mean( t^2 for t in r )
@code_warntype test(r)   # return type Float64 is inferred

On Thursday, September 22, 2016 at 7:21:36 PM UTC+1, Christoph Ortner wrote:
>
> I hope that there is something I am missing, or making a mistake in the 
> following example: 
>
> r = rand(10)
> test1(r) = sum( t^2 for t in r )
> test2(r)= sum( [t^2 for t in r] )
> @code_warntype test1(r)   # return type Any is inferred
> @code_warntype test2(r)   # return type Float64 is inferred
>
>
> This caused a problem for me, beyond execution speed: I used a generator 
> to create the elements for a comprehension, since the type was not inferred 
> the zero-element could not be created.
>
> Is this a known issue?
>

Reply via email to