Skip to content
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

Merged
merged 8 commits into from
Jan 10, 2023

Conversation

N5N3
Copy link
Member

@N5N3 N5N3 commented Jan 7, 2023

The main motivation for this PR:

  1. 8652f26
    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.)
  2. 68e51c6
    This PR also tries to avoid some false Union{} caused by circular upbound checks. With merge_env we might form more Union 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.

@N5N3 N5N3 added types and dispatch Types, subtyping and method dispatch needs pkgeval Tests for all registered packages should be run with this change don't squash Don't squash merge labels Jan 7, 2023
@N5N3 N5N3 requested a review from vtjnash January 7, 2023 14:37
@N5N3
Copy link
Member Author

N5N3 commented Jan 7, 2023

@nanosoldier runtests()

@nanosoldier
Copy link
Collaborator

Your package evaluation job has completed - possible new issues were detected. A full report can be found here.

@N5N3
Copy link
Member Author

N5N3 commented Jan 8, 2023

@nanosoldier runtests(["LicenseGrabber", "Clustering", "AlgebraicRewriting", "ExtensibleEffects", "RDMREopt", "Cropbox", "DataTypesBasic", "ProbNumDiffEq", "SpmImageTycoonInstaller", "KalmanFilterTools", "SurrogatesMOE", "Rocket", "TypeClasses"])

@nanosoldier
Copy link
Collaborator

Your package evaluation job has completed - possible new issues were detected. A full report can be found here.

src/subtype.c Outdated Show resolved Hide resolved
src/subtype.c Outdated Show resolved Hide resolved
src/subtype.c Outdated Show resolved Hide resolved
src/subtype.c Show resolved Hide resolved
src/subtype.c Outdated Show resolved Hide resolved
@vtjnash
Copy link
Member

vtjnash commented Jan 9, 2023

I made comments on each of the individual commits (or none, if that particular commit SGTM). This seems like a good improvement.

@vtjnash vtjnash removed the needs pkgeval Tests for all registered packages should be run with this change label Jan 9, 2023
src/subtype.c Show resolved Hide resolved
src/subtype.c Outdated Show resolved Hide resolved
@N5N3 N5N3 force-pushed the inter-fix2 branch 8 times, most recently from 1f4424f to 4f6b436 Compare January 10, 2023 09:36
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).
N5N3 added 7 commits January 10, 2023 21:18
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}
@vtjnash vtjnash added the merge me PR is reviewed. Merge when all tests are passing label Jan 10, 2023
@N5N3 N5N3 merged commit d2c2709 into JuliaLang:master Jan 10, 2023
@N5N3 N5N3 removed the merge me PR is reviewed. Merge when all tests are passing label Jan 10, 2023
@N5N3 N5N3 deleted the inter-fix2 branch January 10, 2023 16:22
vtjnash pushed a commit that referenced this pull request Jul 30, 2024
This PR reverts the optimization from
748149e (part of #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 #55206
KristofferC pushed a commit that referenced this pull request Aug 2, 2024
This PR reverts the optimization from
748149e (part of #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 #55206

(cherry picked from commit fb6b790)
lazarusA pushed a commit to lazarusA/julia that referenced this pull request Aug 17, 2024
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
don't squash Don't squash merge types and dispatch Types, subtyping and method dispatch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants