diff --git a/src/struct.jl b/src/struct.jl index 7aaa54307..c96706d30 100644 --- a/src/struct.jl +++ b/src/struct.jl @@ -67,7 +67,7 @@ function decodetyp(typ::TypeT) end end -struct Struct +struct Struct <: Real juliatype::DataType v::Vector{StructElement} end @@ -108,6 +108,13 @@ function Base.setproperty!(s::Struct, name::Symbol, x) SymbolicUtils.term(setfield!, s, idx, x; type) end +function symbolic_getproperty(s, name::Symbol) + SymbolicUtils.term(getfield, s, name, type = Real) +end +function symbolic_getproperty(s::Union{Arr, Num}, name::Symbol) + wrap(symbolic_getproperty(unwrap(s), name)) +end + # We cannot precisely derive the type after `getfield` due to SU limitations, # so give up and just say Real. SymbolicUtils.promote_symtype(::typeof(getfield), ::Type{<:Struct}, _...) = Real