Skip to content

Commit

Permalink
fix struct type for number (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
GiggleLiu authored Sep 21, 2023
1 parent 9cca137 commit 47c4691
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/StructTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ Similarly for serializing, `Float64(x::T)` will first be called before serializi
"""
struct NumberType <: InterfaceType end

StructType(::Type{<:Number}) = NumberType()
StructType(::Type{<:Real}) = NumberType()
numbertype(::Type{T}) where {T <: Real} = T
numbertype(x) = Float64

Expand Down
6 changes: 5 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -855,4 +855,8 @@ StructTypes.@register_struct_subtype Vehicle2 Truck2
@test StructTypes.lowertype(Car2) === typeof(nt)
@test typeof(car) == Car2
@test car.make == "Mercedes-Benz"
end
end

@testset "struct type on complex" begin
@test StructTypes.StructType(ComplexF64) == StructTypes.Struct()
end

0 comments on commit 47c4691

Please sign in to comment.