-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
UndefVarError line number wrong [0.4 only] #13851
Comments
I don't see the line number issue on |
see #13491 for the line number fix |
Same opinion here as #13818 (comment)
|
the line that fixes the bug is https://github.com/JuliaLang/julia/pull/13491/files#diff-6d4d21428a67320600faf5a1a9f3a16aR5911, the rest of the PR was removing old workarounds that were no longer necessary |
should be fixed by #15385 |
I'm using v0.4.0.
If I put the following code in a file (scopeError.jl):
then run it, I get the expected output:
If I uncomment line 7 with the
print("y = $y\n")
and run it again, I get an error.You'll notice that it's telling me the error is on line 4, inside the if-clause immediately after y's initialization, and not on line 7 inside the else-clause where y is actualy undefined (until ix == 2). At the least, the error message should point to line 7 I think. For the equivalent code, Python puts the error at line 7.
What REALLY confuses me is that the documentation specifically states that if-blocks "do not introduce new scope blocks." In that case, it seems like
y
should be scoped inside the entire for-loop after it gets initialized at ix==2. Perhaps I'm too used to Python and that's not how it actually works in julia, but I would have expected the following code to run without any errors:Yet it returns:
The equivalent code works without error in Python. Notice that the above error is again pointing to the wrong place.
The text was updated successfully, but these errors were encountered: