{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/11242","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/11242/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/11242/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/11242/events","html_url":"https://github.com/JuliaLang/julia/pull/11242","id":75459510,"number":11242,"title":"NTuples made me sad (so I nixed them)","user":{"login":"timholy","id":1525481,"avatar_url":"https://avatars.githubusercontent.com/u/1525481?v=3","gravatar_id":"","url":"https://api.github.com/users/timholy","html_url":"https://github.com/timholy","followers_url":"https://api.github.com/users/timholy/followers","following_url":"https://api.github.com/users/timholy/following{/other_user}","gists_url":"https://api.github.com/users/timholy/gists{/gist_id}","starred_url":"https://api.github.com/users/timholy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timholy/subscriptions","organizations_url":"https://api.github.com/users/timholy/orgs","repos_url":"https://api.github.com/users/timholy/repos","events_url":"https://api.github.com/users/timholy/events{/privacy}","received_events_url":"https://api.github.com/users/timholy/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/JuliaLang/julia/milestones/14","html_url":"https://github.com/JuliaLang/julia/milestones/0.5.0","labels_url":"https://api.github.com/repos/JuliaLang/julia/milestones/14/labels","id":868319,"number":14,"title":"0.5.0","description":"Release-defining items for v0.5 - the `Arraymageddon` release.","creator":{"login":"vtjnash","id":330950,"avatar_url":"https://avatars.githubusercontent.com/u/330950?v=3","gravatar_id":"","url":"https://api.github.com/users/vtjnash","html_url":"https://github.com/vtjnash","followers_url":"https://api.github.com/users/vtjnash/followers","following_url":"https://api.github.com/users/vtjnash/following{/other_user}","gists_url":"https://api.github.com/users/vtjnash/gists{/gist_id}","starred_url":"https://api.github.com/users/vtjnash/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vtjnash/subscriptions","organizations_url":"https://api.github.com/users/vtjnash/orgs","repos_url":"https://api.github.com/users/vtjnash/repos","events_url":"https://api.github.com/users/vtjnash/events{/privacy}","received_events_url":"https://api.github.com/users/vtjnash/received_events","type":"User","site_admin":false},"open_issues":59,"closed_issues":8,"state":"open","created_at":"2014-11-16T16:16:12Z","updated_at":"2015-09-15T14:28:02Z","due_on":"2016-02-01T05:00:00Z","closed_at":null},"comments":55,"created_at":"2015-05-12T04:42:04Z","updated_at":"2015-09-15T21:33:32Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/JuliaLang/julia/pulls/11242","html_url":"https://github.com/JuliaLang/julia/pull/11242","diff_url":"https://github.com/JuliaLang/julia/pull/11242.diff","patch_url":"https://github.com/JuliaLang/julia/pull/11242.patch"},"body":"This rabbit hole turned out to be a giant dungeon, ~~instead, and I haven't yet found the exit. I think I'm very close, but I've spent far too much time on this and I'm beginning to run out of ideas and energy.~~, but yay, I found the exit.\r\n\r\nThis is the latest attempt at `NTuple{N,T} -> Tuple{Vararg{T,N}}`, aka #10911, #10691. Julia builds and passes ~~many~~ all tests, ~~but borks on some (e.g., `subarray`). The current problem seems to be that a `VarState(Tuple{_<:Vararg{T,N}},false)` gets injected somewhere (leading ultimately to an attempted `Tuple{Vararg, ASCIIString}` and `Vararg type in non-final position` error). It's probably a 3-line fix, but I have not yet succeeded in finding the correct 3 lines (inference.jl is difficult for not-Jeff to hack on).~~\r\n\r\n~~This still contains~~The intermediate commits contain a lot of debugging code that ~~will eventually be~~ was deleted in the later commits. In the end, the way I got this ~~far~~to work was to write new versions of `jl_intersect_type`, `jl_subtype_le`, `type_morespecific`, and `type_match_`, which (1) called the old algorithm and stored the result, then (2) translated NTuples on-the-fly and then called the new algorithm with the translated arguments, and (3) printed some output if the two disagreed. ~~This branch is partway through the deletion of all that debugging code; before completing the migration I'd love to figure out where the problem is.~~\r\n\r\nIt turns out that we have enough differences in how `NTuple`s and `Tuple{Vararg}`s behave that some disagreements are unavoidable; one of the best things about this, presumably, is that such differences will go away. I even went to the trouble to catalog the differences; in the \"best\" column I use \"N\" to indicate that I think the new algorithm yields the most sensible result, and \"O\" to indicate the old algorithm. Only two of those four algorithms had differences, of which representative examples are:\r\n\r\n`jl_intersect_type`:\r\nnone (as measured by a <: b && b <: a)\r\n\r\n`jl_subtype_le`:\r\n\r\n| a | b | ta | invariant | old result | new result | best |\r\n| --- | --- | --- | --------- | ---------- | ---------- | ---- |\r\n| `_<:Tuple` | `Tuple` | 0 | 0 | 0 | 1 | N |\r\n| `_<:Tuple{_<:Vararg{T<:Any, N<:Any}}` | `Tuple{Vararg{#T<:Any, N<:Any}}` | 0 | 0 | 0 | 1 | N? |\r\n| `Tuple{}` | `NTuple{#_<:Any, #T<:Any}` | 0 | 1 | 1 | ~~0~~1 | ~~O~~same |\r\n| `Tuple{Tuple{_<:Tuple{Any, Any}}}` | `Tuple{Tuple{Tuple{Any, Any}}}` | 0 | 0 | 0 | 1 | N? |\r\n| `_<:Tuple{Vararg{Int64, #N<:Any}}` | `Tuple{Vararg{#T<:Any, #_<:Any}}` | 0 | 0 | 0 | 1 | N? |\r\n| `Tuple{Symbol, Integer}` | `Tuple{Vararg{#T<:Any, N<:Any}}` | 0 | 1 | 0 | 1 | ? |\r\n| `Tuple{Char, Char}` | `Tuple{Vararg{#T<:Any, N<:Any}}` | 0 | 1 | 0 | 1 | N |\r\n| `Tuple{Type{Tuple{Int64, Int64}}}` | `Tuple{Type{Tuple{Int64, Vararg{Int64, N<:Any}}}}` | 0 | 0 | 0 | 1 | N? |\r\n| `Tuple{Type{Tuple{Char}}, Tuple{Vararg{Any, N<:Any}}}` | `Tuple{Type{Tuple{Vararg{#T<:Any, N<:Any}}}, Tuple}` | 0 | 0 | 0 | 1 | N |\r\n| `Tuple{Tuple{_<:Tuple{Vararg{Any, N<:Any}}}, Int64}` | `Tuple{Tuple{Tuple{Vararg{Any, N<:Any}}}, Int64}` | 0 | 0 | 0 | 1 | N? |\r\n| `Tuple{Tuple{Symbol, Vararg{Symbol, N<:Any}}, DataType, Type{T<:Any}}` | `Tuple{Vararg{#T<:Any, N<:Any}}` | 0 | 1 | 0 | 1 | N |\r\n| `_<:Tuple{Symbol, Vararg{Symbol, N<:Any}}` | `Tuple` | 0 | 0 | 0 | 1 | N |\r\n| `Tuple{DataType, Type}` | `Tuple{Vararg{#T<:Any, N<:Any}}` | 0 | 1 | 0 | 1 | N? |\r\n| `_<:Tuple{Tuple{Symbol, Vararg{Symbol, N<:Any}}, DataType, Type{T<:Any}}` | `Tuple{Tuple{Vararg{Any, N<:Any}}, DataType, Vararg{Any, N<:Any}}` | 0 | 0 | 0 | 1 | N? |\r\n| `Tuple{Type{Tuple{Type{Base.IteratorsMD.CartesianIndex}, Tuple{Int64, Int64, Int64}}}, UInt64}` | `Tuple{Type{Tuple{Type{Base.IteratorsMD.CartesianIndex}, Tuple{Vararg{Int64, N<:Any}}}}, UInt64}` | 0 | 0 | 0 | 1 | N? |\r\n\r\n`jl_type_morespecific`:\r\nnone\r\n\r\n`type_match_`:\r\n\r\n| child | parent | morespecific | invariant | old result | new result | best |\r\n| ----- | ------ | ------------ | --------- | ---------- | ---------- | ---- |\r\n| `NTuple{#N<:Any, Int}` | `NTuple{#N<:Any, Integer}` | 0 | 0 | 0 | 1 | N |\r\n| `Tuple{Ptr{#T<:Any}, NTuple{#N<:Any, Int64}}` | `Tuple{Ptr{#T<:Any}, NTuple{#N<:Any, Integer}}` | 1 | 0 | 0 | 1 | N |\r\n\r\nNote that ~~in only one case does~~there are no cases where the result in current master seems to make more sense to me than the version here. I think there's some chance that, once working, this will fix some ambiguity and similar problems.\r\n"},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/140553540","html_url":"https://github.com/JuliaLang/julia/pull/11242#issuecomment-140553540","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/11242","id":140553540,"user":{"login":"timholy","id":1525481,"avatar_url":"https://avatars.githubusercontent.com/u/1525481?v=3","gravatar_id":"","url":"https://api.github.com/users/timholy","html_url":"https://github.com/timholy","followers_url":"https://api.github.com/users/timholy/followers","following_url":"https://api.github.com/users/timholy/following{/other_user}","gists_url":"https://api.github.com/users/timholy/gists{/gist_id}","starred_url":"https://api.github.com/users/timholy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timholy/subscriptions","organizations_url":"https://api.github.com/users/timholy/orgs","repos_url":"https://api.github.com/users/timholy/repos","events_url":"https://api.github.com/users/timholy/events{/privacy}","received_events_url":"https://api.github.com/users/timholy/received_events","type":"User","site_admin":false},"created_at":"2015-09-15T21:33:32Z","updated_at":"2015-09-15T21:33:32Z","body":"Thanks for clarifying. I guess the key issue is that `Vararg` currently makes little sense if it's not wrapped in a `Tuple`. So you and @carnaval are advancing the notion that we shouldn't even have it be an independent entity. I find it hard to disagree with this thinking.\r\n\r\nIf `Va` is type-equal to a Tuple, could we/would we still want to prevent `pfx <: Va`?\r\n"}}