Traceur.jl icon indicating copy to clipboard operation
Traceur.jl copied to clipboard

Lots of warnings are nonsense

Open baggepinnen opened this issue 4 years ago • 9 comments

I do not understand the following warnings, the variable names seems to be left out and is it really a problem if something is assigned as Nothing or a Tuple?

┌ Warning:  is assigned as Tuple{Int64,Int64}
└ @ broadcast.jl:-1
┌ Warning:  is assigned as Nothing
└ @ broadcast.jl:-1
┌ Warning:  is assigne

baggepinnen avatar Dec 20 '19 03:12 baggepinnen

IIRC this warning tries to figure out when a binding changes type, so e.g. was a Tuple{int64,Int64} but then got assigned nothing. In your particular case the warning seems kinda broken since we can't find a variable name though.

pfitzseb avatar Dec 20 '19 08:12 pfitzseb

Okay that makes sense to warn about. Even if the variable name was displayed, I might not have understood that it was the fact that the type changed that was warned about. Maybe a better message is

 Warning:  is changed to Nothing

or something like that.

Also, if I'm not mistaken, the compiler is much better at optimizing for code where varibales change type nowadays, as long as it is visible at compile time.

baggepinnen avatar Dec 20 '19 08:12 baggepinnen

Maybe a better message is Warning: is changed to Nothing or something like that.

Agreed.

Also, if I'm not mistaken, the compiler is much better at optimizing for code where varibales change type nowadays, as long as it is visible at compile time.

True. It's also much better about small unions (Union{Float64, Nothing}), but I think we still warn about that. Checking that the compiler is actually optimizing everything as expected is a lot harder than "just" pattern matching the inferred code.

pfitzseb avatar Dec 20 '19 08:12 pfitzseb

I also ran into this. The weird thing is not only the missing variable name, but also the lines in the code are identified only with "-1". So do we now know that this is in fact a bug?

PetrKryslUCSD avatar Feb 20 '20 19:02 PetrKryslUCSD

It's not always trivial to find the correct line info, but yes, probably a bug.

pfitzseb avatar Feb 20 '20 21:02 pfitzseb

I have similar things

julia> @trace reactran_fvcf(dC0,C_uni,false,1)
┌ Warning: dynamic dispatch to (Core.apply_type(Base.Val, x))()
└ @ essentials.jl:696
┌ Warning:  is assigned as Tuple{Int64,Int64}
└ @ D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\LinearAlgebra\src\bidiag.jl:539
┌ Warning:  is assigned as Nothing
└ @ D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\LinearAlgebra\src\bidiag.jl:546
┌ Warning:  is assigned as Union{Nothing, Tuple{Int64,Int64}}
└ @ D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\LinearAlgebra\src\bidiag.jl:542
┌ Warning:  is assigned as Union{Nothing, Tuple{Int64,Int64}}
└ @ D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\LinearAlgebra\src\bidiag.jl:544
┌ Warning: dynamic dispatch to LinearAlgebra.A_mul_B_td!(C, A, B, φ (%5 => %4, %7 => %6, %11 => %10, %13 => %12))
└ @ D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.5\LinearAlgebra\src\bidiag.jl:391
┌ Warning: getindex returns Union{SubArray{Float64,1,Array{Float64,1},Tuple{StepRange{Int64,Int64}},true}, Array{Float64,1}}
└ @ tuple.jl:24
┌ Warning: getindex returns Union{Base.Broadcast.Extruded{SubArray{Float64,1,Array{Float64,1},Tuple{StepRange{Int64,Int64}},true},Tuple{Bool},Tuple{Int64}}, Base.Broadcast.Extruded{Array{Float64,1},Tuple{Bool},Tuple{Int64}}}
└ @ tuple.jl:24
┌ Warning:  is assigned as Tuple{Int64,Int64}
└ @ broadcast.jl:70
┌ Warning:  is assigned as Nothing
└ @ broadcast.jl:79
┌ Warning: getindex returns Union{SubArray{Float64,1,Array{Float64,1},Tuple{StepRange{Int64,Int64}},true}, Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1},Nothing,typeof(*),Tuple{Array{Float64,1},Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1},Nothing,typeof(-),Tuple{Float64,SubArray{Float64,1,Array{Float64,1},Tuple{StepRange{Int64,Int64}},true}}}}}}
└ @ tuple.jl:24
┌ Warning: getindex returns Union{Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1},Nothing,typeof(-),Tuple{Float64,SubArray{Float64,1,Array{Float64,1},Tuple{StepRange{Int64,Int64}},true}}}, Array{Float64,1}}
└ @ tuple.jl:24
┌ Warning: getindex returns Union{Float64, SubArray{Float64,1,Array{Float64,1},Tuple{StepRange{Int64,Int64}},true}}
└ @ tuple.jl:24

