-
-
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
improve effects of objectid
and getindex(::Dict)
#49447
improve effects of objectid
and getindex(::Dict)
#49447
Conversation
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.
Add a test case that exercises the improved effects.
tests added. |
base/reflection.jl
Outdated
function objectid(x) | ||
# objectid is foldable iff it isn't a pointer. | ||
# Sring, Symbol, Module, and DataType are safe because jl_objectid for them works by value. | ||
if !ismutable(x) || x isa String || x isa Symbol || x isa Module |
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.
ismutable
doesn't feel right.
Consider
struct F
v::Vector
end
That's not mutable but I don't think objectid is foldable for it.
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.
Module
I think also gets different objectid
in different sessions?
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.
Module
is hashed by name and parent name as of #47749. Good catch on F
. I think the right test is valid type param
Build on aarch64-darwin is failing likely due to a |
getindex(Dict)
and objectid
objectid
and getindex(::Dict)
d8c0deb
to
a582220
Compare
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.
Added some changes on my own. Should be ready to go if CI goes successfully.
As pointed out in #51594 (comment), this is necessary for the assertion added in #49447 to be valid.
With these changes (and #49260) we can now tab complete through dictionaries.EDIT: It's not necessary.The
objectid
improvement is needed forDict{Symbol, T}
sincehash(Symbol)
callsobjectid
.