Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions src/MutatePlainDataArray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,26 @@ function field_offset_type_impl(::Type{T}, ::Val{S}) where {T,S}
if !isstructtype(T)
error("$T is not struct type.")
end
if S isa Symbol
fs = fieldnames(T)
findex = findfirst(==(S), fs)
if isnothing(findex)
if VERSION ≥ v"1.12"
throw(FieldError(T, S))
else
error("Cannot find field $S in type $T.")
@static if VERSION ≥ v"1.13"
fieldoffset(T, S), fieldtype(T, S)
else
if S isa Symbol
fs = fieldnames(T)
findex = findfirst(==(S), fs)
if isnothing(findex)
if VERSION ≥ v"1.12"
throw(FieldError(T, S))
else
error("Cannot find field $S in type $T.")
end
end
elseif S isa Integer
findex = S
else
error("$S is not a symbol or an integer.")
end
elseif S isa Integer
findex = S
else
error("$S is not a symbol or an integer.")
fieldoffset(T, findex), fieldtype(T, findex)
end

fieldoffset(T, findex), fieldtype(T, findex)
end

"""
Expand Down
Loading