-
-
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
typeintersect: improve merge_env
accuracy and avoid possible false Union{}
#48167
Conversation
@nanosoldier |
Your package evaluation job has completed - possible new issues were detected. A full report can be found here. |
@nanosoldier |
Your package evaluation job has completed - possible new issues were detected. A full report can be found here. |
I made comments on each of the individual commits (or none, if that particular commit SGTM). This seems like a good improvement. |
1f4424f
to
4f6b436
Compare
If we always merge the whole env, then the output bounds would be widen than input if different Union decision touch different vars. Also add missing `occurs_inv/cov`'s merge (by max).
This is not ideal. As some times circular bound seems meaningful. But at least better than `Union{}` ?
1. use `obviously_in_union` to catch more unneeded duplication in `Union`. 2. under-estimate merged `lb` in more case. (Should not affect subtype path.)
I gave up fixing the deep stack overflow. Making the `env` soundness seems much easier. close JuliaLang#47874. At present, we only catch cases with pattern like A1 = Union{T,Int} where {T} A2 = Union{T2,Int} where {T,T2<:Union{T,Int}} A3 = Union{Int,A2}
…Lang#55299) This PR reverts the optimization from 748149e (part of JuliaLang#48167), while keeping the fix for merging occurs_inv/occurs_cov, as that optimzation makes no sense especially when typevar occurs both inside and outside the inner intersection. Close JuliaLang#55206
The main motivation for this PR:
On master, we always merge the whole env during
intersect_all
, which is not ideal as the output bounds would be wider than input if 2 Union decision touches different vars.This PR tries to only merge the vars we meet in the current decision. And add the missing
occurs_inv
/occurs_cov
merge (by max.)This PR also tries to avoid some false
Union{}
caused by circular upbound checks. Withmerge_env
we might form moreUnion
upbound than before.So I think it makes sense to ignore the invalid part in a
Union
.The rest commits are added mainly to avoid stackoverflow. (As we might trigger more re-intersection with change 2.)
Test added.