-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
avoid storing types in fields in Fix, ComposedFunction, Splat, Broadcasted
#59623
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
base: master
Are you sure you want to change the base?
avoid storing types in fields in Fix, ComposedFunction, Splat, Broadcasted
#59623
Conversation
|
@nanosoldier |
|
@nanosoldier |
Fix, ComposedFunction, Returns for some edge casesFix, ComposedFunction, Returns, Splat, Broadcast.Broadcasted for some edge cases
|
It's really inspiring and educative to follow your thought process and your work here. Thanks a lot for this! What about |
julia> typeof(Float32 => Int)
Pair{DataType, DataType}
julia> typeof(Float32 ∘ Int)
ComposedFunction{Type{Float32}, Type{Int64}}Perhaps modifying |
vtjnash
left a comment
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.
Adding maybe_unwrap appears to be a layering violation in the code, since it means the result is no longer a safe pass-through. Same goes for optimizing any of these functions using this shim (especially Fix and Returns), since they will cease to function exactly per their docstring, and will instead inject a different value that is type-equal, but which is not egal to the value the user expected.
|
The package evaluation job you requested has completed - possible new issues were detected. Report summary❗ Packages that crashed3 packages crashed on the previous version too. ✖ Packages that failed22 packages failed only on the current version.
1308 packages failed on the previous version too. ✔ Packages that passed tests17 packages passed tests only on the current version.
5262 packages passed tests on the previous version too. ~ Packages that at least loaded11 packages successfully loaded only on the current version.
3459 packages successfully loaded on the previous version too. ➖ Packages that were skipped altogether900 packages were skipped on the previous version too. |
Fix, ComposedFunction, Returns, Splat, Broadcast.Broadcasted for some edge casesFix, ComposedFunction, Splat, Broadcast.Broadcasted for some edge cases
As pointed out by vtjnash.
True, haven't considered that. I notice the Your concern is basically that someone might have written a method something like this, where function (a::Type{A})(args...; kwargs...)
if a === B
g(args...; kwargs...)
else
h(args...; kwargs...)
end
endThis kind of usage would be broken by this PR because we would always have Regarding the PkgEval run, I notice these real failures:
|
|
I think ComposedFunction is okay to change, but not sure about Fix, since it means we could not use |
|
The package evaluation job you requested has completed - possible new issues were detected. Report summary❗ Packages that crashed1 packages crashed only on the current version.
6 packages crashed on the previous version too. ✖ Packages that failed32 packages failed only on the current version.
1300 packages failed on the previous version too. ✔ Packages that passed tests6 packages passed tests only on the current version.
5275 packages passed tests on the previous version too. ~ Packages that at least loaded6 packages successfully loaded only on the current version.
3460 packages successfully loaded on the previous version too. ➖ Packages that were skipped altogether899 packages were skipped on the previous version too. |
Fix, ComposedFunction, Splat, Broadcast.Broadcasted for some edge casesFix, ComposedFunction, Splat, Broadcasted
vtjnash
left a comment
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.
I think you need to find a way to eliminate the _maybe_unwrap_type overloads all over the place. I think you can potentially do it (by wrapping the function with the unwrap at the same time as you wrap the argument), but the overloads of getproperty also seem like they need to go away too.
This is:
A minor change to the functionality of
Fix,ComposedFunction,Splat,Broadcast.Broadcastedthat ensures these types are zero-cost abstractions (which are abstractions that should not cause any run time overhead) even when their argument values are types.The interpretation of the fields and the type parameters of
Fix,ComposedFunction,Splat,Broadcast.Broadcastedis changed in some special cases. The intention is to prevent having a field type which is some subtype ofType.The field
xofBase.Fixis not affected by this change, only the fieldf. This is to prevent potential breakage.A feature addition, introducing the new
TypeWrapper. While I feel awkward proposing a feature addition along with another kind of improvement, I feel the feature addition is necessary for completeness of the above redesign. This is becauseTypeWrapperbecomes necessary to describe some subtypes ofFix,ComposedFunction,Splat,Broadcast.Broadcastedwith this change.xref #59619