Skip to content

Commit d36a5ef

Browse files
authored
Test for unbound args (#891)
* Test for unbound args * Two unbound args * Zero unbound args
1 parent 76ce2c5 commit d36a5ef

File tree

5 files changed

+13
-4
lines changed

5 files changed

+13
-4
lines changed

src/MVector.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# Some more advanced constructor-like functions
32
@inline zeros(::Type{MVector{N}}) where {N} = zeros(MVector{N,Float64})
43
@inline ones(::Type{MVector{N}}) where {N} = ones(MVector{N,Float64})

src/abstractarray.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ When `a` is an instance or a concrete type the element type `eltype(a)` is
127127
used. However, when `a` is a `UnionAll` type such as `SMatrix{2,2}`, the
128128
promoted type of `elements` is used instead.
129129
"""
130-
@inline function _construct_similar(a, s::Size, elements::NTuple{L,ET}) where {L,ET}
130+
@inline function _construct_similar(a, s::Size, elements::Tuple{ET,Vararg{ET,L}}) where {L,ET}
131131
similar_type(a, _eltype_or(a, ET), s)(elements)
132132
end
133133

src/matrix_multiply_add.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ istranspose(::TSize{<:Any,T}) where T = (T === :transpose)
193193
size(::TSize{S}) where S = S
194194
Size(::TSize{S}) where S = Size{S}()
195195
access_type(::TSize{<:Any,T}) where T = T
196-
Base.transpose(::TSize{S,:transpose}) where {S,T} = TSize{reverse(S),:any}()
197-
Base.transpose(::TSize{S,:any}) where {S,T} = TSize{reverse(S),:transpose}()
196+
Base.transpose(::TSize{S,:transpose}) where {S} = TSize{reverse(S),:any}()
197+
Base.transpose(::TSize{S,:any}) where {S} = TSize{reverse(S),:transpose}()
198198

199199
# Get the parent of transposed arrays, or the array itself if it has no parent
200200
# Different from Base.parent because we only want to get rid of Transpose and Adjoint

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ if TEST_GROUP ∈ ["", "all", "group-A"]
4646
end
4747

4848
addtests("ambiguities.jl")
49+
addtests("unbound_args.jl")
4950
addtests("custom_types.jl")
5051
addtests("convert.jl")
5152
addtests("core.jl")

test/unbound_args.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
# Some unbound_args are hard to avoid, e.g. `SVector{N}(::NTuple{N,T})`
3+
# if `N == 0`, then `T` is unbound. We could disallow calling
4+
# `SVector{0}(())`, but throwing a `T not defined` error seems benign.
5+
# Working around this, e.g. with `SVector{N}(::Tuple{T,Vararg{T,Nm1}}) where {N,T,Nm1}`
6+
# and then asserting `N == Nm1+1` also seems reasonable (the compiler should eliminate the assert).
7+
const allowable_unbound_args = 0
8+
9+
@test length(detect_unbound_args(StaticArrays)) <= allowable_unbound_args

0 commit comments

Comments
 (0)