Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions src/Static.jl
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,9 @@ Base.xor(::StaticInteger{X}, ::StaticInteger{Y}) where {X, Y} = static(xor(X, Y)
Base.xor(::StaticInteger{X}, y::Union{Integer, Missing}) where {X} = xor(X, y)
Base.xor(x::Union{Integer, Missing}, ::StaticInteger{Y}) where {Y} = xor(x, Y)

Base.:(!)(::True) = False()
Base.:(!)(::False) = True()
# These are heavily invalidating, leading to major compile time increases downstream
#Base.:(!)(::True) = False()
#Base.:(!)(::False) = True()

Base.all(::Tuple{Vararg{True}}) = true
Base.all(::Tuple{Vararg{Union{True, False}}}) = false
Expand Down Expand Up @@ -745,47 +746,47 @@ end
"""
eq(x, y)

Equivalent to `!=` but if `x` and `y` are both static returns a `StaticBool.
Equivalent to `!=` but if `x` and `y` are both static returns a `StaticBool`.
"""
eq(x::X, y::Y) where {X, Y} = ifelse(is_static(X) & is_static(Y), static, identity)(x == y)
eq(x) = Base.Fix2(eq, x)

"""
ne(x, y)

Equivalent to `!=` but if `x` and `y` are both static returns a `StaticBool.
Equivalent to `!=` but if `x` and `y` are both static returns a `StaticBool`.
"""
ne(x::X, y::Y) where {X, Y} = !eq(x, y)
ne(x::X, y::Y) where {X, Y} = ifelse(is_static(X) & is_static(Y), static, identity)(x != y)
ne(x) = Base.Fix2(ne, x)

"""
gt(x, y)

Equivalent to `>` but if `x` and `y` are both static returns a `StaticBool.
Equivalent to `>` but if `x` and `y` are both static returns a `StaticBool`.
"""
gt(x::X, y::Y) where {X, Y} = ifelse(is_static(X) & is_static(Y), static, identity)(x > y)
gt(x) = Base.Fix2(gt, x)

"""
ge(x, y)

Equivalent to `>=` but if `x` and `y` are both static returns a `StaticBool.
Equivalent to `>=` but if `x` and `y` are both static returns a `StaticBool`.
"""
ge(x::X, y::Y) where {X, Y} = ifelse(is_static(X) & is_static(Y), static, identity)(x >= y)
ge(x) = Base.Fix2(ge, x)

"""
le(x, y)

Equivalent to `<=` but if `x` and `y` are both static returns a `StaticBool.
Equivalent to `<=` but if `x` and `y` are both static returns a `StaticBool`.
"""
le(x::X, y::Y) where {X, Y} = ifelse(is_static(X) & is_static(Y), static, identity)(x <= y)
le(x) = Base.Fix2(le, x)

"""
lt(x, y)

Equivalent to `<` but if `x` and `y` are both static returns a `StaticBool.
Equivalent to `<` but if `x` and `y` are both static returns a `StaticBool`.
"""
lt(x::X, y::Y) where {X, Y} = ifelse(is_static(X) & is_static(Y), static, identity)(x < y)
lt(x) = Base.Fix2(lt, x)
Expand Down
2 changes: 0 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ end

@test @inferred(~t) === f
@test @inferred(~f) === t
@test @inferred(!t) === f
@test @inferred(!f) === t
@test @inferred(+t) === StaticInt(1)
@test @inferred(+f) === StaticInt(0)
@test @inferred(-t) === StaticInt(-1)
Expand Down