Closed goretkin closed 1 year ago
The macros generate code that access fields like x.field, e.g.:
x.field
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:
getfield(x, :field)
getproperty
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
Current implementation uses getfield.
getfield
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 overloadgetproperty
. Here is an obnoxious example: