Commit 0452a8c
committed
Add an explicit JSONValue.opEquals method to fix taggedalgebraic support
The original `JSONValue` implementation relied on `alias payload this`
for equality comparisons. This breaks with taggedalgebraic >= 0.11.0,
with some of the failure cases emerging for all DMD versions, and others
only for DMD >= 2.086.0.
The former breakages seem to be related to changes in the implementation
of `TaggedAlgebraic.opEquals`, while the cases that emerge only for DMD
>= 2.086.0 appear to be related to a breaking change to prefer generated
struct `opEquals` over aliased `opEquals`:
https://dlang.org/changelog/2.086.0.html#alias_this_opEquals
The aliased `opEquals` also fails in a number of array comparison cases,
regardless of taggedalgebraic or compiler version.
This patch fixes all these issues by implementing an explicit `opEquals`
method. As with the previous implementation this relies only on payload
and not on location, which appears to be in keeping with the rest of the
library.
We need to special case when `null` input is provided, as this could be
ambiguous as to which `PayloadUnion` entry to compare to. Similarly, we
special-case comparison of `JSONValue` to `JSONValue` in order to ensure
that comparison is correctly based on their respective payloads. In all
other cases, a direct comparison of input to payload appears sufficient.
Fixes #44 (*).
Fixes #48.
(* Proof that the DMD >= 2.086.0 issues are fixed should be visible via
the `dmd-beta` CI build, which should now pass.)1 parent fc171c0 commit 0452a8c
1 file changed
Lines changed: 30 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
102 | 126 | | |
103 | 127 | | |
104 | 128 | | |
| |||
149 | 173 | | |
150 | 174 | | |
151 | 175 | | |
152 | | - | |
153 | 176 | | |
154 | | - | |
| 177 | + | |
155 | 178 | | |
156 | 179 | | |
157 | 180 | | |
| |||
164 | 187 | | |
165 | 188 | | |
166 | 189 | | |
167 | | - | |
168 | 190 | | |
169 | | - | |
| 191 | + | |
170 | 192 | | |
171 | | - | |
172 | | - | |
| 193 | + | |
| 194 | + | |
173 | 195 | | |
174 | 196 | | |
175 | 197 | | |
176 | 198 | | |
177 | 199 | | |
178 | 200 | | |
179 | | - | |
180 | 201 | | |
181 | 202 | | |
182 | | - | |
| 203 | + | |
183 | 204 | | |
184 | 205 | | |
185 | 206 | | |
186 | 207 | | |
187 | 208 | | |
188 | | - | |
| 209 | + | |
189 | 210 | | |
190 | 211 | | |
191 | 212 | | |
| |||
0 commit comments