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

Bug Report: Type argument not specializing for closures #45257

Closed
schlichtanders opened this issue May 10, 2022 · 1 comment
Closed

Bug Report: Type argument not specializing for closures #45257

schlichtanders opened this issue May 10, 2022 · 1 comment

Comments

@schlichtanders
Copy link

According to the documentation it can happen, that julia does not specialize functions on Types (and same goes for Functions and Vararg, but I am focussing on Types here).

I think I found a case where Julia should naturally specialize, but does not do so: Creating closures with the type.

Here is an example of what I mean

myconvert(T, value) = T(value)

function outerfunc(type, value)
    innerfunc(x) = myconvert(type, x)
    innerfunc(value)
end
using Test
tostring(a) = "$a"
@inferred outerfunc(tostring, 1)
# "1"

@inferred outerfunc(Symbol, 1)
# ERROR: return type Symbol does not match inferred return type Any

Please correct me if this missing specialization is indeed an intended aspect of julia. It looks accidental to me.

Using Julia 1.7.1
julia> versioninfo()
Julia Version 1.7.1
Commit ac5cc99908 (2021-12-22 19:35 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-12.0.1 (ORCJIT, icelake-client)
@KristofferC
Copy link
Sponsor Member

Probably dup of #23618.

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

3 participants