Open
Description
From a Hacker News comment today, this code at toplevel throws an error on line 4:
local s = 0
for i = 1:10
t = s + i
s = t
println("$s")
end
println("$s")
Now I am not too surprised this doesn't work at toplevel, but it's a poor experience for users to encounter the error when reaching for s
and not when declaring it. If the local var =
declaration is guaranteed to be useless, then the code coming after is almost certainly going to have a bug.
IMO it would be a better user experience to throw an error on line 1, above, not line 4, since that is where the mistake in this code snippet is. Users will need to learn the global / non-global scoping rules to use Julia effectively, and the sooner we "teach" them the better (and clearly the user in the link above did not have a good experience).