-
-
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
Type inference failing for nested reduction #46557
Comments
This trips the recursion heuristic, because it can't prove that the |
#45789 only works for reduction on nested Iterator, not nested reduction. |
Probably a duplicate of #40084. I was bitten by this with the following example. Even more mysterious, the inference works if I define the same function twice... julia> using Test
julia> f(x) = sum(x) do v
sum(length, v)
end;
julia> @inferred f([[[1]]])
ERROR: return type Int64 does not match inferred return type Any
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:35
[2] top-level scope
@ REPL[3]:1
julia> f(x) = sum(x) do v
sum(length, v)
end;
julia> @inferred f([[[1]]])
1 |
Great example! The phenomenon about it being inferred after a second definition has happened to me as well, it is really weird. E.g. I redefined a function in a package that was type-unstable in the unit tests, but then was type stable after being overwritten with the same source code. |
I run into similar issues. Redefining the same helps. In a sense this looks promising, as the compiler had all information already on the first run, but somehow needed to runs to actually get it. |
I just ran into a similar example:
|
Don't think that has anything to do with this issue, since there is no nested inference there (only a closure capture of a Type) |
The following nested reduction does not infer, even after #45789:
The text was updated successfully, but these errors were encountered: