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 some cases of diagonal subtyping when a var also appears invariantly #34272

Merged
merged 1 commit into from
Jan 15, 2020

Conversation

JeffBezanson
Copy link
Sponsor Member

This is a part of #31833 that seems to be pretty non-breaking.

fix #26108, fix #26716

@JeffBezanson JeffBezanson added domain:types and dispatch Types, subtyping and method dispatch kind:bugfix This change fixes an existing bug labels Jan 6, 2020
@JeffBezanson
Copy link
Sponsor Member Author

@nanosoldier runtests(ALL, vs = ":master")

@nanosoldier
Copy link
Collaborator

Your test job has completed - possible new issues were detected. A full report can be found here. cc @maleadt

@vtjnash
Copy link
Sponsor Member

vtjnash commented Jan 7, 2020

GeometryTypes package is an interesting case:

MethodError: *(::StaticArrays.SArray{Tuple{2,2},Int64,2,4}, ::HyperRectangle{2,Int64}) is ambiguous. Candidates:
*(m::StaticArrays.SArray{Tuple{N1,N1},T1,2,L} where L, h::HyperRectangle{N2,T2}) where {N1, N2, T1, T2} in GeometryTypes at /home/pkgeval/.julia/packages/GeometryTypes/06goY/src/hyperrectangles.jl:83
*(m::StaticArrays.SArray{Tuple{N,N},T1,2,L} where L, h::HyperRectangle{N,T2}) where {N, T1, T2} in GeometryTypes at /home/pkgeval/.julia/packages/GeometryTypes/06goY/src/hyperrectangles.jl:121

So we have A = Tuple{V{Tuple{N,N}}, V{N}} where N vs. B = Tuple{V{Tuple{N1,N1}}, V{N2}} where {N1, N2}, where before this change A <: B, while it seems that afterwards it's presumably not considering N1 to be in invariant position anymore.

@JeffBezanson
Copy link
Sponsor Member Author

Yeah, that's one of the trickiest cases. It's hard to say what we even want Ref{Tuple{T,T}} where T to mean. I tried making that T concrete but maybe it can't be.

@vtjnash
Copy link
Sponsor Member

vtjnash commented Jan 7, 2020

Right. It's not obvious whether that only means the values for T are required to be the same (because the Tuple itself is invariant), or whether for soundness it must mean that T is also concrete. I'm leaning towards the former interpretation, but maybe it's better if it is the latter (as done here).

@vtjnash
Copy link
Sponsor Member

vtjnash commented Jan 7, 2020

Note: I think that case is described in #26175 (comment), where we see it's currently undecidable given Tuple{T, T} where T whether Tuple{R, R} (for any value of R except Union{}) is a proper subtype of it, and is therefore also partly the motivation for #24614 (and this PR).

@JeffBezanson
Copy link
Sponsor Member Author

Ok, I may have found a version of this that fixes #31824 too, without needing to change any convert methods and without changing that case from GeometryTypes 🎉 .

@JeffBezanson JeffBezanson added the kind:minor change Marginal behavior change acceptable for a minor release label Jan 7, 2020
@JeffBezanson
Copy link
Sponsor Member Author

@nanosoldier runtests(ALL, vs = ":master")

@maleadt
Copy link
Member

maleadt commented Jan 8, 2020

I did a bunch of Nanosoldier development changing the report repo layout, so I had to restart your job:
@nanosoldier runtests(ALL, vs = ":master")

@nanosoldier
Copy link
Collaborator

nanosoldier commented Jan 9, 2020

Your test job has completed - possible new issues were detected. A full report can be found here. cc @maleadt

@JeffBezanson
Copy link
Sponsor Member Author

Hmm, the correct commit is listed at the top of the report, but in the versioninfo output in the logs it looks like it actually ran with the wrong commit. And indeed GeometryTypes passes locally but failed with the same error in the pkgeval run.

@maleadt
Copy link
Member

maleadt commented Jan 9, 2020

Hmm, the correct commit is listed at the top of the report, but in the versioninfo output in the logs it looks like it actually ran with the wrong commit.

