Skip to content

Commit c946134

Browse files
authored
Merge pull request #519 from JuliaArrays/teh/fix_452
Fix helpful warning on Julia 1.x
2 parents 552bc75 + bfa5536 commit c946134

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/traits.jl

+5-3
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ end
6868

6969
Base.show(io::IO, ::Size{S}) where {S} = print(io, "Size", S)
7070

71-
Size(a::T) where {T<:AbstractArray} = Size(T)
72-
function Size(::Type{SA}) where {SA <: StaticArray} # A nice, default error message for when S not defined
71+
function missing_size_error(::Type{SA}) where SA
7372
error("""
7473
The size of type `$SA` is not known.
7574
@@ -83,7 +82,10 @@ function Size(::Type{SA}) where {SA <: StaticArray} # A nice, default error mess
8382
SMatrix{3,3}(m) # correct - size is inferrable
8483
""")
8584
end
86-
Size(::Type{SA}) where {SA <: StaticArray{S}} where {S<:Tuple} = Size(S) # S defined as a Tuple
85+
86+
Size(a::T) where {T<:AbstractArray} = Size(T)
87+
Size(::Type{SA}) where {SA <: StaticArray} = missing_size_error(SA)
88+
Size(::Type{SA}) where {SA <: StaticArray{S}} where {S<:Tuple} = @isdefined(S) ? Size(S) : missing_size_error(SA)
8789
@pure Size(::Type{<:AbstractArray{<:Any, N}}) where {N} = Size(ntuple(_ -> Dynamic(), N))
8890

8991
struct Length{L}

test/core.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@
138138
try
139139
convert(SVector, [1,2,3])
140140
catch err
141-
@test_broken isa(err, ErrorException)
142-
@test_broken startswith(err.msg, "The size of type `StaticArrays.SArray{Tuple{S},T,1,S} where T where S` is not known.")
141+
@test isa(err, ErrorException)
142+
@test startswith(err.msg, "The size of type")
143143
end
144144
end
145145
@test_throws Exception Length{2.5}()

0 commit comments

Comments
 (0)