-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
fieldtype
returns too-general type
#18037
Comments
backport is pending #17953 |
@vtjnash That went the other way around than I expected. I expected 0.6 to return the more specific type, not 0.5 to return a less specific type. Put differently: How can I access the specific type information that is output by |
ok, I read that backwards: probably /broken/ by #17953 |
Here is a work-around (it's not pretty): @generated function ft{T, i}(x::T, ::Type{Val{i}})
:($(fieldtype(x, i)))
end
function f{T}(x::T)
@show T
@show [fieldtype(T, i) for i in 1:nfields(T)]
@show [ft(x, Val{i}) for i in 1:nfields(T)]
nothing
end
f(((nothing, nothing), (nothing, 4))) This outputs
|
yes, the |
the getfield_tfunc was missing a test for whether the fields were all equivalent before concluding that the result type was exact fixes the fix JuliaLang#17953 fix JuliaLang#18037
In the function below, Julia returns
Any
for the field type of a tuple, although Julia actually knows that the field has typeInt
:I see the output:
This is different from Julia 0.5, which returns the fully specific type:
#12793 might be related.
The text was updated successfully, but these errors were encountered: