Skip to content

Commit a5df8ad

Browse files
committed
test for number of arguments edgecase
1 parent f83e5b3 commit a5df8ad

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

base/operators.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1211,7 +1211,7 @@ end
12111211

12121212
function (f::Fix{F,N,T})(args::Vararg{Any,M}) where {F,N,T,M}
12131213
@inline
1214-
M < N - 1 || throw(ArgumentError("expected at least $(N-1) arguments to a `Fix` function with `N=$(N)`"))
1214+
M < N - 1 || M == 0 || throw(ArgumentError("expected at least $(N-1) arguments to a `Fix` function with `N=$(N)`"))
12151215
return f.f(args[begin:begin+(N-2)]..., f.x..., args[begin+(N-1):end]...)
12161216
end
12171217

test/functional.jl

+11
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,17 @@ end
348348
h = Fix(*, Val(1), "1", "2", "3")
349349
@test h() == "123"
350350
end
351+
@testset "with integer rather than Val" begin
352+
function f(x, y)
353+
g = Fix(1, x, y) do x, y
354+
x = x^2
355+
y = y * 3.5
356+
x + y
357+
end
358+
g()
359+
end
360+
@inferred f(1, 2)
361+
end
351362

352363
@testset "varargs inside Fix" begin
353364
lazy_sum = Fix(+, Val(1), 1, 2, 3, 4, 5)

0 commit comments

Comments
 (0)