I don’t understand what is going on with the code below (MWE): the first invocation of isequal
is false
, from then on it is true
. Running v0.6
.
struct MaybeParsed{T}
pos::Int
value::T
MaybeParsed{T}(pos) where {T} = new{T}(pos)
MaybeParsed{T}(pos, value::T) where {T} = new{T}(pos, value)
MaybeParsed(pos, value::T) where {T} = new{T}(pos, value)
end
function Base.isequal(x::MaybeParsed{Tx}, y::MaybeParsed{Ty}) where {Tx,Ty}
if isbits(Tx) && isbits(Ty)
(x.pos == y.pos) & ifelse(x.pos > 0, isequal(x.value, y.value), true)
else
x.pos == y.pos && (x.pos > 0 ? isequal(x.value, y.value) : true)
end
end
isequal(MaybeParsed{Int}(1), MaybeParsed{Int}(1)) # false
isequal(MaybeParsed{Int}(1), MaybeParsed{Int}(1)) # true