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

More help for users when encountering UndefVarError #17062

Closed
3 tasks
ivarne opened this issue Jun 22, 2016 · 3 comments · Fixed by #51979
Closed
3 tasks

More help for users when encountering UndefVarError #17062

ivarne opened this issue Jun 22, 2016 · 3 comments · Fixed by #51979
Labels
error handling Handling of exceptions by Julia or the user good first issue Indicates a good issue for first-time contributors to Julia Hacktoberfest Good for Hacktoberfest participants help wanted Indicates that a maintainer wants help on an issue or pull request

Comments

@ivarne
Copy link
Member

ivarne commented Jun 22, 2016

The printing of UndefVarError is very minimalistic and can be improved to look for common mistakes.

  • Look for variable names that is similar to Base functions/types (eg, levenshtein distance/length)
  • Collect a list of function names in other languages and add explanation of how to get equivalent results in Julia
  • Collect a list of function names in common packages so that we can point users to the correct package (especially relevant now that we have started to move functions out of Base).

I opened the similar issue #7512 a while ago, but it was hard to find a general solution.

Ref #17046 (comment), and cc @tknopp

@ivarne ivarne added help wanted Indicates that a maintainer wants help on an issue or pull request error handling Handling of exceptions by Julia or the user good first issue Indicates a good issue for first-time contributors to Julia labels Jun 22, 2016
@oxinabox
Copy link
Contributor

Is there levenshtein distance already in Base?
(I know it is in Distences.jl)
But I'm not sure what is used for apropos.

@MichaelHatherly
Copy link
Member

Is there levenshtein distance already in Base?

Yup, there's one here.

@dbeach24
Copy link
Contributor

Finding similar function names (based on levens
Is there a good way to get the names of the local variables within the stack frame that triggered the UndefVarError?

@kshyatt kshyatt added the Hacktoberfest Good for Hacktoberfest participants label Oct 5, 2016
vtjnash added a commit that referenced this issue Oct 31, 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 added a commit that referenced this issue Nov 8, 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 added a commit that referenced this issue Nov 8, 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error handling Handling of exceptions by Julia or the user good first issue Indicates a good issue for first-time contributors to Julia Hacktoberfest Good for Hacktoberfest participants help wanted Indicates that a maintainer wants help on an issue or pull request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants