reflection: Add world keyword argument to Base.bodyfunction - #63239
Merged
Merged
Conversation
Member
|
what makes this preferable over |
Member
Author
|
To maintain consistency with the other reflection functions, I think it would be better to add a |
adienes
approved these changes
Sep 18, 2026
vtjnash
approved these changes
Sep 18, 2026
vtjnash
left a comment
Member
There was a problem hiding this comment.
I guess it's too late to move this to InteractiveUtils where it likely belonged, so we should make it agree with the others anyways.
`Base.bodyfunction` resolved the keyword body function with `getfield(mod, name)`, which looks up the binding in the world age of the calling task. A long-lived task that was spawned before the method was defined therefore hit the backdated binding path, which prints the `access to binding in a world prior to its definition world` warning and throws `UndefVarError` under `--depwarn=error`. JETLS ran into this when its analysis worker tasks inspected methods that were defined after the workers had started. This change adds a `world::UInt=get_world_counter()` keyword argument and performs the binding lookup with `invoke_in_world`, consistently with other reflection utilities such as `hasmethod` and `kwarg_decl`. Existing positional calls keep working, and they now resolve the body function in the latest world regardless of the world age of the caller. Assisted-by: Claude Code (Fable 5.1)
aviatesk
force-pushed
the
avi/bodyfunction-world
branch
from
September 18, 2026 14:51
dfcdc8a to
cd47e7d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Base.bodyfunctionresolved the keyword body function withgetfield(mod, name), which looks up the binding in the world age of the calling task. A long-lived task that was spawned before the method was defined therefore hit the backdated binding path, which prints theaccess to binding in a world prior to its definition worldwarning and throwsUndefVarErrorunder--depwarn=error. JETLS ran into this when its analysis worker tasks inspected methods that were defined after the workers had started.This change adds a
world::UInt=get_world_counter()keyword argument and performs the binding lookup withinvoke_in_world, consistently with other reflection utilities such ashasmethodandkwarg_decl. Existing positional calls keep working, and they now resolve the body function in the latest world regardless of the world age of the caller.Assisted-by: Claude Code (Fable 5.1)