Use type wrapper directly rather than typename in FieldError
#58507
+20
−2
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.