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

Improve inference for interpolated tuple parameters in stagedfunctions #10191

Closed
mbauman opened this issue Feb 13, 2015 · 3 comments
Closed

Improve inference for interpolated tuple parameters in stagedfunctions #10191

mbauman opened this issue Feb 13, 2015 · 3 comments

Comments

@mbauman
Copy link
Sponsor Member

mbauman commented Feb 13, 2015

Would it be possible easy to improve the inference here?

julia> immutable Foo{T} end

julia> stagedfunction bar{T}(x::Foo{T})
         return :(Foo{$T}())
       end
bar (generic function with 1 method)

julia> @code_warntype bar(Foo{(1,2)}())
Variables:
  x::Foo{(1,2)}

Body:
  begin
      return ((top(apply_type))(Foo,(1,2))::Type{_<:Foo{T}})()::Foo{T}
  end::Foo{T}

Cc @Keno. This seems like an extension of #9016 (which makes the inference for the normal function equivalent concrete).

@simonster
Copy link
Member

It seems like this works:

julia> stagedfunction bar{T}(x::Foo{T})
                return :($(Foo{T})())
              end
bar (generic function with 1 method)

julia> @code_warntype bar(Foo{(1,2)}())
Variables:
  x::Foo{(1,2)}

Body:
  begin 
      return $(Expr(:new, Foo{(1,2)}))
  end::Foo{(1,2)}

although it would be better if what you wrote worked as well.

@mbauman
Copy link
Sponsor Member Author

mbauman commented Feb 16, 2015

Thanks, Simon, that workaround does the trick perfectly.

mbauman added a commit to JuliaArrays/AxisArrays.jl that referenced this issue Feb 28, 2015
Requires JuliaLang/julia#10331. But I think it is also running into a MAX_TUPLE_LEN issue, which is messing up my workaround for JuliaLang/julia#10191.

Needs tests, too.
mbauman added a commit to JuliaArrays/AxisArrays.jl that referenced this issue Jun 2, 2015
Requires JuliaLang/julia#10331. But I think it is also running into a MAX_TUPLE_LEN issue, which is messing up my workaround for JuliaLang/julia#10191.

Needs tests, too.
@mbauman
Copy link
Sponsor Member Author

mbauman commented Apr 21, 2016

My original example is now fixed.

@mbauman mbauman closed this as completed Apr 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants