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

redirect_stderr does not redirect method overwritten warnings #56667

Open
LilithHafner opened this issue Nov 24, 2024 · 2 comments
Open

redirect_stderr does not redirect method overwritten warnings #56667

LilithHafner opened this issue Nov 24, 2024 · 2 comments
Labels
bug Indicates an unexpected problem or unintended behavior error messages Better, more actionable error messages

Comments

@LilithHafner
Copy link
Member

$julia -q --warn-overwrite=yes
julia> f() = 1
f (generic function with 1 method)

julia> g() = @eval f() = 1
g (generic function with 1 method)

julia> g()
WARNING: Method definition f() in module Main at REPL[1]:1 overwritten at REPL[2]:1.
f (generic function with 1 method)

julia> redirect_stderr(g, devnull)
WARNING: Method definition f() in module Main at REPL[2]:1 overwritten on the same line (check for duplicate calls to `include`).
f (generic function with 1 method)
@LilithHafner LilithHafner added bug Indicates an unexpected problem or unintended behavior error messages Better, more actionable error messages labels Nov 24, 2024
@LilithHafner
Copy link
Member Author

LilithHafner commented Nov 24, 2024

A workaround for suppressing these warnings is

julia> x = Base.JLOptions().warn_overwrite
0x01

julia> unsafe_store!(reinterpret(Ptr{UInt8}, cglobal(:jl_options, Base.JLOptions)), 0x00, fieldoffset(Base.JLOptions, findfirst(==(:warn_overwrite), fieldnames(Base.JLOptions)))+1)
Ptr{UInt8} @0x0000fffec7b91ea8

julia> g()

julia> unsafe_store!(reinterpret(Ptr{UInt8}, cglobal(:jl_options, Base.JLOptions)), x, fieldoffset(Base.JLOptions, findfirst(==(:warn_overwrite), fieldnames(Base.JLOptions)))+1)
Ptr{UInt8} @0x0000fffec7b91ea8

julia> g()
WARNING: Method definition f() in module Main at REPL[27]:1 overwritten on the same line (check for duplicate calls to `include`).

@IanButterworth
Copy link
Member

I tried to fix this here #55958

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 error messages Better, more actionable error messages
Projects
None yet
Development

No branches or pull requests

2 participants