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

room for improvement with undefined var error message #5632

Closed
IainNZ opened this issue Jan 31, 2014 · 2 comments
Closed

room for improvement with undefined var error message #5632

IainNZ opened this issue Jan 31, 2014 · 2 comments
Labels
error handling Handling of exceptions by Julia or the user

Comments

@IainNZ
Copy link
Member

IainNZ commented Jan 31, 2014

function foo(x)
    return x^2
end

function bar(y)
    fizz = foo(y)
    # Many lines of code
    foo = fizz + 1
    # ...
    return foo
end

println(bar(5))

produces

ERROR: foo not defined
 in bar at /home/idunning/.julia/v0.3/JuMP/test/foo.jl:6
 in include at boot.jl:240
while loading /home/idunning/.julia/v0.3/JuMP/test/foo.jl, in expression starting on line 13

The error message, if you read as "foo not defined yet", would maybe point you to the fact foo is later used in the function as a variable, but I would find it confusing because the meaning of foo at that point is unambiguous, and is in fact defined in two places (not nowhere, as the message implies)

@JeffBezanson
Copy link
Member

I guess the message could identify whether it is a local or global variable. That would probably help in this case. In some cases I can also give a more specific message if the variable is provably used before it even could have been assigned, e.g. print(x); x = 1.

@JeffBezanson JeffBezanson changed the title Possible room for improvement with error message room for improvement with undefined var error message Aug 12, 2014
@jakebolewski jakebolewski added the error handling Handling of exceptions by Julia or the user label Jun 2, 2015
@KristofferC
Copy link
Member

Closing in favour of #17062

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
Projects
None yet
Development

No branches or pull requests

4 participants