The commit is always going to be different, because we build the merge commit (which doesn't really exist) instead of the head of this pull request. It's possible that some caching is happening though, and that the previous merge commit was used. I'll have a look.

EDIT: yes, that's what happening:

julia> repo = NewPkgEval.get_repo("JuliaLang/julia")
LibGit2.GitRepo("/home/maleadt/.julia/packages/NewPkgEval/JClmG/deps/downloads/JuliaLang/julia")

julia> NewPkgEval.get_repo_commit(repo, "pull/34272/merge")
("refs/remotes/origin/pull/34272/merge", Git Commit:
Commit Author: Name: Jeff Bezanson, Email: [email protected], Time: 2020-01-06 01:02:36-05:00
Committer: Name: GitHub, Email: [email protected], Time: 2020-01-06 01:02:36-05:00
SHA: dfcba8768f7c22fc8bee10bd7562f4e1eb27766e
Message:
Merge 49623bd294a505b2cafc4e1eedd4a51e2bda3efc into 18783434e9c0e48152b99d5e3717deb8711f492b
)

@maleadt
Copy link
Member

maleadt commented Jan 9, 2020

Trying a more fine-grained run first, as suggested by the report (the system is now busy doing releast-1.4 builds):

@nanosoldier runtests(["ClusteringGA", "CurrenciesBase", "FameSVD", "GeometryTypes", "Graph500", "HTTP", "IncrementalInference", "JuliaDB", "KissMCMC", "LCMCore", "Lerche", "LoopThrottle", "MbedTLS", "Mocking", "OhMyREPL", "RigidBodyDynamics", "Sched", "StanMamba"], vs = ":master")

@nanosoldier
Copy link
Collaborator

Your test job has completed - possible new issues were detected. A full report can be found here. cc @maleadt

@JeffBezanson
Copy link
Sponsor Member Author

Ok, IncrementalInference and Sched failures seem to be intermittent, and MbedTLS also crashes on other branches, so this looks OK so far.

@JeffBezanson
Copy link
Sponsor Member Author

@nanosoldier runtests(ALL, vs = ":master")

@nanosoldier
Copy link
Collaborator

Your test job has completed - possible new issues were detected. A full report can be found here. cc @maleadt

@JeffBezanson
Copy link
Sponsor Member Author

Starting to look good! QuantumAlgebra has an unreachable instruction to investigate; that's about it.

@JeffBezanson
Copy link
Sponsor Member Author

Fixed! Also double-checked that all the other failing packages pass locally.
This is now ready to merge 🎉 🎉

@JeffBezanson JeffBezanson merged commit a9f1227 into master Jan 15, 2020
@JeffBezanson JeffBezanson deleted the jb/diag3 branch January 15, 2020 22:37
@@ -136,6 +136,35 @@ function test_diagonal()
@test issub(Tuple{Tuple{T, T}} where T>:Int, Tuple{Tuple{T, T} where T>:Int})
@test issub(Vector{Tuple{T, T} where Number<:T<:Number},
Vector{Tuple{Number, Number}})

@test !issub(Type{Tuple{T,Any} where T}, Type{Tuple{T,T}} where T)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused...

julia> Type{Tuple{T, Any} where T} <: Type{Tuple{Any,Any}} <: Type{Tuple{T, T}} where T
true

julia> Type{Tuple{T, Any} where T} <:                         Type{Tuple{T, T}} where T
false

In fact, we have

julia> Type{Tuple{T, Any} where T} == Type{Tuple{Any,Any}}
true

which looks right to me, as (Tuple{T, Any} where T) == Tuple{Any,Any}, noting the covariance of T here. But Type{Tuple{Any,Any}} <: Type{Tuple{T, T}} where T also looks fine: LHS and RHS become equal for one specific choice of T on the RHS, namely Any. And T does not fall under the diagonal rule. (It would if the where were inside the Type{}.) So that would leave me with the conclusion that Type{Tuple{T, Any} where T} <: Type{Tuple{T, T}} where T should hold. Yet here, we test for the opposite. Wrong test or wrong reasoning? (Note that as it is now, this violates transitivity, so there must be a bug somewhere.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same violation of transitivity can be observed for this simpler case, BTW:

julia> Ref{Tuple{T} where T} <: Ref{Tuple{Any}} <: Ref{Tuple{T}} where T
true

julia> Ref{Tuple{T} where T} <:                    Ref{Tuple{T}} where T
false

I'd guess we have an issue for this somewhere, but couldn't find one at a quick glance.

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

Successfully merging this pull request may close these issues.

subtyping bug: diagonality is ignored in union subtyping bug with comparing diagonal and triangular tuples
5 participants