{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/10880","repository_url":"https://api.github.com/repos/JuliaLang/julia","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/10880/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/10880/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/10880/events","html_url":"https://github.com/JuliaLang/julia/issues/10880","id":69321945,"number":10880,"title":"\"Regression\" in typeinf when concatenate two tuple types","user":{"login":"yuyichao","id":712232,"avatar_url":"https://avatars.githubusercontent.com/u/712232?v=3","gravatar_id":"","url":"https://api.github.com/users/yuyichao","html_url":"https://github.com/yuyichao","followers_url":"https://api.github.com/users/yuyichao/followers","following_url":"https://api.github.com/users/yuyichao/following{/other_user}","gists_url":"https://api.github.com/users/yuyichao/gists{/gist_id}","starred_url":"https://api.github.com/users/yuyichao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuyichao/subscriptions","organizations_url":"https://api.github.com/users/yuyichao/orgs","repos_url":"https://api.github.com/users/yuyichao/repos","events_url":"https://api.github.com/users/yuyichao/events{/privacy}","received_events_url":"https://api.github.com/users/yuyichao/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/JuliaLang/julia/labels/types%20and%20dispatch","name":"types and dispatch","color":"fef2c0"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":19,"created_at":"2015-04-18T16:01:03Z","updated_at":"2016-03-04T14:06:35Z","closed_at":null,"body":"I was under the impression that #10380 can make type inference easier for functions that use tuple types. However, when I want to get the type of the concatenation of two tuples, I couldn't get good type inference anymore. (It is also very likely that I'm just being stupid and don't know the correct way to do it in the new version.)\r\n\r\nThe code I am using can be simplified to\r\n\r\n```julia\r\nif isa((Int,), Type)\r\n    function cat_tt(a, b)\r\n        tuple(a..., b...)\r\n    end\r\nelse\r\n    function cat_tt(a, b)\r\n        Tuple{a.parameters..., b.parameters...}\r\n    end\r\nend\r\n\r\nprintln(cat_tt(typeof((1, 2)), typeof((1, 2))))\r\nprintln(@code_typed cat_tt(typeof((1, 2)), typeof((1, 2))))\r\n```\r\n\r\nBefore the change of the tuple type, the output is\r\n```julia\r\n(Int64,Int64,Int64,Int64)\r\nAny[:($(Expr(:lambda, Any[:a,:b], Any[Any[],Any[Any[:a,Type{(Int64,Int64)},0],Any[:b,Type{(Int64,Int64)},0]],Any[],Any[]], :(begin  # /home/yuyichao/tmp/julia_cat_tt.jl, line 5:\r\n        return (Int64,Int64,Int64,Int64)\r\n    end::(Type{Int64},Type{Int64},Type{Int64},Type{Int64})))))]\r\n```\r\n\r\nAfter the change\r\n```jl\r\nTuple{Int64,Int64,Int64,Int64}\r\nAny[:($(Expr(:lambda, Any[:a,:b], Any[Any[],Any[Any[:a,Type{Tuple{Int64,Int64}},0],Any[:b,Type{Tuple{Int64,Int64}},0]],Any[],Any[]], :(begin  # /home/yuyichao/tmp/julia_cat_tt.jl, line 9:\r\n        return (top(_apply))(call,top(apply_type),(top(tuple))(Tuple)::Tuple{DataType},(top(getfield))(a::Type{Tuple{Int64,Int64}},:parameters)::SimpleVector,(top(getfield))(b::Type{Tuple{Int64,Int64}},:parameters)::SimpleVector)::ANY\r\n    end::ANY))))]\r\n```\r\n\r\nMaybe there's better ways to do this.\r\n"},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/192295169","html_url":"https://github.com/JuliaLang/julia/issues/10880#issuecomment-192295169","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/10880","id":192295169,"user":{"login":"mbauman","id":154641,"avatar_url":"https://avatars.githubusercontent.com/u/154641?v=3","gravatar_id":"","url":"https://api.github.com/users/mbauman","html_url":"https://github.com/mbauman","followers_url":"https://api.github.com/users/mbauman/followers","following_url":"https://api.github.com/users/mbauman/following{/other_user}","gists_url":"https://api.github.com/users/mbauman/gists{/gist_id}","starred_url":"https://api.github.com/users/mbauman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbauman/subscriptions","organizations_url":"https://api.github.com/users/mbauman/orgs","repos_url":"https://api.github.com/users/mbauman/repos","events_url":"https://api.github.com/users/mbauman/events{/privacy}","received_events_url":"https://api.github.com/users/mbauman/received_events","type":"User","site_admin":false},"created_at":"2016-03-04T14:06:35Z","updated_at":"2016-03-04T14:06:35Z","body":"Ah, this is interesting. I, too, had been thrown off by the function not getting specialized at the REPL - SubArray's trait computation should be pure.\r\n\r\nAs I understand it, the pure optimization is only used while running inference on another function because it can be precomputed and inlined there. It only isn't specialized at global scope and with type-unstable inputs. "}}