-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Open
Labels
compiler:loweringSyntax lowering (compiler front end, 2nd stage)Syntax lowering (compiler front end, 2nd stage)minor changeMarginal behavior change acceptable for a minor releaseMarginal behavior change acceptable for a minor releaseparserLanguage parsing and surface syntaxLanguage parsing and surface syntax
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).
oscardssmith, jishnub, Seelengrab, sgt101, xgdgsc and 1 more
Metadata
Metadata
Assignees
Labels
compiler:loweringSyntax lowering (compiler front end, 2nd stage)Syntax lowering (compiler front end, 2nd stage)minor changeMarginal behavior change acceptable for a minor releaseMarginal behavior change acceptable for a minor releaseparserLanguage parsing and surface syntaxLanguage parsing and surface syntax