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

deprecation warning is only printed once #22043

Closed
fredrikekre opened this issue May 23, 2017 · 6 comments
Closed

deprecation warning is only printed once #22043

fredrikekre opened this issue May 23, 2017 · 6 comments
Labels
deprecation This change introduces or involves a deprecation display and printing Aesthetics and correctness of printed representations of objects.

Comments

@fredrikekre
Copy link
Member

Ref #22034 (comment), on 0.6 and master I can only produce one deprecation warning per julia session.

master and 0.6-rc2:

julia> f2(x) = 2; f4(x) = 4;

julia> @deprecate f1(x) f2(x);

julia> @deprecate f3(x) f4(x);

julia> f1(1)
WARNING: f1(x) is deprecated, use f2(x) instead.
Stacktrace:
 [1] depwarn(::String, ::Symbol) at ./deprecated.jl:64
 [2] f1(::Int64) at ./deprecated.jl:51
 [3] eval(::Module, ::Any) at ./boot.jl:235
 [4] eval_user_input(::Any, ::Base.REPL.REPLBackend) at ./REPL.jl:66
 [5] macro expansion at ./REPL.jl:97 [inlined]
 [6] (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:73
while loading no file, in expression starting on line 0
2

julia> f3(1) # why does this not warn?
4

And on 0.5.2:

julia> f2(x) = 2; f4(x) = 4;

julia> @deprecate f1(x) f2(x);

julia> @deprecate f3(x) f4(x);

julia> f1(1)
WARNING: f1(x) is deprecated, use f2(x) instead.
 in depwarn(::String, ::Symbol) at ./deprecated.jl:64
 in f1(::Int64) at ./deprecated.jl:50
 in eval(::Module, ::Any) at ./boot.jl:234
 in eval_user_input(::Any, ::Base.REPL.REPLBackend) at ./REPL.jl:64
 in macro expansion at ./REPL.jl:95 [inlined]
 in (::Base.REPL.##3#4{Base.REPL.REPLBackend})() at ./event.jl:68
while loading no file, in expression starting on line 0
2

julia> f3(1)
WARNING: f3(x) is deprecated, use f4(x) instead.
 in depwarn(::String, ::Symbol) at ./deprecated.jl:64
 in f3(::Int64) at ./deprecated.jl:50
 in eval(::Module, ::Any) at ./boot.jl:234
 in eval_user_input(::Any, ::Base.REPL.REPLBackend) at ./REPL.jl:64
 in macro expansion at ./REPL.jl:95 [inlined]
 in (::Base.REPL.##3#4{Base.REPL.REPLBackend})() at ./event.jl:68
while loading no file, in expression starting on line 0
4

Seems like a bad bug in these days of new releases and fixing deprecation warnings.

@fredrikekre
Copy link
Member Author

Bisected to c8026a9 and also ref #21367 (comment) which I also experienced writing tests for #22034

@fredrikekre
Copy link
Member Author

Actually, its not just c8026a9, reverting that makes the warning print every time, so it has to be something else (perhaps a combination?). This is master with c8026a9 reverted:

julia> f2(x) = 2;

julia> @deprecate f1(x) f2(x);

julia> f1(1)
WARNING: f1(x) is deprecated, use f2(x) instead.
Stacktrace:
 [1] depwarn(::String, ::Symbol) at ./deprecated.jl:70
 [2] f1(::Int64) at ./deprecated.jl:57
 [3] eval(::Module, ::Any) at ./boot.jl:235
 [4] eval_user_input(::Any, ::Base.REPL.REPLBackend) at ./REPL.jl:66
 [5] macro expansion at ./REPL.jl:97 [inlined]
 [6] (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:73
while loading no file, in expression starting on line 0
2

julia> f1(1)
WARNING: f1(x) is deprecated, use f2(x) instead.
Stacktrace:
 [1] depwarn(::String, ::Symbol) at ./deprecated.jl:70
 [2] f1(::Int64) at ./deprecated.jl:57
 [3] eval(::Module, ::Any) at ./boot.jl:235
 [4] eval_user_input(::Any, ::Base.REPL.REPLBackend) at ./REPL.jl:66
 [5] macro expansion at ./REPL.jl:97 [inlined]
 [6] (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:73
while loading no file, in expression starting on line 0
2

@kshyatt kshyatt added the display and printing Aesthetics and correctness of printed representations of objects. label May 25, 2017
@fredrikekre
Copy link
Member Author

Perhaps this is only an issue in global scope. Example from top post, but calling f1 and f3 from a function, then it works as expected:

julia> f2(x) = 2; f4(x) = 4;

julia> @deprecate f1(x) f2(x);

julia> @deprecate f3(x) f4(x);

julia> function foo()
           f1(1)
           f3(1)
       end
foo (generic function with 1 method)

julia> foo()
WARNING: f1(x) is deprecated, use f2(x) instead.
Stacktrace:
 [1] depwarn(::String, ::Symbol) at ./deprecated.jl:70
 [2] f1(::Int64) at ./deprecated.jl:57
 [3] foo() at ./REPL[4]:2
 [4] eval(::Module, ::Any) at ./boot.jl:236
 [5] eval_user_input(::Any, ::Base.REPL.REPLBackend) at ./REPL.jl:66
 [6] macro expansion at ./REPL.jl:97 [inlined]
 [7] (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:73
while loading no file, in expression starting on line 0
WARNING: f3(x) is deprecated, use f4(x) instead.
Stacktrace:
 [1] depwarn(::String, ::Symbol) at ./deprecated.jl:70
 [2] f3(::Int64) at ./deprecated.jl:57
 [3] foo() at ./REPL[4]:3
 [4] eval(::Module, ::Any) at ./boot.jl:236
 [5] eval_user_input(::Any, ::Base.REPL.REPLBackend) at ./REPL.jl:66
 [6] macro expansion at ./REPL.jl:97 [inlined]
 [7] (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at ./event.jl:73
while loading no file, in expression starting on line 0
4

julia> foo()
4

@JeffBezanson JeffBezanson added the deprecation This change introduces or involves a deprecation label Jul 12, 2017
@JeffBezanson
Copy link
Sponsor Member

JeffBezanson commented Jul 12, 2017

This seems to be because a given line number of prompt input is always considered the "same location", and warnings are uniqued by the location of the deprecated call. If you do e.g.

julia> begin
       f3(1)
       end

you get a warning because the call is now on line 2 instead of line 1.

@c42f
Copy link
Member

c42f commented Nov 26, 2017

Just a heads-up that I've been changing the depwarn system a bit over at #24490, which should put the deduplication logic squarely in the hands of the user, rather than being locked away in a global Set.

As part of these changes, I've set the log record id (which should be used for a fast first round of deduplication) to the raw pointer to the caller which will fix the issue you've seen here, at the cost of some duplicates for naive depwarn filtering. I anticipate having a depwarn report which can produce a legible table of all depwarns encountered while running a piece of code. Something like:

report = depwarn_report() do
    # your code here
end

The new system allows this to produce identical results each time, as the deduplication is under control of the currently installed logger.

@c42f c42f mentioned this issue Dec 15, 2017
6 tasks
@fredrikekre
Copy link
Member Author

fixed by the logging pr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecation This change introduces or involves a deprecation display and printing Aesthetics and correctness of printed representations of objects.
Projects
None yet
Development

No branches or pull requests

4 participants