Skip to content

Commit b040cc3

Browse files
nsajkomateuszbaranChrisRackauckas
authored
fix return type inference failure for Size (#21)
* fix return type inference failure for `Size` The `ntuple` function has a method that takes a `Val` argument instead of an `Integer` as the second parameter. Using it helps Julia with type inference in some cases, in particular when the value of the argument is known when the code is being compiled and when it is greater than ten (with current Julia versions). With Julia master, the following code demonstrates the fixed issue. It errors with StaticArraysCore master, but passes with this commit: ```julia using Test, StaticArraysCore @inferred Size(Array{Float64, 11}) ``` * Update src/StaticArraysCore.jl Co-authored-by: Christopher Rackauckas <accounts@chrisrackauckas.com> * bump patch version to 1.4.1 --------- Co-authored-by: Mateusz Baran <mateuszbaran89@gmail.com> Co-authored-by: Christopher Rackauckas <accounts@chrisrackauckas.com>
1 parent 275f63c commit b040cc3

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "StaticArraysCore"
22
uuid = "1e83bf80-4336-4d27-bf5d-d5a4f845583c"
3-
version = "1.4.0"
3+
version = "1.4.1"
44

55
[compat]
66
julia = "1.6"

src/StaticArraysCore.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,6 @@ Size(a::T) where {T<:AbstractArray} = Size(T)
491491
Size(::Type{SA}) where {SA <: StaticArray} = missing_size_error(SA)
492492
Size(::Type{SA}) where {SA <: StaticArray{S}} where {S<:Tuple} = @isdefined(S) ? Size(S) : missing_size_error(SA)
493493

494-
Base.@pure Size(::Type{<:AbstractArray{<:Any, N}}) where {N} = Size(ntuple(_ -> Dynamic(), N))
494+
Size(::Type{<:AbstractArray{<:Any, N}}) where {N} = Size(ntuple(_ -> Dynamic(), Val(N)))
495495

496496
end # module

0 commit comments

Comments
 (0)