-
-
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
Widen diagonal var during Type
unwrapping in instanceof_tfunc
#52228
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2cdea4e
Widen diagonal var during `Type` unwrapping in `instanceof_tfunc`
N5N3 c024906
Fix for UnionAll handling in `insert_nondiagonal`
N5N3 328b554
Force deep widening if `widen2ub == 1`
N5N3 b9fdc9c
fuse `simple_union` for `Union` normalization
N5N3 4ea1a1f
Remove unneeded check
N5N3 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Since you already checked occurs_inv, it may be already fine to do
wident2ub
always?In effect though, that may be the same as implementing it as a map of
rewrap_unionall
over the fields (but recursively) roughly doingmap(rewrap_unionall, t.parameters, Repeated(u))
?I think the tricky cases I was thinking of were possibly something like:
Tuple{Val{S}, T, T} where {S, T<:S}
or perhapsTuple{S, T, T} where {S, T<:S}
or perhapsTuple{S, Vararg{T}} where {S, T<:S}
These could be safely widened to
Tuple{Val, Any, Any}
,Tuple{Any, Any, Any}
, andTuple{Any, Vararg{Any}}
respectively, but I was hoping to instead convert them to the more precise results ofTuple{Val{S}, T1, T2} where {S, T1<:S, T2<:S}
,Tuple{S, T1, T2} where {S, T1<:S, T2<:S}
, andTuple{S, Vararg{Union{T1,T2} where T1<:S where T2<:S}} where S
(though normally allocation normalization will have incorrectly broken that last type anyways, since it quickly converts that to
Tuple{S, Vararg{T where T<:S}} where S
which it thinks is equal toTuple{S, Vararg{S}} where S
even though it is not necessarily correct to replace T.ub with T in the expressionT where T
there–as that also implies a new constraint on theVararg
: that it is a diagonal Vararg when it was not intended to be)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.
It seems ok that
AsS
should be always concrete at runtime andTuple{S, Vararg{S}} where S
should cover all possible types.Edit: Well we are doing inference, so that might be bad.
The current code fails for this case though
It shows that the
widen2ub
branch should be recursive, and returnTuple{S2, S1, Vararg{Any}} where {S, S1<:S, S2<:S}
instead.As for the first two examples, the current code with
widen2ub = 0
should be precise, though with worse normalization.