InteractiveUtils: access bindings in fixed world (#61804)
This is a less-ambitious version of the program started in #60736 that
avoids the need for #61200, by restricting itself to world-age at
definition and side-stepping the issue of which names were `export`ed or
`public` at specific world ages.
A copy of my OP plus a summary of the new strategy:
InteractiveUtils provides a number of utilities for querying and
accessing the contents of modules. Because these modules can gain new
bindings, some callers of InteractiveUtils functions produce warnings
WARNING: Detected access to binding ... prior to its definition world.
One dramatic example occurs with the sequence
using OptimizationProblems: OptimizationProblems
using OptimizationProblems.ADNLPProblems
using ADNLPModels: ADNLPModel
when running with Revise. ADNLPProblems loads new problems via Requires,
and starting with v3.13 Revise queries `InteractiveUtils.subtypes` to
cache dependent fieldtypes. This triggers the warning.
To fix this, add a `world` keyword argument to `names`/`unsorted_names`
to control the world age at which bindings are looked up. It is then
threaded through `varinfo`, `methodswith`, and `subtypes` in
InteractiveUtils so they operate on bindings in the correct world.
The default for the `world` kwarg preserves the current behavior:
`names`/`unsorted_names` default to `tls_world_age()` (matching the
prior C-side use of `jl_current_task->world_age`); the InteractiveUtils
entry points default to `get_world_counter()` so interactive tools see
the latest definitions by default.
Closes #60736
Closes #61200
Related: https://github.com/timholy/Revise.jl/issues/993
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com> T
Tim Holy committed
5ee356ac9e51335c1ce68234e11e050051902ac0
Parent: dbb9a28
Committed by GitHub <noreply@github.com>
on 5/15/2026, 3:12:00 AM