From 0afdc8ee95d7b8fcb1c34951ef36709132ef61ad Mon Sep 17 00:00:00 2001 From: Chris Elrod Date: Mon, 30 Aug 2021 09:48:44 -0400 Subject: [PATCH] add static(::UInt) methods --- Project.toml | 2 +- src/Static.jl | 5 ++++- test/runtests.jl | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index ae7e93b..7fa71be 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Static" uuid = "aedffcd0-7271-4cad-89d0-dc628f76c6d3" authors = ["chriselrod", "ChrisRackauckas", "Tokazama"] -version = "0.3.0" +version = "0.3.1" [deps] IfElse = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173" diff --git a/src/Static.jl b/src/Static.jl index 16bd9e4..a71379b 100644 --- a/src/Static.jl +++ b/src/Static.jl @@ -70,8 +70,11 @@ static @aggressive_constprop static(x::X) where {X} = ifelse(is_static(X), identity, _no_static_type)(x) @aggressive_constprop static(x::Int) = StaticInt(x) @aggressive_constprop static(x::Union{Int8,UInt8,Int16,UInt16}) = StaticInt(x % Int) -if sizeof(Int) == 8 +@static if sizeof(Int) == 8 @aggressive_constprop static(x::Union{Int32,UInt32}) = StaticInt(x % Int) + @aggressive_constprop static(x::UInt64) = StaticInt(Int(x)) +else + @aggressive_constprop static(x::UInt32) = StaticInt(Int(x)) end @aggressive_constprop static(x::Float64) = StaticFloat64(x) @aggressive_constprop static(x::Bool) = StaticBool(x) diff --git a/test/runtests.jl b/test/runtests.jl index 0551c5e..8378637 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -5,7 +5,7 @@ using Test Aqua.test_all(Static) @testset "StaticInt" begin - @test StaticInt(UInt(8)) === StaticInt{8}() + @test static(UInt(8)) === StaticInt(UInt(8)) === StaticInt{8}() @test iszero(StaticInt(0)) @test !iszero(StaticInt(1)) @test !isone(StaticInt(0))