-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Open
Labels
docsThis change adds or pertains to documentationThis change adds or pertains to documentation
Description
julia> struct Foo
i::Ref{Int}
end
julia> f = Foo(Ref(0))
Foo(Base.RefValue{Int64}(0))
julia> g(x) = x.i[]
g (generic function with 1 method)
julia> @code_warntype g(f)
Variables
#self#::Core.Const(g)
x::Foo
Body::Any
1 ─ %1 = Base.getproperty(x, :i)::Ref{Int64}
│ %2 = Base.getindex(%1)::Any
└── return %2
julia> versioninfo()
Julia Version 1.6.0-DEV.1227
Commit 86bbe0941c (2020-10-15 00:29 UTC)
I thought this would infer the return type as Int, but it only manages Any. Am I doing something wrong, or is this expected? Is there a situation where the dereference can return something other than Int?
Metadata
Metadata
Assignees
Labels
docsThis change adds or pertains to documentationThis change adds or pertains to documentation