What I don't understand is how do we where are they referring to in my code? It only returns the line numbers of the package codes.

JianghuiDu avatar Oct 16 '20 20:10 JianghuiDu

It looks to me like it's analyzing code in packages? I only want to analyze the code I've written. Is there any way to do this?

┌ Warning: dynamic dispatch to Base.BoundsError(Base.getfield(_2, itr), Base.getfield(π (%5, Tuple{Char, Int64}), 2)) └ @ iterators.jl:216 ┌ Warning: dynamic dispatch to Base.Iterators.EOFError() └ @ iterators.jl:1290 ┌ Warning: dynamic dispatch to Base.BoundsError(Base.getfield(_2, itr), Base.getfield(π (%6, Tuple{Char, Int64}), 2)) └ @ iterators.jl:216 ┌ Warning: is assigned as Tuple{Char, Int64} └ @ operators.jl:1132 ┌ Warning: is assigned as Union{Nothing, Tuple{Char, Int64}} └ @ operators.jl:1137 ┌ Warning: is assigned as Union{Nothing, Tuple{Char, Nothing}} └ @ strings/io.jl:336 ┌ Warning: is assigned as Union{Nothing, Tuple{Char, Nothing}} └ @ strings/io.jl:355 ┌ Warning: dynamic dispatch to Base.BoundsError(_3, 1) └ @ strings/io.jl:216 ┌ Warning: dynamic dispatch to Base.Iterators.EOFError() └ @ strings/io.jl:1290 ┌ Warning: dynamic dispatch to Base.BoundsError(_3, Base.getfield(π (%66, Tuple{Char, Int64}), 2)) └ @ strings/io.jl:216 ┌ Warning: dynamic dispatch to Base.BoundsError("abtnvfr", Base.sub_int(Core.zext_int(Core.Int64, $(Expr(:invoke, MethodInstance for UInt32(::Char), :(Base.UInt32), :(φ (%148 => %143, %907 => %903))))), 6)) └ @ strings/io.jl:216 ┌ Warning: dynamic dispatch to Base.Iterators.EOFError() └ @ strings/io.jl:1290 ┌ Warning: dynamic dispatch to Base.BoundsError(_3, Base.getfield(π (%150, Tuple{Char, Int64}), 2)) └ @ strings/io.jl:216 ┌ Warning: dynamic dispatch to Base.repr(_9) └ @ iostream.jl:216 ┌ Warning: dynamic dispatch to Base.string("embedded NULs are not allowed in C strings: ", Base.repr(_9)) └ @ iostream.jl:216 ┌ Warning: dynamic dispatch to Base.ArgumentError(Base.string("embedded NULs are not allowed in C strings: ", Base.repr(_9))) └ @ iostream.jl:216

andrewKyres avatar Mar 21 '21 15:03 andrewKyres

You can specify the modules kwarg to get only warnings in the specified modules (as per the docstring).

pfitzseb avatar Mar 22 '21 10:03 pfitzseb

Minimum working example:

julia> using Traceur
julia> f(x) = [x]
julia> @trace f(0)
┌ Warning:  is assigned as Tuple{Int64, Int64}
└ @ array.jl:108
┌ Warning:  is assigned as Nothing
└ @ array.jl:108
1-element Vector{Int64}:
 0

With julia v1.6.0, Traceur v0.3.1

https://github.com/JuliaLang/julia/blob/06e7ee6ce8277035cc4ae6d0a365698f2f5bb347/base/array.jl#L108

It seems related to the for loop

julia> function f3()
           for i = 1:2
           end
       end

julia> @trace f3()
┌ Warning:  is assigned as Tuple{Int64, Int64}
└ @ REPL[8]:2
┌ Warning:  is assigned as Union{Nothing, Tuple{Int64, Int64}}
└ @ REPL[8]:3

ederag avatar Mar 30 '21 10:03 ederag