Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1003,12 +1003,15 @@ function datatype_fieldcount(t::DataType)
return fieldcount(types)
end
return nothing
elseif isabstracttype(t) || (t.name === Tuple.name && isvatuple(t))
elseif isabstracttype(t)
return nothing
end
if isdefined(t, :types)
if t.name === Tuple.name
isvatuple(t) && return nothing
return length(t.types)
end
# Equivalent to length(t.types), but `t.types` is lazy and we do not want
# to be forced to compute it.
return length(t.name.names)
end

Expand Down
3 changes: 3 additions & 0 deletions test/compiler/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5725,3 +5725,6 @@ let interp = CachedConditionalInterp();
result.linfo.def.name === :func_cached_conditional
end == 1
end

# fieldcount on `Tuple` should constant fold, even though `.fields` not const
@test fully_eliminated(Base.fieldcount, Tuple{Type{Tuple{Nothing, Int, Int}}})