Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lots of warnings are nonsense #41

Open
baggepinnen opened this issue Dec 20, 2019 · 9 comments
Open

Lots of warnings are nonsense #41

baggepinnen opened this issue Dec 20, 2019 · 9 comments
Labels
bug Something isn't working

Comments

@baggepinnen
Copy link

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
@pfitzseb
Copy link
Member

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.

@baggepinnen
Copy link
Author

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.

@pfitzseb
Copy link
Member

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.

@PetrKryslUCSD
Copy link

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?

@pfitzseb
Copy link
Member

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

@pfitzseb pfitzseb added the bug Something isn't working label Feb 20, 2020
@JianghuiDu
Copy link

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.

@andrewKyres
Copy link

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

@pfitzseb
Copy link
Member

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

@ederag
Copy link
Contributor

ederag commented Mar 30, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants