Commit eff51e4
committed
explicitly use
Fixes bug where `true` was incorrectly returned for `Dict.equal?` when
the 1st argument was a subset of the 2nd argument.
e.g:
```elixir
iex> h1 = HashDict.new(foo: 1, bar: 2)
iex> h2 = HashDict.new(foo: 1, bar: 2, baz: 3)
iex> Dict.equal?(h1, h2)
true # OOPS
iex> Dict.equal?(h2, h1)
false # works as expected other way round
```
The code to check equality was checking size (incorrectly), and then
checking to see if every element in the first dict was present in the
2nd.
However, `size` was being used instead of `Dict.size`. This ended up
calling `Kernel.size` instead - and would always return `true`
regardless of whever the actual size of the `Dict` arguments were the
same or not.Dict.size rather than just size in equal?
1 parent ea5df22 commit eff51e4
2 files changed
+6
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
| 102 | + | |
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
| 125 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
217 | 221 | | |
218 | 222 | | |
219 | 223 | | |
| |||
0 commit comments