@@ -203,7 +203,7 @@ using StaticArrays, Test, LinearAlgebra
203
203
@test @inferred (convert (AbstractArray{Float64}, diag)) isa Diagonal{Float64,SVector{2 ,Float64}}
204
204
@test convert (AbstractArray{Float64}, diag) == diag
205
205
# The following cases currently convert the SMatrix into an MMatrix, because
206
- # the constructor in Base invokes `similar`, rather than `convert`, on the static
206
+ # the constructor in Base invokes `similar`, rather than `convert`, on the static
207
207
# array. This was fixed in https://github.com/JuliaLang/julia/pull/40831; so should
208
208
# work from Julia v1.8.0-DEV.55
209
209
trans = Transpose (SVector (1 ,2 ))
@@ -219,6 +219,16 @@ using StaticArrays, Test, LinearAlgebra
219
219
unitlotri = UnitLowerTriangular (SA[1 0 ; 2 1 ])
220
220
@test_was_once_broken v " 1.8.0-DEV.55" @inferred (convert (AbstractArray{Float64}, unitlotri)) isa UnitLowerTriangular{Float64,SMatrix{2 ,2 ,Float64,4 }}
221
221
end
222
+
223
+ @testset " type inference in length" begin
224
+ s1 = SA[1 ,2 ];
225
+ s2 = SA[1 ,2 ,3 ];
226
+ v = [s1, s2];
227
+ f (v, i) = length (v[i]);
228
+ for i in 1 : 2
229
+ @test (@inferred f (v, i)) == length (v[i])
230
+ end
231
+ end
222
232
end
223
233
224
234
@testset " permutedims" begin
318
328
@test Base. rest (x) == x
319
329
a, b... = x
320
330
@test b == SA[2 , 3 ]
321
-
331
+
322
332
x = SA[1 2 ; 3 4 ]
323
333
@test Base. rest (x) == vec (x)
324
334
a, b... = x
@@ -327,14 +337,14 @@ end
327
337
a, b... = SA[1 ]
328
338
@test b == []
329
339
@test b isa SVector{0 }
330
-
340
+
331
341
for (Vec, Mat) in [(MVector, MMatrix), (SizedVector, SizedMatrix)]
332
342
x = Vec (1 , 2 , 3 )
333
343
@test Base. rest (x) == x
334
344
@test pointer (Base. rest (x)) != pointer (x)
335
345
a, b... = x
336
346
@test b == Vec (2 , 3 )
337
-
347
+
338
348
x = Mat {2,2} (1 , 2 , 3 , 4 )
339
349
@test Base. rest (x) == vec (x)
340
350
@test pointer (Base. rest (x)) != pointer (x)
0 commit comments