-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
print_backdate_admonition
may need a backtrace
#57969
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
Comments
How strict do we want to be? We could do this: diff --git a/src/module.c b/src/module.c
index 7d77e933f81..a54384967aa 100644
--- a/src/module.c
+++ b/src/module.c
@@ -773,6 +773,8 @@ JL_DLLEXPORT jl_module_t *jl_get_module_of_binding(jl_module_t *m, jl_sym_t *var
static NOINLINE void print_backdate_admonition(jl_binding_t *b) JL_NOTSAFEPOINT
{
+ if (jl_options.depwarn == JL_OPTIONS_DEPWARN_ERROR)
+ jl_undefined_var_error(b->globalref->name, (jl_value_t*)b->globalref->mod);
jl_safe_printf(
"WARNING: Detected access to binding `%s.%s` in a world prior to its definition world.\n"
" Julia 1.12 has introduced more strict world age semantics for global bindings.\n"
diff --git a/base/errorshow.jl b/base/errorshow.jl
index c53c605cbfb..b1b7a083eb0 100644
--- a/base/errorshow.jl
+++ b/base/errorshow.jl
@@ -1163,6 +1163,8 @@ function UndefVarError_hint(io::IO, ex::UndefVarError)
print(io, "\nSuggestion: check for spelling errors or missing imports.")
elseif Base.is_some_explicit_imported(kind)
print(io, "\nSuggestion: this global was defined as `$(Base.partition_restriction(bpart).globalref)` but not assigned a value.")
+ elseif kind === Base.PARTITION_KIND_BACKDATED_CONST
+ print(io, "\nSuggestion: this const was attempted to be used before it was defined (new Julia v1.12 rule).")
end
elseif scope === :static_parameter
print(io, "\nSuggestion: run Test.detect_unbound_args to detect method arguments that do not fully constrain a type parameter.") resulting in:
|
I like it. The only minor weakness I see with this proposal is that you can't get lineinfo unless you make it an error, so it's not possible to use it like Possible alternate phrasing: "Suggestion: define the constant before running code that uses it (stricter Julia v1.12+ rule)." |
It looks like the hint code is also not currently supporting binding ages like method printing does (to alert you if there is a binding in a different world with different values) which is likely a separate issue with the resulting hint text |
I marked for triage/needs decision, since I want folks to be on-board with making this controlled by the existing depwarn error flag before we commit to doing that |
I do think the UndefVarError one is reasonable, because that's closest to the behavior you'll get after we remove the deprecation. |
This is close to the expected behavior after deprecations are removed (other than that the b->globalref->mod in the printed message here will be the source module instead of the destination module, which may sometimes cause confusing printing here, but probably rarely). Closes #57969
Wording updated based upon timholy's suggestion in #57969.
This is close to the expected behavior after deprecations are removed (other than that the b->globalref->mod in the printed message here will be the source module instead of the destination module, which may sometimes cause confusing printing here, but probably rarely). Closes #57969
This is close to the expected behavior after deprecations are removed (other than that the b->globalref->mod in the printed message here will be the source module instead of the destination module, which may sometimes cause confusing printing here, but probably rarely). Closes #57969
This is close to the expected behavior after deprecations are removed (other than that the b->globalref->mod in the printed message here will be the source module instead of the destination module, which may sometimes cause confusing printing here, but probably rarely). I also needed this recently to find a place this warning occurred, so I think it should be merged now and get feedback later. Closes #57969 (cherry picked from commit 0682158)
…8260) Wording updated based upon timholy's suggestion in JuliaLang#57969.
This is close to the expected behavior after deprecations are removed (other than that the b->globalref->mod in the printed message here will be the source module instead of the destination module, which may sometimes cause confusing printing here, but probably rarely). I also needed this recently to find a place this warning occurred, so I think it should be merged now and get feedback later. Closes JuliaLang#57969
Uh oh!
There was an error while loading. Please reload this page.
The binding partitioning work introduced stricter rules for accessing globals, including a scary warning from
julia/src/module.c
Lines 775 to 784 in 13311f3
The text was updated successfully, but these errors were encountered: