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

fix #31703, type intersection bug with chains of vars in invariant position #31747

Merged
merged 1 commit into from
Apr 18, 2019

Conversation

JeffBezanson
Copy link
Member

@JeffBezanson JeffBezanson commented Apr 17, 2019

The problem here was the rule for intersecting var T inside e.g. Ref{T} ⊓ Ref{Foo{S}}. We were intersecting Foo{S} with the upper bound of T, and then (sometimes) doing a side check that that type is consistent. (The "sometimes" was added in #29380, basically as a different attempt to fix this same problem.) But that is not correct: T needs to equal Foo{S}, so Foo{S} must be fully within its bounds. The catch is that that doesn't need to hold for all values of S though; we are free to restrict S while forming the intersection. So here I changed the algorithm to always check T.lb <: Foo{S} <: T.ub, but with all variables treated as existential. Seems to work. This subtype_in_env_existential trick might have other uses in intersection as well.

Fixes #31703

@JeffBezanson JeffBezanson added types and dispatch Types, subtyping and method dispatch bugfix This change fixes an existing bug backport 1.2 labels Apr 17, 2019
@vtjnash
Copy link
Member

vtjnash commented Apr 18, 2019

Is this related to #29524 (see reduction near the end) which had:

julia> typeintersect(Ref{Tuple{T}} where T, Ref{_1} where _1<:Tuple{Real})
Union{}

@JeffBezanson
Copy link
Member Author

Wow, yes, it does seem to fix that case too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This change fixes an existing bug types and dispatch Types, subtyping and method dispatch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unreachable reached in Atoms.jl yet again
3 participants