-
-
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
fix promote_op function #29739
fix promote_op function #29739
Conversation
|
||
## promotion to complex ## | ||
|
||
_default_type(T::Type{Complex}) = Complex{Int} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
base/promotion.jl
Outdated
if isdefined(Core, :Compiler) | ||
const _return_type = Core.Compiler.return_type | ||
const _unsafe_return_type = Core.Compiler.return_type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically we're allowed to rename this, but I believe several packages use it so we should continue to support the old name.
Out of curiosity, where is this code? |
This function had some weird and broken extraneous code, using Core.Inference directly is not recommended, but where we are going to do it anyways, we should at least do it correctly. The `cumsum` code had a test to assert that `Real + Real` was convertable to `Real`. This was hacked into the code poorly. It is now hacked in directly. We can separately debate if this is a good idea, I am simply preserving the existing behavior of the code but implementing it correctly (by changing the behavior of the actual function, instead of by convincing inference to return the incorrect answer).
I'm referring specifically to the addition of this method: Previously, this result was achieved by defining that the result eltype was the typejoin of the input types with the result of calling R = promote_op(add_sum, T, T)
out = similar(A, R)
cumsum!(out, A, dims=dims)
return out Since there's a |
67621cc
to
40a4773
Compare
This function had some weird and broken extraneous code,
using Core.Inference directly is not recommended,
but where we are going to do it anyways, we should at least do it correctly.
The
cumsum
code had a test to assert thatReal + Real
was convertable toReal
.This was hacked into the code poorly. It is now hacked in directly.
We can separately debate if this is a good idea,
I am simply preserving the existing behavior of the code
but implementing it correctly (by changing the behavior of the actual function,
instead of by convincing inference to return the incorrect answer).
close #28370 -- not really fixable, but just don't expect to get good results from inference and you should be all set.