-
-
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
local
in global scope
#10472
Comments
Fix was reverted in faae194. |
Related, this
or if not then it should error on |
This came up on julia-users, below is a minimal test case. I think this is related, if not I can make a new issue. Note that it errors in 0.5 and works in 0.4. (If
|
Complication: we like to be able to paste code from functions into the REPL if possible, and disallowing |
Ok, that would be a +1 for "just ignoring it". (Note though, because of hard & soft scope, copy-paste does not work always anyway.) |
Looking back at my previous attempt to fix this, the real wrinkle is macros. A macro like The other possible solution would involve macro hygiene. Basically we'd want to implicitly wrap the result of a macro in something like a |
So |
What really happens is that if a top-level expression contains |
Technically, changing this would be breaking, but it's a kind of weird thing to do. Should we just document |
I propose removing this from the milestone. Nice to fully work out at some point, but doesn't seem crucial. |
Wouldn't it be fairly simple to just raise an error for |
It's currently useful for macros to expand to top-level expressions that contain |
Ah, I see. Changing this does not actually seem at all pressing to me. I'd be fine with leaving this as-is with the justification that it makes macro stuff easier. What's the drawback of this feature? |
I don't see any major problems, it's just weird. |
Whatever, let's just keep it then. I guess we can document that it may go away and then see how much stuff in the ecosystem breaks if we ever decide to change it and let that be the deciding factor on whether it's a 1.x change or a 2.0 change. |
Since it came up in two discussions today, I am wondering if this behavior could just be kept as it is, and documented in the docstring
If there is agreement on this, I would be happy to do a PR to the docstring. |
Note, however, that if you have |
I think this issue can just be closed? The current behavior seems quite reasonable to me. |
Using
local
in the global scope does not error but does not do anything either:I would think that either throwing an error on
local x = 10
or just ignoring thelocal
would be the right thing to do.The text was updated successfully, but these errors were encountered: