@@ -871,10 +871,12 @@ end
871
871
index_to_dict (i:: Integer ) = Dict (:type => " integer" , :value => i)
872
872
index_to_dict (r:: UnitRange ) = Dict (:type => " unitrange" , :first => first (r), :last => last (r))
873
873
index_to_dict (:: Colon ) = Dict (:type => " colon" )
874
- index_to_dict (s:: ConcretizedSlice{T,R} ) where {T,R} = Dict (:type => " concretized_slice" , :range => repr (s. range))
874
+ index_to_dict (s:: ConcretizedSlice{T,Base.OneTo{I}} ) where {T,I} = Dict (:type => " concretized_slice" , :oneto => s. range. stop)
875
+ index_to_dict (:: ConcretizedSlice{T,R} ) where {T,R} = error (" ConcretizedSlice with range type $(R) not supported" )
875
876
index_to_dict (t:: Tuple ) = Dict (:type => " tuple" , :values => [index_to_dict (x) for x in t])
876
877
877
878
function dict_to_index (dict)
879
+ # conversion needed because of the same reason as in dict_to_optic
878
880
dict = Dict (Symbol (k) => v for (k, v) in dict)
879
881
if dict[:type ] == " integer"
880
882
return dict[:value ]
@@ -883,9 +885,11 @@ function dict_to_index(dict)
883
885
elseif dict[:type ] == " colon"
884
886
return Colon ()
885
887
elseif dict[:type ] == " concretized_slice"
886
- return ConcretizedSlice (eval (Meta . parse (dict[:range ])))
888
+ return ConcretizedSlice (Base . Slice (Base . OneTo (dict[:oneto ])))
887
889
elseif dict[:type ] == " tuple"
888
890
return tuple (map (dict_to_index, dict[:values ])... )
891
+ else
892
+ error (" Unknown index type: $(dict[:type ]) " )
889
893
end
890
894
end
891
895
@@ -909,6 +913,8 @@ function dict_to_optic(dict)
909
913
return PropertyLens {Symbol(dict[:field])} ()
910
914
elseif dict[:type ] == " composed"
911
915
return dict_to_optic (dict[:outer ]) ∘ dict_to_optic (dict[:inner ])
916
+ else
917
+ error (" Unknown optic type: $(dict[:type ]) " )
912
918
end
913
919
end
914
920
0 commit comments