Skip to content

Commit 9a8c427

Browse files
authored
Merge pull request #15 from SciML/staticuint
add static(::UInt) methods
2 parents bf61620 + 0afdc8e commit 9a8c427

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Static"
22
uuid = "aedffcd0-7271-4cad-89d0-dc628f76c6d3"
33
authors = ["chriselrod", "ChrisRackauckas", "Tokazama"]
4-
version = "0.3.0"
4+
version = "0.3.1"
55

66
[deps]
77
IfElse = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173"

src/Static.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,11 @@ static
7070
@aggressive_constprop static(x::X) where {X} = ifelse(is_static(X), identity, _no_static_type)(x)
7171
@aggressive_constprop static(x::Int) = StaticInt(x)
7272
@aggressive_constprop static(x::Union{Int8,UInt8,Int16,UInt16}) = StaticInt(x % Int)
73-
if sizeof(Int) == 8
73+
@static if sizeof(Int) == 8
7474
@aggressive_constprop static(x::Union{Int32,UInt32}) = StaticInt(x % Int)
75+
@aggressive_constprop static(x::UInt64) = StaticInt(Int(x))
76+
else
77+
@aggressive_constprop static(x::UInt32) = StaticInt(Int(x))
7578
end
7679
@aggressive_constprop static(x::Float64) = StaticFloat64(x)
7780
@aggressive_constprop static(x::Bool) = StaticBool(x)

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ using Test
55
Aqua.test_all(Static)
66

77
@testset "StaticInt" begin
8-
@test StaticInt(UInt(8)) === StaticInt{8}()
8+
@test static(UInt(8)) === StaticInt(UInt(8)) === StaticInt{8}()
99
@test iszero(StaticInt(0))
1010
@test !iszero(StaticInt(1))
1111
@test !isone(StaticInt(0))

0 commit comments

Comments
 (0)