Skip to content
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

RFC: make UndefVarError messages more precise and informative #51979

Merged
merged 1 commit into from
Nov 8, 2023

Conversation

vtjnash
Copy link
Sponsor Member

@vtjnash vtjnash commented Nov 1, 2023

Record the 'scope' of the variable that was undefined (the Module, or a descriptive word such as :local or :static_parameter). Add that scope to the error message, and expand the hint suggestions added by the REPL to include more specific advice on common mistakes:

  • forgetting to set an initial value
  • forgetting to import a global
  • creating a local of the same name as a global
  • not matching a static parameter in a signature subtype

Fixes #17062 (although more could probably be done to search for typos using REPL.string_distance and getting the method from stacktrace)
Fixes #18877
Fixes #25263
Fixes #35126
Fixes #39280
Fixes #41728
Fixes #48731
Fixes #49917
Fixes #50369

(this needs a fix to a Distributed test, which can be done concurrent with any discussion about exact wording here)

@vtjnash vtjnash added the error messages Better, more actionable error messages label Nov 1, 2023
@JeffBezanson
Copy link
Sponsor Member

This is great! 🎉

vtjnash added a commit to JuliaLang/Distributed.jl that referenced this pull request Nov 2, 2023
vtjnash added a commit to JuliaLang/Distributed.jl that referenced this pull request Nov 3, 2023
vtjnash added a commit to JuliaLang/Distributed.jl that referenced this pull request Nov 3, 2023
Record the 'scope' of the variable that was undefined (the Module, or a
descriptive word such as :local or :static_parameter). Add that scope to
the error message, and expand the hint suggestions added by the REPL to
include more specific advice on common mistakes:

  - forgetting to set an initial value
  - forgetting to import a global
  - creating a local of the same name as a global
  - not matching a static parameter in a signature subtype

Fixes #17062 (although more could probably be done to search for typos using REPL.string_distance and getting the method from stacktrace)
Fixes #18877
Fixes #25263
Fixes #35126
Fixes #39280
Fixes #41728
Fixes #48731
Fixes #49917
Fixes #50369
@vtjnash vtjnash marked this pull request as ready for review November 8, 2023 14:20
@vtjnash vtjnash added the merge me PR is reviewed. Merge when all tests are passing label Nov 8, 2023
@vtjnash vtjnash merged commit 449c7a2 into master Nov 8, 2023
8 checks passed
@vtjnash vtjnash deleted the jn/undefvarmessage branch November 8, 2023 17:24
@giordano giordano removed the merge me PR is reviewed. Merge when all tests are passing label Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment