-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Use type wrapper directly rather than typename in FieldError
#58507
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
Merged
IanButterworth
merged 6 commits into
JuliaLang:master
from
MasonProtter:fielderror-changing-fields
Jun 6, 2025
Merged
Use type wrapper directly rather than typename in FieldError
#58507
IanButterworth
merged 6 commits into
JuliaLang:master
from
MasonProtter:fielderror-changing-fields
Jun 6, 2025
Conversation
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
8d1a053
to
052b3b7
Compare
One further reason in favour of this which was mentioned on Discourse is that the stacktrace info is not always present if there was inlining: julia> mutable struct Point
x::Float64
y::Float64
end
julia> const a = Point(1.0, 2.0);
julia> mutable struct Point
x::Float64
y::Float64
z::Float64
end
julia> @inline f() = a.z; Before this PR: julia> f()
ERROR: FieldError: type Point has no field `z`, available fields: `x`, `y`
Stacktrace:
[1] getproperty
@ ./Base_compiler.jl:54 [inlined]
[2] f()
@ Main ./REPL[4]:1
[3] top-level scope
@ REPL[5]:1 After this PR: julia> f()
ERROR: FieldError: type @world(Point, 38523:38526) has no field `z`, available fields: `x`, `y`
Stacktrace:
[1] getproperty
@ ./Base_compiler.jl:54 [inlined]
[2] f()
@ Main ./REPL[4]:1
[3] top-level scope
@ REPL[8]:1 |
Triage is in favour |
KristofferC
pushed a commit
that referenced
this pull request
Jun 6, 2025
(cherry picked from commit 347fb7c)
aviatesk
added a commit
to aviatesk/JET.jl
that referenced
this pull request
Jun 7, 2025
aviatesk
added a commit
to aviatesk/JET.jl
that referenced
this pull request
Jun 7, 2025
aviatesk
added a commit
to aviatesk/JET.jl
that referenced
this pull request
Jun 7, 2025
aviatesk
added a commit
to aviatesk/JET.jl
that referenced
this pull request
Jun 7, 2025
aviatesk
added a commit
to aviatesk/JET.jl
that referenced
this pull request
Jun 7, 2025
aviatesk
added a commit
to aviatesk/JET.jl
that referenced
this pull request
Jun 7, 2025
nilesh646
pushed a commit
to nilesh646/julia
that referenced
this pull request
Jun 17, 2025
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.
Motivation
FieldError
currently printsnameof(exc.type)
which just gives a simple symbol for a type's name when a user tries to access a non-existant field.The argument is that this should say something like
FieldError: type @world(Point, 38528:38531) has no field x
. Though, I will note that the world-info is available in the stacktrace, so it is in some sense redundant.Similarly, it says
Point
rather thanMain.Foo.Point
in the error message. This info is also available in the stacktrace.This PR
This PR simply replaced
nameof
with.name.wrapper
to get the unparameterized version of the type so that it can be printed with the@world
decorations and namespace as needed:and
Discussion / doubts
I'm a bit conflicted on whether or not this is a good idea. On one hand, it clutters the error message with info you could get by simply reading the stacktrace. On the other hand, many users are allergic to reading stacktraces and report confusion with things like this.
I'm interested if people have thoughts on the mechanism here, or if there's a better way to surface the worldage problem / namespacing stuff via hints.