Skip to content

Commit

Permalink
don't taint :terminates because of the loop in afoldl (JuliaLang#…
Browse files Browse the repository at this point in the history
…57353)

The iteration count is always finite.
  • Loading branch information
nsajko authored Feb 11, 2025
1 parent c46b533 commit 866c61d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions base/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ const ⊽ = nor
# method count limit in inference
afoldl(op, a) = a
function afoldl(op, a, bs...)
@_terminates_locally_meta
l = length(bs)
i = 0; y = a; l == i && return y
#@nexprs 31 i -> (y = op(y, bs[i]); l == i && return y)
Expand Down
1 change: 1 addition & 0 deletions test/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ end
end

@test [Base.afoldl(+, 1:i...) for i = 1:40] == [i * (i + 1) ÷ 2 for i = 1:40]
@test Core.Compiler.is_terminates(Base.infer_effects(Base.afoldl, Tuple{typeof(+), Vararg{Int, 100}}))

@testset "Returns" begin
@test @inferred(Returns(1)() ) === 1
Expand Down

0 comments on commit 866c61d

Please sign in to comment.