From 987d42fe6978f9c9fc9df0ac8584c2cd0926e7e9 Mon Sep 17 00:00:00 2001 From: Isaiah Norton Date: Mon, 5 Oct 2015 21:39:22 -0400 Subject: [PATCH] Show file:line with binding deprecation warning --- src/module.c | 7 +++++++ test/cmdlineargs.jl | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/module.c b/src/module.c index 3520de1015d9f..44bff90e5a3c2 100644 --- a/src/module.c +++ b/src/module.c @@ -479,6 +479,9 @@ DLLEXPORT int jl_is_binding_deprecated(jl_module_t *m, jl_sym_t *var) return b && b->deprecated; } +extern const char *jl_filename; +extern int jl_lineno; + void jl_binding_deprecation_warning(jl_binding_t *b) { if (b->deprecated && jl_options.depwarn) { @@ -503,6 +506,10 @@ void jl_binding_deprecation_warning(jl_binding_t *b) jl_printf(JL_STDERR, " instead"); } jl_printf(JL_STDERR, ".\n"); + + if (jl_options.depwarn != JL_OPTIONS_DEPWARN_ERROR) + jl_printf(JL_STDERR, " likely near %s:%d\n", jl_filename, jl_lineno); + if (jl_options.depwarn == JL_OPTIONS_DEPWARN_ERROR) { if (b->owner) jl_errorf("deprecated binding: %s.%s", b->owner->name->name, b->name->name); diff --git a/test/cmdlineargs.jl b/test/cmdlineargs.jl index 2ed49d782c316..9a8e9396aed1a 100644 --- a/test/cmdlineargs.jl +++ b/test/cmdlineargs.jl @@ -173,7 +173,7 @@ let exename = `$(joinpath(JULIA_HOME, Base.julia_exename())) --precompiled=yes` wait(proc) close(out.in) @test success(proc) - @test readchomp(out) == "WARNING: Foo.Deprecated is deprecated." + @test readchomp(out) == "WARNING: Foo.Deprecated is deprecated.\n likely near no file:5" end @unix_only let out = Pipe(),