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

more tuple/apply inference fun #30380

Closed
jrevels opened this issue Dec 13, 2018 · 1 comment · Fixed by #30385
Closed

more tuple/apply inference fun #30380

jrevels opened this issue Dec 13, 2018 · 1 comment · Fixed by #30385

Comments

@jrevels
Copy link
Member

jrevels commented Dec 13, 2018

julia> g(args...) = h(args...)
g (generic function with 1 method)

julia> h(f, args...) = f(args...)
h (generic function with 1 method)

julia> f(T, y) = g(getfield, g(tuple, T, y), 1)
f (generic function with 1 method)

julia> @code_typed f(AbstractFloat, 1)
CodeInfo(
1%1 = Main.tuple::Const(tuple, false)
│   %2 = (%1)(T, y)::Tuple{DataType,Int64}%3 = Main.getfield::Const(getfield, false)
│   %4 = (%3)(%2, 1)::DataType
└──      return %4
) => DataType

julia> k(T, y) = getfield(tuple(T, y), 1)
k (generic function with 1 method)

julia> @code_typed k(AbstractFloat, 1)
CodeInfo(
1return AbstractFloat
) => Type{AbstractFloat}

julia> versioninfo()
Julia Version 1.1.0-DEV.843
Commit a0bc8fdb75 (2018-12-08 18:35 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin17.5.0)
  CPU: Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, skylake)

MWE from Cassette; I'd like the output of f(...) to be inferred as Type{AbstractFloat} (the same as k(...))

@jrevels
Copy link
Member Author

jrevels commented Dec 13, 2018

To be more clear:

julia> @code_typed optimize=false f(AbstractFloat, 1)
CodeInfo(
1%1 = (Main.g)(Main.tuple, T, y)::Tuple{DataType,Int64}%2 = (Main.g)(Main.getfield, %1, 1)::DataType
└──      return %2
) => DataType

julia> @code_typed optimize=false k(AbstractFloat, 1)
CodeInfo(
1%1 = (Main.tuple)(T, y)::PartialTuple(Tuple{DataType,Int64}, Any[Const(AbstractFloat, false), Int64])
│   %2 = (Main.getfield)(%1, 1)::Const(AbstractFloat, false)
└──      return %2
) => Type{AbstractFloat}

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

Successfully merging a pull request may close this issue.

1 participant