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

Depwarns at global scope have incorrect caller #25130

Closed
nalimilan opened this issue Dec 16, 2017 · 6 comments
Closed

Depwarns at global scope have incorrect caller #25130

nalimilan opened this issue Dec 16, 2017 · 6 comments
Labels
bug Indicates an unexpected problem or unintended behavior display and printing Aesthetics and correctness of printed representations of objects.

Comments

@nalimilan
Copy link
Member

This will make it quite hard to identify where deprecations come from:

julia> Array(Int, 1)
W- `Array(::Type{T}, m::Int) where T` is deprecated, use `Array{T}(uninitialized, m)` instead. -Warn:Core:julia_internal.h:380
|  caller = jl_call_fptr_internal at julia_internal.h:380 [inlined]
1-element Array{Int64,1}:
 139639004667120
@ararslan ararslan added bug Indicates an unexpected problem or unintended behavior display and printing Aesthetics and correctness of printed representations of objects. labels Dec 16, 2017
@c42f
Copy link
Member

c42f commented Dec 16, 2017

I think this is more a stack sanitization issue for stack frames coming from the REPL.

In normal functions, caller should point to the offending calling frame rather than the whole stack trace. I thought this would be much more precise and useful than spamming the user with the whole stack trace:

julia> foo() = Array(Int,1)
foo (generic function with 2 methods)

julia> foo()
W- `Array(::Type{T}, m::Int) where T` is deprecated, use `Array{T}(uninitialized, m)` instead. -Warn:Main:REPL[2]:1
|  caller = foo() at REPL[2]:1
1-element Array{Int64,1}:
 -1

@c42f c42f mentioned this issue Dec 16, 2017
15 tasks
@c42f
Copy link
Member

c42f commented Dec 16, 2017

An alternative to simply attaching caller would be to attach the whole backtrace, but somehow have a way to highlight the offending frame.

As a bit of extra context for what I've been thinking here for future functionality - the caller is attached partly to make a "depwarn report" possible: the idea is that you can run a big chunk of code, collect all the depwarn log events, put them into a table and filter/group/sort them by the source location which needs to change in order to silence the depwarns. Combined with source rewriting via Deprecations.jl, it should even be possible to automatically rewrite the source for a good class of deprecations.

@nalimilan
Copy link
Member Author

Maybe we just need a special case for calls done in the global scope?

@c42f
Copy link
Member

c42f commented Dec 17, 2017

Oh, I see - this issue is worse than I thought as it applies to all code at global scope, not just the REPL.

Would you mind changing the title to something like "Depwarns at global scope have incorrect caller"

I'm sure this can be fixed. Possibly with a special case but I'll need to dig.

@vchuravy vchuravy changed the title Deprecations no longer print full stack trace with new logging framework Depwarns at global scope have incorrect caller Dec 17, 2017
@stevengj
Copy link
Member

stevengj commented Dec 18, 2017

It's not just global scope(?):

julia> f() = warn("foo")
f (generic function with 1 method)

julia> f()
W- `warn()` is deprecated, use `@warn` instead. -Warn:Core:julia_internal.h:380
|  caller = jl_call_fptr_internal at julia_internal.h:380 [inlined]
WARNING: foo

@c42f
Copy link
Member

c42f commented Dec 18, 2017

Yep, this is serious. I think I have a simple fix, just figuring out how to test it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior display and printing Aesthetics and correctness of printed representations of objects.
Projects
None yet
Development

No branches or pull requests

4 participants