diff --git a/base/operators.jl b/base/operators.jl index 9a12649eb731e..d5391bcaf5a6f 100644 --- a/base/operators.jl +++ b/base/operators.jl @@ -1211,7 +1211,7 @@ end function (f::Fix{F,N,T})(args::Vararg{Any,M}) where {F,N,T,M} @inline - M < N - 1 || throw(ArgumentError("expected at least $(N-1) arguments to a `Fix` function with `N=$(N)`")) + M < N - 1 || N == 1 || throw(ArgumentError("expected at least $(N-1) arguments to a `Fix` function with `N=$(N)`")) return f.f(args[begin:begin+(N-2)]..., f.x..., args[begin+(N-1):end]...) end diff --git a/test/functional.jl b/test/functional.jl index faa8cb30b74fe..398d8f893afbd 100644 --- a/test/functional.jl +++ b/test/functional.jl @@ -348,6 +348,17 @@ end h = Fix(*, Val(1), "1", "2", "3") @test h() == "123" end + @testset "with integer rather than Val" begin + function f(x, y) + g = Fix(1, x, y) do x, y + x = x^2 + y = y * 3.5 + x + y + end + g() + end + @inferred f(1, 2) + end @testset "varargs inside Fix" begin lazy_sum = Fix(+, Val(1), 1, 2, 3, 4, 5)