-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Add world age hint for UndefVarError #58572
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
Conversation
Similar to the existing world age hint for MethodError, this adds a helpful message when an UndefVarError occurs because a binding was defined in a newer world age than the code trying to access it. The implementation checks if a binding that was undefined at the error's world age is now defined in the current world, and displays: "The binding may be too new: running in world age X, while current world is Y." Additionally, for all binding kinds, the error hint now notes when the binding state has changed between the error's world and the current world. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
|
|
||
| # Get the current world's binding partition for comparison | ||
| curworld = tls_world_age() | ||
| cur_bpart = lookup_binding_partition(curworld, GlobalRef(scope, var)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The printing world doesn't really have anything in common with the error world, especially in the REPL. Can Claud add the field to UndefVarError?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UndefVarError already has the field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(See 5 lines prior)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current world is just for the extra warning if the current kind is different from the old kind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, great. I didn't realize we'd already done that. I assumed that Claude was just hallucinating it based on MethodError. I think we want get_world_counter() here though, not tls_world_age().
Lines 347 to 349 in 44c3813
| elseif hasmethod(f, arg_types) && !hasmethod(f, arg_types, world=ex.world) | |
| curworld = get_world_counter() | |
| print(io, "\nThe applicable method may be too new: running in world age $(ex.world), while current world is $(curworld).") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Claude thought so too, but I told it not to. I want to change the MethodError also, because otherwise there can be a TOCTOU issue with the hasmethod and the printing using different worlds. I think that's just confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought hasmethod is a tls_world query these days to prevent the TOCTOU issue (looks like that is used incorrectly above). The methods listing query though is a latest world query, so it should try to be consistent with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will make a separate PR to discuss that, but in any case, I think this should be tls_world_age
This rolls up a couple of bug fixes with some tweaks to documentation and AGENTS.md that came in useful getting the AI to do #58572.
This rolls up a couple of bug fixes with some tweaks to documentation and AGENTS.md that came in useful getting the AI to do #58572.
This rolls up a couple of bug fixes with some tweaks to documentation and AGENTS.md that came in useful getting the AI to do #58572.
Similar to the existing world age hint for MethodError, this adds a helpful message when an UndefVarError occurs because a binding was defined in a newer world age than the code trying to access it. The implementation checks if a binding that was undefined at the error's world age is now defined in the current world, and displays: "The binding may be too new: running in world age X, while current world is Y." Additionally, for all binding kinds, the error hint now notes when the binding state has changed between the error's world and the current world. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <[email protected]> (cherry picked from commit 2e39f64)
Similar to the existing world age hint for MethodError, this adds
a helpful message when an UndefVarError occurs because a binding
was defined in a newer world age than the code trying to access it.
The implementation checks if a binding that was undefined at the
error's world age is now defined in the current world, and displays:
"The binding may be too new: running in world age X, while current
world is Y."
Additionally, for all binding kinds, the error hint now notes when
the binding state has changed between the error's world and the
current world.
🤖 Generated with Claude Code