Skip to content

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

oscardssmith
Copy link
Member

alternate to #58214.

@oscardssmith oscardssmith added performance Must go faster compiler:inference Type inference labels Apr 24, 2025
Co-authored-by: Jeff Bezanson <jeff.bezanson@gmail.com>
Co-authored-by: Jeff Bezanson <jeff.bezanson@gmail.com>
Copy link
Member

@vtjnash vtjnash left a 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
Copy link
Member

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

Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:inference Type inference performance Must go faster
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants