-
-
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
Obscure issue with redefining functions #4688
Comments
I believe this is caused by |
It seems like |
Since redefining functions isn't officially supported, I'm not sure that this can be considered a bug. This is really just a part if #265. |
Yes, since redefining functions isn't officially supported this may not qualify as a bug. But I'm not sure fixing #265 would necessarily fix this. It seems like |
Here's a case that doesn't involve redefining any functions, only defining new methods of the same function before ever calling it: julia> a(y) = "should be unreachable by calling b"
a (generic function with 1 method)
julia> b(y) = "not an Int"
b (generic function with 1 method)
julia> begin
a(y::Int) = "an Int"
let x = true
b(y::Int) = x == true ? a(y) : a(y)
end
end
b (generic function with 2 methods)
julia> b(1)
"should be unreachable by calling b" |
Ok, yeah, that's definitely a bug. Nice find. You're really putting the type inference through its paces. |
Same theory applies; it is looking at the old version of |
Although the behavior here is a bug (since the interior of
For example I might specify "adding a method to a top-level generic function is not guaranteed to take effect before the next top-level expression". The effect within the current top-level expression is undefined. |
I wouldn't expect redefining
a()
alone to make a difference here, sinceb()
is inlining it, but I would expect that redefininga()
and then redefiningb()
should change the output ofb()
. If I modifyb()
so that it doesn't usex
it works:If I remove the
begin
/end
around the redefinition it also works:The text was updated successfully, but these errors were encountered: