-
-
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
Scoping issue in let-block #11808
Comments
I think it is another bug. Even in v0.3.9, I have already this problem. |
Yes, you're right. |
This example should shed some light:
Basically, adding a method to a top-level function is not guaranteed to take effect until the next top level expression. It's not really a scope issue per se. I'm positive there is another issue about this somewhere, but I haven't been able to find it yet. |
What's the reason behind that lack of a guarantee about when it takes effect? |
@JeffBezanson Is this some manifest of #265. julia> f() = 0
f (generic function with 1 method)
julia> function g()
foo = 10
global f
f() = foo
f()
end
g (generic function with 1 method)
julia> g()
0
julia> f()
10
julia> g()
0 |
It's related to #265, but IMO we could fix #265 without changing this behavior. Fixing #265 involves, essentially, invalidating and updating various caches, but there is still a question of when those changes become visible. The problem here is that for
|
Is there any way for the compiler to realize that it is calling something that has been modified previously in the same scope, and maybe generate different code, to handle picking up the new definition? |
@JeffBezanson Maybe you're thinking of #4688 (comment)? |
Yes! |
It's a feature or an issue? |
This seems to be working now:
Close? Or is it worth to keep it open for the general issues discussed here? |
Note that Jeff's example #11808 (comment) also works now:
|
This is all working with 1.0 scoping rules. Closing. |
This is a bit odd:
May have something to do with #11801.
The text was updated successfully, but these errors were encountered: