-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
improve isdefined precision for 0 field types #58220
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
base: master
Are you sure you want to change the base?
improve isdefined precision for 0 field types #58220
Conversation
Co-authored-by: Jeff Bezanson <jeff.bezanson@gmail.com>
Co-authored-by: Jeff Bezanson <jeff.bezanson@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about Tuple? Those can throw also
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That comment seems to be false still, as it throws when given a NamedTuple:
julia> Base.datatype_fieldcount(NamedTuple{<:Any, Tuple}.body)
ERROR: ArgumentError: type does not have a definite number of fields
Stacktrace:
[1] fieldcount
@ ./runtime_internals.jl:1155 [inlined]
[2] datatype_fieldcount(t::DataType)
@ Base ./runtime_internals.jl:1119
[3] top-level scope
@ REPL[5]:1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks like a bug in datatype_fieldcount
; the intent seems to be for it not to throw.
alternate to #58214.