Skip to content
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

use getfield instead of getproperty #20

Closed
goretkin opened this issue Jul 29, 2021 · 1 comment
Closed

use getfield instead of getproperty #20

goretkin opened this issue Jul 29, 2021 · 1 comment

Comments

@goretkin
Copy link

The macros generate code that access fields like x.field, e.g.:

https://github.com/andrewcooke/AutoHashEquals.jl/blob/f643bdd354ffea0f3f7df3c23c8a965768e9ef0c/src/AutoHashEquals.jl#L31

but I think it should be replaced with getfield(x, :field), since some types may overload getproperty. Here is an obnoxious example:

julia> @auto_hash_equals struct Foo{T}
       _::T
       end

julia> ==(Foo(1), Foo(1))
true

julia> Base.getproperty(x::Foo, f::Symbol) = rand() # horrible but not "illegal"

julia> ==(Foo(1), Foo(1))
false
goretkin added a commit to goretkin/AutoHashEquals.jl that referenced this issue Jul 30, 2021
`Tuple` already handles `missing`

This also addresses in part
JuliaServices#20

(`hash` still uses `getproperty`)
goretkin added a commit to goretkin/AutoHashEquals.jl that referenced this issue Jul 30, 2021
JuliaServices#20

"use getfield instead of getproperty"
goretkin added a commit to goretkin/AutoHashEquals.jl that referenced this issue Jul 30, 2021
@gafter
Copy link
Member

gafter commented Aug 18, 2023

Current implementation uses getfield.

@gafter gafter closed this as completed Aug 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants