Closed davishmcclurg closed 8 months ago
The keys used to collect property defaults are mutable hashes, which causes weird hash table problems when they're modified (#hash no longer matches even though they have the same #object_id). Explained here: https://docs.ruby-lang.org/en/3.3/Hash.html#class-Hash-label-Modifying+an+Active+Hash+Key
#hash
#object_id
I think this problem got covered up a bit because it requires more than 8 keys for values to be dropped.
compare_by_identity fixes things by just using #object_id to compare hash keys. It stays consistent after the hash key is mutated.
compare_by_identity
From the docs:
Note: this requirement does not apply if the Hash uses compare_by_identity since comparison will then rely on the keys' object id instead of hash and eql?.
hash
eql?
Fixes: https://github.com/davishmcclurg/json_schemer/issues/179
The keys used to collect property defaults are mutable hashes, which causes weird hash table problems when they're modified (
#hash
no longer matches even though they have the same#object_id
). Explained here: https://docs.ruby-lang.org/en/3.3/Hash.html#class-Hash-label-Modifying+an+Active+Hash+KeyI think this problem got covered up a bit because it requires more than 8 keys for values to be dropped.
compare_by_identity
fixes things by just using#object_id
to compare hash keys. It stays consistent after the hash key is mutated.From the docs:
Fixes: https://github.com/davishmcclurg/json_schemer/issues/179