Skip to content

Commit

Permalink
make @SVector and @SMatrix calls default to Float64 to match Ba…
Browse files Browse the repository at this point in the history
…se (#1165)

* make `@SVector` and `@SMatrix` calls default to `Float64` to match Base

This makes calls to `zeros`, `ones`, `rand`, and friend default to `Float64`
similar to Base. This can be a source of type instability when used
in the single argument version, and it is not transparent as to why.
Making `Float64` the default eliminates this source of error for the user.

Closes: #1164

* bump to v1.5.26
  • Loading branch information
sjkelly authored Jun 10, 2023
1 parent d9d54bd commit 376efdb
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "StaticArrays"
uuid = "90137ffa-7385-5640-81b9-e52037218182"
version = "1.5.25"
version = "1.5.26"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
2 changes: 1 addition & 1 deletion src/SMatrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function static_matrix_gen(::Type{SM}, @nospecialize(ex), mod::Module) where {SM
f = ex.args[1]
if f === :zeros || f === :ones || f === :rand || f === :randn || f === :randexp
if length(ex.args) == 3
return :($f($SM{$(escall(ex.args[2:3])...)}))
return :($f($SM{$(escall(ex.args[2:3])...), Float64})) # default to Float64 like Base
elseif length(ex.args) == 4
return :($f($SM{$(escall(ex.args[[3,4,2]])...)}))
else
Expand Down
2 changes: 1 addition & 1 deletion src/SVector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function static_vector_gen(::Type{SV}, @nospecialize(ex), mod::Module) where {SV
f = ex.args[1]
if f === :zeros || f === :ones || f === :rand || f === :randn || f === :randexp
if length(ex.args) == 2
return :($f($SV{$(esc(ex.args[2]))}))
return :($f($SV{$(esc(ex.args[2])), Float64})) # default to Float64 like Base
elseif length(ex.args) == 3
return :($f($SV{$(escall(ex.args[3:-1:2])...)}))
else
Expand Down

2 comments on commit 376efdb

@mateuszbaran
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/85275

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.5.26 -m "<description of version>" 376efdbf3bbab34d624dfbee88a9ae83282f0718
git push origin v1.5.26

Please sign in to comment.