Commit da5b844
committed
Fix enum hash equality
Protobuf::Enum delegates methods to Fixnum, which has a custom hash
equality method (`eql?`). This causes enum values to be equivalent when
using `==`, `===`, `equals?`, but not `eql?`**:
2.3.7 :002 > Test::EnumTestType::ZERO.eql?(::Test::EnumTestType::ZERO)
=> false
However, they are equilvalent to their tag value:
2.3.7 :002 > Test::EnumTestType::ZERO.eql?(::Test::EnumTestType::ZERO.tag)
=> true
Use the hash equality implementation from Object#eql?, which is
equivalent to == instead.
**The implementation changed in Ruby 2.5, so this only affects Ruby
versions less than v2.5.1 parent ac12151 commit da5b844
2 files changed
Lines changed: 33 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
271 | 271 | | |
272 | 272 | | |
273 | 273 | | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
274 | 293 | | |
275 | 294 | | |
276 | 295 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
271 | 285 | | |
272 | 286 | | |
273 | 287 | | |
| |||
0 commit comments