-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Description
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)
endusing Test
tostring(a) = "$a"
@inferred outerfunc(tostring, 1)
# "1"
@inferred outerfunc(Symbol, 1)
# ERROR: return type Symbol does not match inferred return type AnyPlease 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)
Metadata
Metadata
Assignees
Labels
No labels