Skip to content

Commit

Permalink
Merge pull request #7 from tkf/type-capture
Browse files Browse the repository at this point in the history
Fix inference for fix(::Type, ...)
  • Loading branch information
goretkin authored Jul 10, 2020
2 parents e20fa8b + c63b9e7 commit cd45bf0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Curry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ struct Fix{F, A, K} <: Function
k::K
end

Fix(::Type{T}, a, k) where {T} = Fix{Type{T}, typeof(a), typeof(k)}(T, a, k)

function (c::Fix)(args...; kw...)
c.f(interleave(c.a, args)...; c.k..., kw...)
end
Expand Down
9 changes: 9 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ using Test
@inferred a1(1.0)
end

@testset "fix(::Type, ...)" begin
f = @inferred fix(CartesianIndex, nothing, Some(1))
@test @inferred(f(2)) === CartesianIndex(2, 1)

modulo(x; by) = mod(x, by)
g = @inferred fix(modulo, nothing, by = UInt8)
@test_broken @inferred(g(271)) === 0x0f
end

@testset "Fix.jl" begin

#=
Expand Down

0 comments on commit cd45bf0

Please sign in to comment.