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
4 changes: 4 additions & 0 deletions Compiler/src/tfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,10 @@ end
return Const(true)
end
end
# datatype_fieldcount is what `fieldcount` uses internally
# and returns nothing (!==0) for non-definite field counts.
elseif datatype_fieldcount(a1) === 0
return Const(false)
end
elseif isa(a1, Union)
# Results can only be `Const` or `Bool`
Expand Down
1 change: 1 addition & 0 deletions Compiler/test/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,7 @@ let isdefined_tfunc(@nospecialize xs...) =
@test isdefined_tfunc(Union{UnionIsdefinedA,UnionIsdefinedB}, Const(:x)) === Const(true)
@test isdefined_tfunc(Union{UnionIsdefinedA,UnionIsdefinedB}, Const(:y)) === Const(false)
@test isdefined_tfunc(Union{UnionIsdefinedA,Nothing}, Const(:x)) === Bool
@test isdefined_tfunc(Nothing, Any) === Const(false)
end

# https://github.com/aviatesk/JET.jl/issues/379
Expand Down
2 changes: 1 addition & 1 deletion base/runtime_internals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,7 @@ function datatype_fieldcount(t::DataType)
return length(names)
end
if types isa DataType && types <: Tuple
return fieldcount(types)
return datatype_fieldcount(types)
end
return nothing
elseif isabstracttype(t)
Expand Down