diff --git a/src/module.c b/src/module.c index e59f46d5c2ffb..e2ee5e4f2ae7e 100644 --- a/src/module.c +++ b/src/module.c @@ -534,8 +534,11 @@ JL_DLLEXPORT void jl_deprecate_binding(jl_module_t *m, jl_sym_t *var, int flag) JL_DLLEXPORT int jl_is_binding_deprecated(jl_module_t *m, jl_sym_t *var) { - jl_binding_t *b = jl_get_binding(m, var); - return b && b->deprecated; + if (jl_binding_resolved_p(m, var)) { + jl_binding_t *b = jl_get_binding(m, var); + return b && b->deprecated; + } + return 0; } extern const char *jl_filename; diff --git a/test/reflection.jl b/test/reflection.jl index 2c525ea0fc9f3..76bdac6681167 100644 --- a/test/reflection.jl +++ b/test/reflection.jl @@ -809,3 +809,7 @@ f20872(::Val, ::Val) = false @test which(f20872, Tuple{Val,Val}).sig == Tuple{typeof(f20872), Val, Val} @test which(f20872, Tuple{Val,Val{N}} where N).sig == Tuple{typeof(f20872), Val, Val} @test_throws ErrorException which(f20872, Tuple{Any,Val{N}} where N) + +module M29962 end +# make sure checking if a binding is deprecated does not resolve it +@test !Base.isdeprecated(M29962, :sin) && !Base.isbindingresolved(M29962, :sin)