Skip to content

Commit 866c61d

Browse files
authored
don't taint :terminates because of the loop in afoldl (#57353)
The iteration count is always finite.
1 parent c46b533 commit 866c61d

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

base/operators.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,7 @@ const ⊽ = nor
593593
# method count limit in inference
594594
afoldl(op, a) = a
595595
function afoldl(op, a, bs...)
596+
@_terminates_locally_meta
596597
l = length(bs)
597598
i = 0; y = a; l == i && return y
598599
#@nexprs 31 i -> (y = op(y, bs[i]); l == i && return y)

test/operators.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ end
350350
end
351351

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

354355
@testset "Returns" begin
355356
@test @inferred(Returns(1)() ) === 1

0 commit comments

Comments
 (0)