Skip to content

Commit

Permalink
Show file:line with binding deprecation warning
Browse files Browse the repository at this point in the history
  • Loading branch information
ihnorton committed Oct 6, 2015
1 parent 19563a3 commit 987d42f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/cmdlineargs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit 987d42f

Please sign in to comment.